public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: Do not merge if merging is disabled
@ 2023-07-06 20:14 Bart Van Assche
  2023-07-06 23:43 ` Damien Le Moal
  2023-07-07  0:38 ` Ming Lei
  0 siblings, 2 replies; 6+ messages in thread
From: Bart Van Assche @ 2023-07-06 20:14 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche, Ming Lei,
	Damien Le Moal

While testing the performance impact of zoned write pipelining, I
noticed that merging happens even if merging has been disabled via
sysfs. Fix this.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/blk-mq-sched.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index 67c95f31b15b..8883721f419a 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -375,7 +375,8 @@ bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
 bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq,
 				   struct list_head *free)
 {
-	return rq_mergeable(rq) && elv_attempt_insert_merge(q, rq, free);
+	return !blk_queue_nomerges(q) && rq_mergeable(rq) &&
+		elv_attempt_insert_merge(q, rq, free);
 }
 EXPORT_SYMBOL_GPL(blk_mq_sched_try_insert_merge);
 

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

* Re: [PATCH] block: Do not merge if merging is disabled
  2023-07-06 20:14 [PATCH] block: Do not merge if merging is disabled Bart Van Assche
@ 2023-07-06 23:43 ` Damien Le Moal
  2023-07-07  0:38 ` Ming Lei
  1 sibling, 0 replies; 6+ messages in thread
From: Damien Le Moal @ 2023-07-06 23:43 UTC (permalink / raw)
  To: Bart Van Assche, Jens Axboe; +Cc: linux-block, Christoph Hellwig, Ming Lei

On 7/7/23 05:14, Bart Van Assche wrote:
> While testing the performance impact of zoned write pipelining, I
> noticed that merging happens even if merging has been disabled via
> sysfs. Fix this.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Damien Le Moal <dlemoal@kernel.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Looks good.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

> ---
>  block/blk-mq-sched.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
> index 67c95f31b15b..8883721f419a 100644
> --- a/block/blk-mq-sched.c
> +++ b/block/blk-mq-sched.c
> @@ -375,7 +375,8 @@ bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
>  bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq,
>  				   struct list_head *free)
>  {
> -	return rq_mergeable(rq) && elv_attempt_insert_merge(q, rq, free);
> +	return !blk_queue_nomerges(q) && rq_mergeable(rq) &&
> +		elv_attempt_insert_merge(q, rq, free);
>  }
>  EXPORT_SYMBOL_GPL(blk_mq_sched_try_insert_merge);
>  

-- 
Damien Le Moal
Western Digital Research


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

* Re: [PATCH] block: Do not merge if merging is disabled
  2023-07-06 20:14 [PATCH] block: Do not merge if merging is disabled Bart Van Assche
  2023-07-06 23:43 ` Damien Le Moal
@ 2023-07-07  0:38 ` Ming Lei
  2023-07-07  1:50   ` Bart Van Assche
  1 sibling, 1 reply; 6+ messages in thread
From: Ming Lei @ 2023-07-07  0:38 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Jens Axboe, linux-block, Christoph Hellwig, Damien Le Moal

On Thu, Jul 06, 2023 at 01:14:33PM -0700, Bart Van Assche wrote:
> While testing the performance impact of zoned write pipelining, I
> noticed that merging happens even if merging has been disabled via
> sysfs. Fix this.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Damien Le Moal <dlemoal@kernel.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  block/blk-mq-sched.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
> index 67c95f31b15b..8883721f419a 100644
> --- a/block/blk-mq-sched.c
> +++ b/block/blk-mq-sched.c
> @@ -375,7 +375,8 @@ bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
>  bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq,
>  				   struct list_head *free)
>  {
> -	return rq_mergeable(rq) && elv_attempt_insert_merge(q, rq, free);
> +	return !blk_queue_nomerges(q) && rq_mergeable(rq) &&
> +		elv_attempt_insert_merge(q, rq, free);
>  }
>  EXPORT_SYMBOL_GPL(blk_mq_sched_try_insert_merge);

elv_attempt_insert_merge() does check blk_queue_nomerges() at its entry,
so this patch fix nothing.

Given blk_mq_sched_try_insert_merge is only called from bfq and
deadline, it may not matter to apply this optimization.

Thanks,
Ming


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

* Re: [PATCH] block: Do not merge if merging is disabled
  2023-07-07  0:38 ` Ming Lei
@ 2023-07-07  1:50   ` Bart Van Assche
  2023-07-07  3:34     ` Damien Le Moal
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2023-07-07  1:50 UTC (permalink / raw)
  To: Ming Lei; +Cc: Jens Axboe, linux-block, Christoph Hellwig, Damien Le Moal

On 7/6/23 17:38, Ming Lei wrote:
> Given blk_mq_sched_try_insert_merge is only called from bfq and
> deadline, it may not matter to apply this optimization.

Without this patch, the documentation of the "nomerges" sysfs
attribute is incorrect. I need this patch because I want the
ability to disable merging even if an I/O scheduler has been
selected. As mentioned in the patch description, I discovered
this while I was writing a shell script that submits various
I/O workloads to a block device.

Bart.


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

* Re: [PATCH] block: Do not merge if merging is disabled
  2023-07-07  1:50   ` Bart Van Assche
@ 2023-07-07  3:34     ` Damien Le Moal
  2023-07-07 13:50       ` Bart Van Assche
  0 siblings, 1 reply; 6+ messages in thread
From: Damien Le Moal @ 2023-07-07  3:34 UTC (permalink / raw)
  To: Bart Van Assche, Ming Lei; +Cc: Jens Axboe, linux-block, Christoph Hellwig

On 7/7/23 10:50, Bart Van Assche wrote:
> On 7/6/23 17:38, Ming Lei wrote:
>> Given blk_mq_sched_try_insert_merge is only called from bfq and
>> deadline, it may not matter to apply this optimization.
> 
> Without this patch, the documentation of the "nomerges" sysfs
> attribute is incorrect. I need this patch because I want the
> ability to disable merging even if an I/O scheduler has been
> selected. As mentioned in the patch description, I discovered
> this while I was writing a shell script that submits various
> I/O workloads to a block device.

Ming's point still stands I think: blk_queue_nomerges(q) is the first
thing checked in elv_attempt_insert_merge(). So your patch should be a
no-op and disabling merging through sysfs should still be effective. Why
is your patch changing anything ?

Moving blk_mq_sched_try_insert_merge() call to rq_mergeable(rq) inside
elv_attempt_insert_merge() would also make a lot of sense I think. With
that, blk_mq_sched_try_insert_merge() would be reduced to calling only
elv_attempt_insert_merge(), which means that elv_attempt_insert_merge()
could go away.

-- 
Damien Le Moal
Western Digital Research


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

* Re: [PATCH] block: Do not merge if merging is disabled
  2023-07-07  3:34     ` Damien Le Moal
@ 2023-07-07 13:50       ` Bart Van Assche
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2023-07-07 13:50 UTC (permalink / raw)
  To: Damien Le Moal, Ming Lei; +Cc: Jens Axboe, linux-block, Christoph Hellwig

On 7/6/23 20:34, Damien Le Moal wrote:
> Ming's point still stands I think: blk_queue_nomerges(q) is the first
> thing checked in elv_attempt_insert_merge(). So your patch should be a
> no-op and disabling merging through sysfs should still be effective. Why
> is your patch changing anything ?
> 
> Moving blk_mq_sched_try_insert_merge() call to rq_mergeable(rq) inside
> elv_attempt_insert_merge() would also make a lot of sense I think. With
> that, blk_mq_sched_try_insert_merge() would be reduced to calling only
> elv_attempt_insert_merge(), which means that elv_attempt_insert_merge()
> could go away.

Let's drop this patch. Since this patch was developed against an older
kernel version, let me check whether this patch is perhaps only needed
for the kernel version it was developed against.

Thanks,

Bart.



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

end of thread, other threads:[~2023-07-07 13:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-06 20:14 [PATCH] block: Do not merge if merging is disabled Bart Van Assche
2023-07-06 23:43 ` Damien Le Moal
2023-07-07  0:38 ` Ming Lei
2023-07-07  1:50   ` Bart Van Assche
2023-07-07  3:34     ` Damien Le Moal
2023-07-07 13:50       ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox