diff --git a/block/blk-core.c b/block/blk-core.c index b3c48aaa6dc0..80a33af0050d 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1796,8 +1796,11 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio) /* * If this is the first request added after a plug, fire * of a plug trace. + * + * @request_count may become stale because of schedule + * out, so check plug list again. */ - if (!request_count) + if (!request_count || list_empty(&plug->list)) trace_block_plug(q); else { struct request *last = list_entry_rq(plug->list.prev); diff --git a/block/blk-mq.c b/block/blk-mq.c index aaea6ea66fac..434cb5f7d9ae 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1380,6 +1380,13 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio) struct request *last = NULL; blk_mq_bio_to_request(rq, bio); + + /* + * @request_count may become stale because of schedule + * out, so check the list again. + */ + if (list_empty(&plug->mq_list)) + request_count = 0; if (!request_count) trace_block_plug(q); else