From: Tejun Heo <tj@kernel.org>
To: Yu Kuai <yukuai1@huaweicloud.com>
Cc: mkoutny@suse.com, axboe@kernel.dk, ming.lei@redhat.com,
cgroups@vger.kernel.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, yukuai3@huawei.com,
yi.zhang@huawei.com
Subject: Re: [PATCH RESEND v6 1/8] blk-throttle: fix that io throttle can only work for single bio
Date: Wed, 27 Jul 2022 08:27:24 -1000 [thread overview]
Message-ID: <YuGDjFkxDSsVrcRw@slm.duckdns.org> (raw)
In-Reply-To: <20220701093441.885741-2-yukuai1@huaweicloud.com>
Sorry about the long delay.
So, the code looks nice but I have a difficult time following the logic.
On Fri, Jul 01, 2022 at 05:34:34PM +0800, Yu Kuai wrote:
> @@ -811,7 +811,7 @@ static bool tg_with_in_bps_limit(struct throtl_grp *tg, struct bio *bio,
> unsigned int bio_size = throtl_bio_data_size(bio);
>
> /* no need to throttle if this bio's bytes have been accounted */
> - if (bps_limit == U64_MAX || bio_flagged(bio, BIO_THROTTLED)) {
> + if (bps_limit == U64_MAX) {
> if (wait)
> *wait = 0;
> return true;
> @@ -921,11 +921,8 @@ static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio)
> unsigned int bio_size = throtl_bio_data_size(bio);
>
> /* Charge the bio to the group */
> - if (!bio_flagged(bio, BIO_THROTTLED)) {
> - tg->bytes_disp[rw] += bio_size;
> - tg->last_bytes_disp[rw] += bio_size;
> - }
> -
> + tg->bytes_disp[rw] += bio_size;
> + tg->last_bytes_disp[rw] += bio_size;
> tg->io_disp[rw]++;
> tg->last_io_disp[rw]++;
So, we're charging and controlling whether it has already been throttled or
not.
> @@ -2121,6 +2118,21 @@ bool __blk_throtl_bio(struct bio *bio)
> tg->last_low_overflow_time[rw] = jiffies;
> throtl_downgrade_check(tg);
> throtl_upgrade_check(tg);
> +
> + /*
> + * re-entered bio has accounted bytes already, so try to
> + * compensate previous over-accounting. However, if new
> + * slice is started, just forget it.
> + */
> + if (bio_flagged(bio, BIO_THROTTLED)) {
> + unsigned int bio_size = throtl_bio_data_size(bio);
> +
> + if (tg->bytes_disp[rw] >= bio_size)
> + tg->bytes_disp[rw] -= bio_size;
> + if (tg->last_bytes_disp[rw] >= bio_size)
> + tg->last_bytes_disp[rw] -= bio_size;
> + }
and trying to restore the overaccounting. However, it's not clear why this
helps with the problem you're describing. The comment should be clearly
spelling out why it's done this way and how this works.
Also, blk_throttl_bio() doesn't call into __blk_throtl_bio() at all if
THROTTLED is set and HAS_IOPS_LIMIT is not, so if there are only bw limits,
we end up accounting these IOs twice?
Thanks.
--
tejun
next prev parent reply other threads:[~2022-07-27 19:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 9:34 [PATCH RESEND v6 0/8] bugfix and cleanup for blk-throttle Yu Kuai
2022-07-01 9:34 ` [PATCH RESEND v6 1/8] blk-throttle: fix that io throttle can only work for single bio Yu Kuai
2022-07-27 18:27 ` Tejun Heo [this message]
2022-07-29 6:32 ` Yu Kuai
2022-07-29 18:04 ` Tejun Heo
2022-07-30 1:06 ` Yu Kuai
2022-07-01 9:34 ` [PATCH RESEND v6 2/8] blk-throttle: prevent overflow while calculating wait time Yu Kuai
2022-07-27 18:28 ` Tejun Heo
2022-07-28 10:23 ` Yu Kuai
2022-07-01 9:34 ` [PATCH RESEND v6 3/8] blk-throttle: factor out code to calculate ios/bytes_allowed Yu Kuai
2022-07-01 9:34 ` [PATCH RESEND v6 4/8] blk-throttle: fix io hung due to config updates Yu Kuai
2022-07-27 18:39 ` Tejun Heo
2022-07-28 9:33 ` Michal Koutný
2022-07-28 10:34 ` Yu Kuai
2022-07-28 16:55 ` Tejun Heo
2022-07-01 9:34 ` [PATCH RESEND v6 5/8] blk-throttle: use 'READ/WRITE' instead of '0/1' Yu Kuai
2022-07-27 18:39 ` Tejun Heo
2022-07-01 9:34 ` [PATCH RESEND v6 6/8] blk-throttle: calling throtl_dequeue/enqueue_tg in pairs Yu Kuai
2022-07-27 18:40 ` Tejun Heo
2022-07-01 9:34 ` [PATCH RESEND v6 7/8] blk-throttle: cleanup tg_update_disptime() Yu Kuai
2022-07-27 18:42 ` Tejun Heo
2022-07-01 9:34 ` [PATCH RESEND v6 8/8] blk-throttle: clean up flag 'THROTL_TG_PENDING' Yu Kuai
2022-07-27 18:44 ` Tejun Heo
2022-07-28 11:03 ` Yu Kuai
2022-07-10 2:39 ` [PATCH RESEND v6 0/8] bugfix and cleanup for blk-throttle Yu Kuai
2022-07-10 2:40 ` Yu Kuai
2022-07-20 11:45 ` Yu Kuai
2022-07-27 12:12 ` Yu Kuai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YuGDjFkxDSsVrcRw@slm.duckdns.org \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=mkoutny@suse.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox