fix inaccurate io_ticks
v5 cover fix inaccurate io_ticks
Hi,
This patchset include two patches,
01. block: fix inaccurate io_ticks
fix the io_ticks if start a new IO and there is no inflight IO before.
02. blk-mq: break more earlier when interate hctx
An optimization for blk_mq_queue_inflight and blk_mq_part_is_in_flight these two function only want to know if there is IO inflight and do not care how many inflight IOs are there.
After this patch blk_mq_queue_inflight will stop interate other hctx when find a inflight IO, blk_mq_part_is_in_inflight stop interate other setbit/hctx when find a inflight IO.
Changes since v4:
* only get inflight in update_io_ticks when start a new IO every jiffy.
Changes since v3:
* add a parameter for blk_mq_queue_tag_busy_iter to break earlier when interate hctx of a queue, since blk_mq_part_is_in_inflight and blk_mq_queue_inflight do not care how many inflight IOs.
Changes since v2:
* use blk_mq_queue_tag_busy_iter framework instead of open-code.
* update_io_ticks before update inflight for __part_start_io_acct
Changes since v1:
* avoid iterate all tagset, return directly if find a set bit.
* fix some typo in commit message
Weiping Zhang (2):
block: fix inaccurate io_ticks
blk-mq: break more earlier when interate hctx
block/blk-core.c | 19 ++++++++++---- block/blk-mq-tag.c | 11 ++++++-- block/blk-mq-tag.h | 2 +- block/blk-mq.c | 58 +++++++++++++++++++++++++++++++++++++++--- block/blk-mq.h | 1 + block/blk.h | 1 + block/genhd.c | 13 ++++++++++ include/linux/blk-mq.h | 1 + 8 files changed, 94 insertions(+), 12 deletions(-)
Signature · 1 line
2.18.4
Ping
Quoted 49 lines · Weiping Zhang
Hi,
This patchset include two patches,
01. block: fix inaccurate
io_ticks
fix theio_ticksif start a new IO and there is no inflight IO before.02. blk-mq: break more earlier when interate hctx
An optimization forblk_mq_queue_inflightandblk_mq_part_is_in_flightthese two function only want to know if there is IO inflight and do not care how many inflight IOs are there.
After this patchblk_mq_queue_inflightwill stop interate other hctx when find a inflight IO,blk_mq_part_is_in_inflightstop interate other setbit/hctx when find a inflight IO.Changes since v4:
* only get inflight inupdate_io_tickswhen start a new IO every jiffy.Changes since v3:
* add a parameter forblk_mq_queue_tag_busy_iterto break earlier when interate hctx of a queue, sinceblk_mq_part_is_in_inflightandblk_mq_queue_inflightdo not care how many inflight IOs.Changes since v2:
* useblk_mq_queue_tag_busy_iterframework instead of open-code.
*update_io_ticksbefore update inflight for__part_start_io_acctChanges since v1:
* avoid iterate all tagset, return directly if find a set bit.
* fix some typo in commit messageWeiping Zhang (2):
block: fix inaccurateio_ticks
blk-mq: break more earlier when interate hctxblock/blk-core.c | 19 ++++++++++---- block/blk-mq-tag.c | 11 ++++++-- block/blk-mq-tag.h | 2 +- block/blk-mq.c | 58 +++++++++++++++++++++++++++++++++++++++--- block/blk-mq.h | 1 + block/blk.h | 1 + block/genhd.c | 13 ++++++++++ include/linux/blk-mq.h | 1 + 8 files changed, 94 insertions(+), 12 deletions(-)--
2.18.4
Hi Jens,
Ping
Quoted 54 lines · Weiping Zhang
Ping
Quoted 49 lines · Weiping Zhang
Hi,
This patchset include two patches,
01. block: fix inaccurate
io_ticks
fix theio_ticksif start a new IO and there is no inflight IO before.02. blk-mq: break more earlier when interate hctx
An optimization forblk_mq_queue_inflightandblk_mq_part_is_in_flightthese two function only want to know if there is IO inflight and do not care how many inflight IOs are there.
After this patchblk_mq_queue_inflightwill stop interate other hctx when find a inflight IO,blk_mq_part_is_in_inflightstop interate other setbit/hctx when find a inflight IO.Changes since v4:
* only get inflight inupdate_io_tickswhen start a new IO every jiffy.Changes since v3:
* add a parameter forblk_mq_queue_tag_busy_iterto break earlier when interate hctx of a queue, sinceblk_mq_part_is_in_inflightandblk_mq_queue_inflightdo not care how many inflight IOs.Changes since v2:
* useblk_mq_queue_tag_busy_iterframework instead of open-code.
*update_io_ticksbefore update inflight for__part_start_io_acctChanges since v1:
* avoid iterate all tagset, return directly if find a set bit.
* fix some typo in commit messageWeiping Zhang (2):
block: fix inaccurateio_ticks
blk-mq: break more earlier when interate hctxblock/blk-core.c | 19 ++++++++++---- block/blk-mq-tag.c | 11 ++++++-- block/blk-mq-tag.h | 2 +- block/blk-mq.c | 58 +++++++++++++++++++++++++++++++++++++++--- block/blk-mq.h | 1 + block/blk.h | 1 + block/genhd.c | 13 ++++++++++ include/linux/blk-mq.h | 1 + 8 files changed, 94 insertions(+), 12 deletions(-)--
2.18.4
Quoted 3 lines · Weiping Zhang
Hi Jens,
Ping
Hello Weiping,
Not sure we have to fix this issue, and adding blk_mq_queue_inflight() back to IO path brings cost which turns out to be visible, and I did get soft lockup report on Azure NVMe because of this kind of cost.
BTW, suppose the io accounting issue needs to be fixed, just wondering why not simply revert 5b18b5a73760 ("block: delete part_round_stats and switch to less precise counting"), and the original way had been worked for decades.
Thanks,
Ming
Quoted 4 lines · Ming Lei
Quoted 2 lines · Weiping Zhang
Hi Jens,
Quoted 8 lines
Quoted 1 line
Ping
Hello Weiping,
Not sure we have to fix this issue, and adding
blk_mq_queue_inflight()back to IO path brings cost which turns out to be visible, and I did get soft lockup report on Azure NVMe because of this kind of cost.
Have you test v5, this patch is different from v1, the v1 gets inflight for each IO,
v5 has changed to get inflight every jiffer.
If for v5, can we reproduce it on null_blk ?
Quoted 5 lines
BTW, suppose the io accounting issue needs to be fixed, just wondering why not simply revert
5b18b5a73760("block: deletepart_round_statsand switch to less precise counting"), and the original way had been worked for decades.
This patch is more better than before, it will break early when find there is inflight io on any cpu, for the worst case(the io in running on the last cpu), it iterates all cpus.
Quoted 4 lines
Thanks,
Ming
Quoted 9 lines · Weiping Zhang
Quoted 8 lines · Ming Lei
Quoted 3 lines · Weiping Zhang
Hi Jens,
Ping
Hello Weiping,
Quoted 7 lines
Quoted 4 lines
Not sure we have to fix this issue, and adding
blk_mq_queue_inflight()back to IO path brings cost which turns out to be visible, and I did get soft lockup report on Azure NVMe because of this kind of cost.Have you test v5, this patch is different from v1, the v1 gets inflight for each IO,
v5 has changed to get inflight every jiffer.
I meant the issue can be reproduced on kernel before 5b18b5a73760("block:
delete part_round_stats and switch to less precise counting").
Also do we really need to fix this issue? I understand device utilization becomes not accurate at very small load, is it really worth of adding runtime load in fast path for fixing this issue?
Quoted 2 lines
If for v5, can we reproduce it on
null_blk?
No, I just saw report on Azure NVMe.
Quoted 9 lines
Quoted 6 lines
BTW, suppose the io accounting issue needs to be fixed, just wondering why not simply revert
5b18b5a73760("block: deletepart_round_statsand switch to less precise counting"), and the original way had been worked for decades.This patch is more better than before, it will break early when find there is inflight io on any cpu, for the worst case(the io in running on the last cpu), it iterates all cpus.
Please see the following case:
1) one device has 256 hw queues, and the system has 256 cpu cores, and each hw queue's depth is 1k.
2) there isn't any io load on CPUs(0 ~ 254)
3) heavy io load is run on CPU 255
So with your trick the code still need to iterate hw queues from 0 to 254, and the load isn't something which can be ignored. Especially it is just for io accounting.
Thanks,
Ming
Quoted 19 lines · Ming Lei
Quoted 9 lines · Weiping Zhang
Quoted 8 lines · Ming Lei
Quoted 3 lines · Weiping Zhang
Hi Jens,
Ping
Hello Weiping,
Quoted 7 lines
Quoted 4 lines
Not sure we have to fix this issue, and adding
blk_mq_queue_inflight()back to IO path brings cost which turns out to be visible, and I did get soft lockup report on Azure NVMe because of this kind of cost.Have you test v5, this patch is different from v1, the v1 gets inflight for each IO,
v5 has changed to get inflight every jiffer.
Quoted 7 lines
I meant the issue can be reproduced on kernel before 5b18b5a73760("block:
deletepart_round_statsand switch to less precise counting").Also do we really need to fix this issue? I understand device utilization becomes not accurate at very small load, is it really worth of adding runtime load in fast path for fixing this issue?
Hello Ming,
The problem is user hard to know how busy disk is,
for small load, it shows high utilization, for heavy load it also shows high utilization, that makes %util meaningless.
The following test case shows a big gap with same workload:
modprobe null_blk submit_queues=8 queue_mode=2 irqmode=2 completion_nsec=100000 fio -name=test -ioengine=sync -bs=4K -rw=write -filename=/dev/nullb0 -size=100M -time_based=1 -direct=1 -runtime=300 -rate=4m &
w/s w_await %util
-----------------------------------------------
before patch 1024 0.15 100
after patch 1024 0.15 14.5
I know for hyper speed disk, add such accounting in fast path is harmful, maybe we add an interface to enable/disable io_ticks accounting, like what /sys/block/<disk>/queue/iostat does.
eg: /sys/block/<disk>/queue/iostat_io_ticks when write 0 to it, just disable io_ticks totally.
Or any other good idea ?
Quoted 15 lines
Quoted 2 lines
If for v5, can we reproduce it on
null_blk?No, I just saw report on Azure NVMe.
Quoted 9 lines
Quoted 6 lines
BTW, suppose the io accounting issue needs to be fixed, just wondering why not simply revert
5b18b5a73760("block: deletepart_round_statsand switch to less precise counting"), and the original way had been worked for decades.This patch is more better than before, it will break early when find there is inflight io on any cpu, for the worst case(the io in running on the last cpu), it iterates all cpus.
Yes, it's the worst case.
Actually v5 has two improvements compare to before 5b18b5a73760:
1. for io end, v5 do not get inflight count
2. for io start, v5 just find the first inflight io in any cpu, for the worst case it does same as before.
Quoted 9 lines
Please see the following case:
1) one device has 256 hw queues, and the system has 256 cpu cores, and each hw queue's depth is 1k.
2) there isn't any io load on CPUs(0 ~ 254)
3) heavy io load is run on CPU 255
Quoted 8 lines
So with your trick the code still need to iterate hw queues from 0 to 254, and the load isn't something which can be ignored. Especially it is just for io accounting.
Thanks,
Ming
Thanks
Ping
Quoted 93 lines · Weiping Zhang
Quoted 19 lines · Ming Lei
Quoted 9 lines · Weiping Zhang
Quoted 8 lines · Ming Lei
Quoted 3 lines · Weiping Zhang
Hi Jens,
Ping
Hello Weiping,
Quoted 7 lines
Quoted 4 lines
Not sure we have to fix this issue, and adding
blk_mq_queue_inflight()back to IO path brings cost which turns out to be visible, and I did get soft lockup report on Azure NVMe because of this kind of cost.Have you test v5, this patch is different from v1, the v1 gets inflight for each IO,
v5 has changed to get inflight every jiffer.Quoted 7 lines
I meant the issue can be reproduced on kernel before 5b18b5a73760("block:
deletepart_round_statsand switch to less precise counting").Also do we really need to fix this issue? I understand device utilization becomes not accurate at very small load, is it really worth of adding runtime load in fast path for fixing this issue?
Hello Ming,
The problem is user hard to know how busy disk is,
for small load, it shows high utilization, for heavy load it also shows high utilization, that makes %util meaningless.The following test case shows a big gap with same workload:
modprobe
null_blksubmit_queues=8 queue_mode=2 irqmode=2 completion_nsec=100000 fio -name=test -ioengine=sync -bs=4K -rw=write -filename=/dev/nullb0 -size=100M -time_based=1 -direct=1 -runtime=300 -rate=4m &w/s
w_await%util
-----------------------------------------------
before patch 1024 0.15 100
after patch 1024 0.15 14.5I know for hyper speed disk, add such accounting in fast path is harmful, maybe we add an interface to enable/disable
io_ticksaccounting, like what /sys/block/<disk>/queue/iostat does.eg: /sys/block/<disk>/queue/iostat_io_ticks when write 0 to it, just disable
io_tickstotally.Or any other good idea ?
Quoted 15 lines
Quoted 2 lines
If for v5, can we reproduce it on
null_blk?No, I just saw report on Azure NVMe.
Quoted 9 lines
Quoted 6 lines
BTW, suppose the io accounting issue needs to be fixed, just wondering why not simply revert
5b18b5a73760("block: deletepart_round_statsand switch to less precise counting"), and the original way had been worked for decades.This patch is more better than before, it will break early when find there is inflight io on any cpu, for the worst case(the io in running on the last cpu), it iterates all cpus.
Yes, it's the worst case.
Actually v5 has two improvements compare to before5b18b5a73760:
1. for io end, v5 do not get inflight count
2. for io start, v5 just find the first inflight io in any cpu, for the worst case it does same as before.Quoted 9 lines
Please see the following case:
1) one device has 256 hw queues, and the system has 256 cpu cores, and each hw queue's depth is 1k.
2) there isn't any io load on CPUs(0 ~ 254)
3) heavy io load is run on CPU 255
Quoted 8 lines
So with your trick the code still need to iterate hw queues from 0 to 254, and the load isn't something which can be ignored. Especially it is just for io accounting.
Thanks,
MingThanks
Ping again.