LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
To: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
Paolo Valente <paolo.valente@linaro.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] block, bfq: keep peak_rate estimation within range 1..2^32-1
Date: Mon, 05 Mar 2018 15:48:53 +0300 [thread overview]
Message-ID: <152025413365.161046.7757556276366364549.stgit@buzz> (raw)
Rate should never overflow or become zero because it is used as divider.
This patch accumulates it with saturation.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
block/bfq-iosched.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index aeca22d91101..a236c8d541b5 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -2546,7 +2546,8 @@ static void bfq_reset_rate_computation(struct bfq_data *bfqd,
static void bfq_update_rate_reset(struct bfq_data *bfqd, struct request *rq)
{
- u32 rate, weight, divisor;
+ u32 weight, divisor;
+ u64 rate;
/*
* For the convergence property to hold (see comments on
@@ -2634,9 +2635,10 @@ static void bfq_update_rate_reset(struct bfq_data *bfqd, struct request *rq)
*/
bfqd->peak_rate *= divisor-1;
bfqd->peak_rate /= divisor;
- rate /= divisor; /* smoothing constant alpha = 1/divisor */
+ do_div(rate, divisor); /* smoothing constant alpha = 1/divisor */
- bfqd->peak_rate += rate;
+ /* rate should never overlow or become zero */
+ bfqd->peak_rate = clamp_t(u64, rate + bfqd->peak_rate, 1, U32_MAX);
update_thr_responsiveness_params(bfqd);
reset_computation:
next reply other threads:[~2018-03-05 12:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-05 12:48 Konstantin Khlebnikov [this message]
2018-03-19 6:03 ` Paolo Valente
2018-03-19 6:28 ` Konstantin Khlebnikov
2018-03-20 3:00 ` Paolo Valente
2018-03-20 7:41 ` Konstantin Khlebnikov
2018-03-20 23:49 ` Paolo Valente
2018-03-26 8:01 ` Paolo Valente
2018-03-26 10:28 ` Konstantin Khlebnikov
2018-03-26 14:06 ` Paolo Valente
2018-03-26 14:18 ` Konstantin Khlebnikov
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=152025413365.161046.7757556276366364549.stgit@buzz \
--to=khlebnikov@yandex-team.ru \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paolo.valente@linaro.org \
--subject='Re: [PATCH] block, bfq: keep peak_rate estimation within range 1..2^32-1' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).