block: Do not merge if merging is disabled
PATCH 1/1 block: Do not merge if merging is disabled
While testing the performance impact of zoned write pipelining, I noticed that merging happens even if merging has been disabled via sysfs. Fix this.
--- block/blk-mq-sched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-mq-sched.c +2 -1
@@ -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);
Quoted 8 lines · Bart Van Assche
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 <[email protected]>Cc Ming Lei <[email protected]>Cc Damien Le Moal <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Looks good.
Quoted 18 lines
--- block/blk-mq-sched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)block/blk-mq-sched.c +2
-1@@ -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);
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 17 lines · Bart Van Assche
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 <[email protected]>Cc Ming Lei <[email protected]>Cc Damien Le Moal <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- block/blk-mq-sched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)block/blk-mq-sched.c +0
-0
block/blk-mq-sched.c bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio, · line 381
Quoted 8 lines
block/blk-mq-sched.c +2
-1@@ -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
Quoted 2 lines · Ming Lei
Given
blk_mq_sched_try_insert_mergeis 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.
Quoted 10 lines · Bart Van Assche
Quoted 2 lines · Ming Lei
Given
blk_mq_sched_try_insert_mergeis 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.
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 10 lines · Damien Le Moal
Ming's point still stands I think:
blk_queue_nomerges(q)is the first thing checked inelv_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 torq_mergeable(rq)insideelv_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 onlyelv_attempt_insert_merge(), which means thatelv_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.