提交 9dcfca65 编写于 作者: Z Zhang Wensheng 提交者: Yongqiang Liu

block: use "precise_iostat" to switch accurate iostat account

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: NZhang Wensheng <zhangwensheng5@huawei.com>
Reviewed-by: NYu Kuai <yukuai3@huawei.com>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 09614b96
...@@ -1689,7 +1689,10 @@ void generic_start_io_acct(struct request_queue *q, int op, ...@@ -1689,7 +1689,10 @@ void generic_start_io_acct(struct request_queue *q, int op,
const int sgrp = op_stat_group(op); const int sgrp = op_stat_group(op);
int cpu = part_stat_lock(); int cpu = part_stat_lock();
if (precise_iostat)
part_round_stats(q, cpu, part); part_round_stats(q, cpu, part);
else
update_io_ticks(cpu, part, jiffies, false);
part_stat_inc(cpu, part, ios[sgrp]); part_stat_inc(cpu, part, ios[sgrp]);
part_stat_add(cpu, part, sectors[sgrp], sectors); part_stat_add(cpu, part, sectors[sgrp], sectors);
part_inc_in_flight(q, part, op_is_write(op)); part_inc_in_flight(q, part, op_is_write(op));
......
...@@ -2864,6 +2864,9 @@ void blk_account_io_start(struct request *rq, bool new_io) ...@@ -2864,6 +2864,9 @@ void blk_account_io_start(struct request *rq, bool new_io)
part_stat_inc(cpu, part, merges[rw]); part_stat_inc(cpu, part, merges[rw]);
} else { } else {
part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq)); part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq));
if (!precise_iostat)
update_io_ticks(cpu, part, jiffies, false);
else
part_round_stats(rq->q, cpu, part); part_round_stats(rq->q, cpu, part);
part_inc_in_flight(rq->q, part, rw); part_inc_in_flight(rq->q, part, rw);
rq->part = part; rq->part = part;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册