From: Zhang Wensheng zhangwensheng5@huawei.com
hulk inclusion category: bugfix bugzilla: 187044, https://gitee.com/openeuler/kernel/issues/I5F2BY CVE: NA
--------------------------------
There is io path like: blk_mq_make_request blk_mq_bio_to_request blk_account_io_start part_round_stats part_in_flight /* controlled by precise_iostat, it also can calculated by atomic accumulation */ blk_mq_in_flight blk_mq_queue_tag_busy_iter bt_for_each blk_mq_find_and_get_req blk_mq_tags_lock_irqsave ... blk_mq_tags_unlock_irqrestore As we can see, there is a unnecessary locking operation in io path which will affect concurrency performance. This problem was introduced by "part_round_stats" and "part_in_flight" which using tag to account inflight.
Fix it by using "precise_iostat" too, moving part_round_stats into "precise_iostat", when "precise_iostat" is on, the iostat is accurate and using atomic accumulation to account inflight. when it is off, the io iostat will not be accurate.
Signed-off-by: Zhang Wensheng zhangwensheng5@huawei.com Reviewed-by: Yu Kuai yukuai3@huawei.com Reviewed-by: Jason Yan yanaijie@huawei.com Signed-off-by: Yongqiang Liu liuyongqiang13@huawei.com --- block/bio.c | 5 ++++- block/blk-core.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/block/bio.c b/block/bio.c index b5bbc023d64d..48092fe0c116 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1689,7 +1689,10 @@ void generic_start_io_acct(struct request_queue *q, int op, const int sgrp = op_stat_group(op); int cpu = part_stat_lock();
- part_round_stats(q, cpu, part); + if (precise_iostat) + part_round_stats(q, cpu, part); + else + update_io_ticks(cpu, part, jiffies, false); part_stat_inc(cpu, part, ios[sgrp]); part_stat_add(cpu, part, sectors[sgrp], sectors); part_inc_in_flight(q, part, op_is_write(op)); diff --git a/block/blk-core.c b/block/blk-core.c index 5892c532ae5b..219aee53a1be 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2864,7 +2864,10 @@ void blk_account_io_start(struct request *rq, bool new_io) part_stat_inc(cpu, part, merges[rw]); } else { part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq)); - part_round_stats(rq->q, cpu, part); + if (!precise_iostat) + update_io_ticks(cpu, part, jiffies, false); + else + part_round_stats(rq->q, cpu, part); part_inc_in_flight(rq->q, part, rw); rq->part = part; }