All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-flush: Queue through IO scheduler when flush not required
@ 2015-11-12 13:25 Jan Kara
  2015-11-16 20:14 ` Jeff Moyer
  2015-11-16 22:28 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Kara @ 2015-11-12 13:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Jeff Moyer, LKML, Jan Kara

Currently blk_insert_flush() just adds flush request to q->queue_head
when flush is not required. That completely bypasses IO scheduler so
e.g. CFQ can be idling waiting for new request to arrive and will idle
through the whole window unnecessarily. Luckily this only happens in
rare cases as usually checks in generic_make_request_checks() clear
FLUSH and FUA flags early if they are not needed.

When no flushing is actually required, we can easily fix the problem by
properly queueing the request through the IO scheduler. Ideally IO
scheduler should be also made aware of requests queued via
blk_flush_queue_rq(). However inserting flush request through IO
scheduler can have unwanted side-effects since due to flush batching
delaying the flush request in IO scheduler will delay all flush requests
possibly coming from other processes. So we keep adding the request
directly to q->queue_head.

Signed-off-by: Jan Kara <jack@suse.com>
---
 block/blk-flush.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index 9c423e53324a..c81d56ec308f 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -422,7 +422,7 @@ void blk_insert_flush(struct request *rq)
 		if (q->mq_ops) {
 			blk_mq_insert_request(rq, false, false, true);
 		} else
-			list_add_tail(&rq->queuelist, &q->queue_head);
+			q->elevator->type->ops.elevator_add_req_fn(q, rq);
 		return;
 	}
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-flush: Queue through IO scheduler when flush not required
  2015-11-12 13:25 [PATCH] blk-flush: Queue through IO scheduler when flush not required Jan Kara
@ 2015-11-16 20:14 ` Jeff Moyer
  2015-11-16 22:28 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Moyer @ 2015-11-16 20:14 UTC (permalink / raw)
  To: Jan Kara; +Cc: Jens Axboe, LKML

Jan Kara <jack@suse.com> writes:

> Currently blk_insert_flush() just adds flush request to q->queue_head
> when flush is not required. That completely bypasses IO scheduler so
> e.g. CFQ can be idling waiting for new request to arrive and will idle
> through the whole window unnecessarily. Luckily this only happens in
> rare cases as usually checks in generic_make_request_checks() clear
> FLUSH and FUA flags early if they are not needed.

Right.  I think the only way we'd even enter that 'if' block was if the
drive state changed (from WB cache to WT cache) between
generic_make_request_checks and blk_insert_flush.

> When no flushing is actually required, we can easily fix the problem by
> properly queueing the request through the IO scheduler. Ideally IO
> scheduler should be also made aware of requests queued via
> blk_flush_queue_rq(). However inserting flush request through IO
> scheduler can have unwanted side-effects since due to flush batching
> delaying the flush request in IO scheduler will delay all flush requests
> possibly coming from other processes. So we keep adding the request
> directly to q->queue_head.

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

> Signed-off-by: Jan Kara <jack@suse.com>
> ---
>  block/blk-flush.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/blk-flush.c b/block/blk-flush.c
> index 9c423e53324a..c81d56ec308f 100644
> --- a/block/blk-flush.c
> +++ b/block/blk-flush.c
> @@ -422,7 +422,7 @@ void blk_insert_flush(struct request *rq)
>  		if (q->mq_ops) {
>  			blk_mq_insert_request(rq, false, false, true);
>  		} else
> -			list_add_tail(&rq->queuelist, &q->queue_head);
> +			q->elevator->type->ops.elevator_add_req_fn(q, rq);
>  		return;
>  	}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-flush: Queue through IO scheduler when flush not required
  2015-11-12 13:25 [PATCH] blk-flush: Queue through IO scheduler when flush not required Jan Kara
  2015-11-16 20:14 ` Jeff Moyer
@ 2015-11-16 22:28 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2015-11-16 22:28 UTC (permalink / raw)
  To: Jan Kara; +Cc: Jeff Moyer, LKML

On 11/12/2015 06:25 AM, Jan Kara wrote:
> Currently blk_insert_flush() just adds flush request to q->queue_head
> when flush is not required. That completely bypasses IO scheduler so
> e.g. CFQ can be idling waiting for new request to arrive and will idle
> through the whole window unnecessarily. Luckily this only happens in
> rare cases as usually checks in generic_make_request_checks() clear
> FLUSH and FUA flags early if they are not needed.
>
> When no flushing is actually required, we can easily fix the problem by
> properly queueing the request through the IO scheduler. Ideally IO
> scheduler should be also made aware of requests queued via
> blk_flush_queue_rq(). However inserting flush request through IO
> scheduler can have unwanted side-effects since due to flush batching
> delaying the flush request in IO scheduler will delay all flush requests
> possibly coming from other processes. So we keep adding the request
> directly to q->queue_head.

Applied, thanks Jan.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-16 22:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 13:25 [PATCH] blk-flush: Queue through IO scheduler when flush not required Jan Kara
2015-11-16 20:14 ` Jeff Moyer
2015-11-16 22:28 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.