Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

blk-throttle: Introduce flag "BIO_TG_BPS_THROTTLED"

Subsequent patches will split the single queue into separate bps and iops
queues. To prevent IO that has already passed through the bps queue at a
single tg level from being counted toward bps wait time again, we introduce
"BIO_TG_BPS_THROTTLED" flag. Since throttle and QoS operate at different
levels, we reuse the value as "BIO_QOS_THROTTLED".

We set this flag when charge bps and clear it when charge iops, as the bio
will move to the upper-level tg or be dispatched.

This patch does not involve functional changes.

Signed-off-by: Zizhi Wo <wozizhi@huawei.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Zizhi Wo <wozizhi@huaweicloud.com>
Link: https://lore.kernel.org/r/20250506020935.655574-5-wozizhi@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Zizhi Wo and committed by
Jens Axboe
c4da7bf5 a404be53

+15 -2
+7 -2
block/blk-throttle.c
··· 792 792 unsigned int bio_size = throtl_bio_data_size(bio); 793 793 794 794 /* Charge the bio to the group */ 795 - if (!bio_flagged(bio, BIO_BPS_THROTTLED)) 795 + if (!bio_flagged(bio, BIO_BPS_THROTTLED) && 796 + !bio_flagged(bio, BIO_TG_BPS_THROTTLED)) { 797 + bio_set_flag(bio, BIO_TG_BPS_THROTTLED); 796 798 tg->bytes_disp[bio_data_dir(bio)] += bio_size; 799 + } 797 800 } 798 801 799 802 static void throtl_charge_iops_bio(struct throtl_grp *tg, struct bio *bio) 800 803 { 804 + bio_clear_flag(bio, BIO_TG_BPS_THROTTLED); 801 805 tg->io_disp[bio_data_dir(bio)]++; 802 806 } 803 807 ··· 827 823 828 824 /* no need to throttle if this bio's bytes have been accounted */ 829 825 if (bps_limit == U64_MAX || tg->flags & THROTL_TG_CANCELING || 830 - bio_flagged(bio, BIO_BPS_THROTTLED)) 826 + bio_flagged(bio, BIO_BPS_THROTTLED) || 827 + bio_flagged(bio, BIO_TG_BPS_THROTTLED)) 831 828 return 0; 832 829 833 830 tg_update_slice(tg, rw);
+8
include/linux/blk_types.h
··· 296 296 * of this bio. */ 297 297 BIO_CGROUP_ACCT, /* has been accounted to a cgroup */ 298 298 BIO_QOS_THROTTLED, /* bio went through rq_qos throttle path */ 299 + /* 300 + * This bio has completed bps throttling at the single tg granularity, 301 + * which is different from BIO_BPS_THROTTLED. When the bio is enqueued 302 + * into the sq->queued of the upper tg, or is about to be dispatched, 303 + * this flag needs to be cleared. Since blk-throttle and rq_qos are not 304 + * on the same hierarchical level, reuse the value. 305 + */ 306 + BIO_TG_BPS_THROTTLED = BIO_QOS_THROTTLED, 299 307 BIO_QOS_MERGED, /* but went through rq_qos merge path */ 300 308 BIO_REMAPPED, 301 309 BIO_ZONE_WRITE_PLUGGING, /* bio handled through zone write plugging */