From: Vivek Goyal <vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Hong Zhiguo <honkiko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Hong Zhiguo <zhiguohong-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
Subject: Re: [PATCH v2] blk-throttle: simplify logic by token bucket algorithm
Date: Tue, 15 Oct 2013 13:32:52 -0400 [thread overview]
Message-ID: <20131015173252.GM31215@redhat.com> (raw)
In-Reply-To: <1381741757-20888-1-git-send-email-zhiguohong-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
On Mon, Oct 14, 2013 at 05:09:17PM +0800, Hong Zhiguo wrote:
[..]
Hi Hong,
Thanks for the token based throttling implementation. In general it looks
good and it simplies the logic. Couple of comments/concerns below.
> @@ -133,14 +135,13 @@ struct throtl_grp {
> /* IOPS limits */
> unsigned int iops[2];
>
> - /* Number of bytes disptached in current slice */
> - uint64_t bytes_disp[2];
> - /* Number of bio's dispatched in current slice */
> - unsigned int io_disp[2];
> + /* Token for throttling by bps */
> + uint64_t bytes_token[2];
> + /* Token for throttling by iops */
> + unsigned int io_token[2];
>
> - /* When did we start a new slice */
> - unsigned long slice_start[2];
> - unsigned long slice_end[2];
> + /* Time check-point */
> + unsigned long t_c[2];
Can we rename this variable to say last_dispatch[2].
[..]
>
> @@ -852,41 +708,26 @@ static bool tg_with_in_bps_limit(struct throtl_grp *tg, struct bio *bio,
> unsigned long *wait)
> {
> bool rw = bio_data_dir(bio);
> - u64 bytes_allowed, extra_bytes, tmp;
> - unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;
> -
> - jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw];
> -
> - /* Slice has just started. Consider one slice interval */
> - if (!jiffy_elapsed)
> - jiffy_elapsed_rnd = throtl_slice;
> -
> - jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, throtl_slice);
> + u64 extra_bytes, token;
> + unsigned long jiffy_wait;
>
> - tmp = tg->bps[rw] * jiffy_elapsed_rnd;
> - do_div(tmp, HZ);
> - bytes_allowed = tmp;
> + token = (u64)tg->bps[rw] * (jiffies - tg->t_c[rw]);
So here we seem to be calculating how many tokens a group is eligible
for. This is done based on since last time check. And last time check
was updated in last dispatch from the group.
What happens if no IO happens in a group for some time, say for 5 minutes,
and then one big IO comes in. IIUC, we will allow a big burst of IO for
the first IO (tokens worth of full 5 minutes will be given to this group).
I think we should have a mechanism where we don't allow too big a burst
for the first IO. (Possibly limit the burst to THROTL_BURST_IO and
THROTL_BURST_BYTES until and unless a bigger IO is already queued and
we are waiting for it).
In previous time slice logic, I took care of it by extend time slice
by 100ms and if no IO happens in the group for 100ms, time slice will
expire and next IO will get at max of 100ms of worth of credit (equivalent
of burst limits).
Thanks
Vivek
next prev parent reply other threads:[~2013-10-15 17:32 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-12 10:46 [PATCH] blk-throttle: simplify logic by token bucket algorithm Hong Zhiguo
[not found] ` <1381574794-7639-1-git-send-email-zhiguohong-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
2013-10-13 12:59 ` Hong zhi guo
2013-10-14 9:09 ` [PATCH v2] " Hong Zhiguo
[not found] ` <1381741757-20888-1-git-send-email-zhiguohong-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
2013-10-14 13:36 ` Tejun Heo
2013-10-14 13:47 ` Hong zhi guo
[not found] ` <20131014133620.GF4722-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-10-14 13:53 ` Hong zhi guo
[not found] ` <CAA7+ByWPM2Pizm+dP1AxPM7Ut-w=AtRfD2GkCK-0OVh+C2Twkg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-14 13:59 ` Tejun Heo
[not found] ` <20131014135929.GH4722-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-10-15 12:35 ` Hong zhi guo
2013-10-15 16:19 ` Jens Axboe
2013-10-15 13:03 ` Vivek Goyal
2013-10-15 17:32 ` Vivek Goyal [this message]
2013-10-16 6:09 ` Hong zhi guo
2013-10-16 14:14 ` Vivek Goyal
2013-10-16 15:47 ` Hong zhi guo
2013-10-16 15:53 ` Tejun Heo
[not found] ` <20131016155344.GA10012-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-10-16 16:22 ` Vivek Goyal
2013-10-16 16:22 ` Hong zhi guo
2013-10-17 12:17 ` [PATCH v3] " Hong Zhiguo
[not found] ` <1382012272-26170-1-git-send-email-zhiguohong-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
2013-10-18 15:55 ` Vivek Goyal
[not found] ` <20131018155532.GD2277-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-10-20 12:08 ` Hong zhi guo
2013-10-20 12:11 ` [PATCH v4 0/2] " Hong Zhiguo
2013-10-20 12:11 ` [PATCH v4 1/2] " Hong Zhiguo
2014-04-10 10:07 ` Hong zhi guo
[not found] ` <CAA7+ByVJWjfs5HiMsnuum75egghrNQHt2KNNPTWeVa0-FWccaQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-10 13:32 ` Vivek Goyal
2013-10-20 12:11 ` [PATCH v4 2/2] blk-throttle: trim tokens generated for an idle tree Hong Zhiguo
[not found] ` <1382271072-15664-3-git-send-email-zhiguohong-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
2013-10-22 21:02 ` Vivek Goyal
[not found] ` <20131022210232.GB2884-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-10-23 3:30 ` Hong zhi guo
2013-10-28 5:08 ` Hong zhi guo
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=20131015173252.GM31215@redhat.com \
--to=vgoyal-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=honkiko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=zhiguohong-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).