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: Split throtl_charge_bio() into bps and iops functions

Split throtl_charge_bio() to facilitate subsequent patches that will
separately charge bps and iops after queue separation.

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-4-wozizhi@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Zizhi Wo and committed by
Jens Axboe
a404be53 3660cd42

+20 -15
+20 -15
block/blk-throttle.c
··· 787 787 return jiffy_wait; 788 788 } 789 789 790 + static void throtl_charge_bps_bio(struct throtl_grp *tg, struct bio *bio) 791 + { 792 + unsigned int bio_size = throtl_bio_data_size(bio); 793 + 794 + /* Charge the bio to the group */ 795 + if (!bio_flagged(bio, BIO_BPS_THROTTLED)) 796 + tg->bytes_disp[bio_data_dir(bio)] += bio_size; 797 + } 798 + 799 + static void throtl_charge_iops_bio(struct throtl_grp *tg, struct bio *bio) 800 + { 801 + tg->io_disp[bio_data_dir(bio)]++; 802 + } 803 + 790 804 /* 791 805 * If previous slice expired, start a new one otherwise renew/extend existing 792 806 * slice to make sure it is at least throtl_slice interval long since now. New ··· 871 857 iops_wait = tg_dispatch_iops_time(tg, bio); 872 858 873 859 return max(bps_wait, iops_wait); 874 - } 875 - 876 - static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio) 877 - { 878 - bool rw = bio_data_dir(bio); 879 - unsigned int bio_size = throtl_bio_data_size(bio); 880 - 881 - /* Charge the bio to the group */ 882 - if (!bio_flagged(bio, BIO_BPS_THROTTLED)) 883 - tg->bytes_disp[rw] += bio_size; 884 - 885 - tg->io_disp[rw]++; 886 860 } 887 861 888 862 /** ··· 959 957 bio = throtl_pop_queued(&sq->queued[rw], &tg_to_put); 960 958 sq->nr_queued[rw]--; 961 959 962 - throtl_charge_bio(tg, bio); 960 + throtl_charge_bps_bio(tg, bio); 961 + throtl_charge_iops_bio(tg, bio); 963 962 964 963 /* 965 964 * If our parent is another tg, we just need to transfer @bio to ··· 1687 1684 while (true) { 1688 1685 if (tg_within_limit(tg, bio, rw)) { 1689 1686 /* within limits, let's charge and dispatch directly */ 1690 - throtl_charge_bio(tg, bio); 1687 + throtl_charge_bps_bio(tg, bio); 1688 + throtl_charge_iops_bio(tg, bio); 1691 1689 1692 1690 /* 1693 1691 * We need to trim slice even when bios are not being ··· 1711 1707 * control algorithm is adaptive, and extra IO bytes 1712 1708 * will be throttled for paying the debt 1713 1709 */ 1714 - throtl_charge_bio(tg, bio); 1710 + throtl_charge_bps_bio(tg, bio); 1711 + throtl_charge_iops_bio(tg, bio); 1715 1712 } else { 1716 1713 /* if above limits, break to queue */ 1717 1714 break;