Re: [PATCH for-6.8/block RFC v2] block: support to account io_ticks precisely

From: Ming Lei
Date: Thu Jan 04 2024 - 21:50:00 EST


On Wed, Jan 03, 2024 at 03:15:15PM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@xxxxxxxxxx>
>
> Currently, io_ticks is accounted based on sampling, specifically
> update_io_ticks() will always account io_ticks by 1 jiffies from
> bdev_start_io_acct()/blk_account_io_start(), and the result can be
> inaccurate, for example(HZ is 250):
>
> Test script:
> fio -filename=/dev/sda -bs=4k -rw=write -direct=1 -name=test -thinktime=4ms
>
> Test result: util is about 90%, while the disk is really idle.
>
> In order to account io_ticks precisely, update_io_ticks() must know if
> there are IO inflight already, and this requires overhead slightly,
> hence precise io accounting is disabled by default, and user can enable
> it through sysfs entry.
>
> Noted that for rq-based devcie, part_stat_local_inc/dec() and
> part_in_flight() is used to track inflight instead of iterating tags,
> which is not supposed to be used in fast path because 'tags->lock' is
> grabbed in blk_mq_find_and_get_req().
>
> Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
> ---
> Changes in v2:
> - remove the new parameter for update_io_ticks();
> - simplify update_io_ticks();
> - use swith in queue_iostats_store();
> - add missing part_stat_local_dec() in blk_account_io_merge_request()

Looks fine,

Reviewed-by: Ming Lei <ming.lei@xxxxxxxxxx>


thanks,
Ming