All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Jens Axboe <jaxboe@fusionio.com>
Cc: Ryan Harper <ryanh@us.ibm.com>,
	linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] blk-throttle: Do not trim slices if there is remainder after division
Date: Mon, 29 Aug 2011 09:09:16 -0400	[thread overview]
Message-ID: <20110829130916.GB3348@redhat.com> (raw)
In-Reply-To: <20110825203225.GD27162@redhat.com>

On Thu, Aug 25, 2011 at 04:32:25PM -0400, Vivek Goyal wrote:
> Throttling code divides a second into smaller slices of 100ms each and
> then decides how many IOPs are allowed in that 100ms. Once IO has been
> dispatched, these slices are reaped off from effective slice.
> 
> Division by a factor of 10, can lead to error if input IOPS rate is
> not a mulitple of 10. As remainder is discarded. So if input rate is
> 69 IOPS, then we effectively get only 60 IOPS.
> 
> Hence do not trim slice at every 100ms period if input rate is not
> a multiple of 10. Instead wait for full second to complete and 
> then trim 10 slices at one go.
> 
> Reported-by: Ryan Harper <ryanh@us.ibm.com>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>

Hi Jens,

Do you have any concerns with this patch. If not, can you please cosider
applying it.

Thanks
Vivek

> ---
>  block/blk-throttle.c |   15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> Index: linux-2.6/block/blk-throttle.c
> ===================================================================
> --- linux-2.6.orig/block/blk-throttle.c	2011-08-25 16:27:55.869757580 -0400
> +++ linux-2.6/block/blk-throttle.c	2011-08-25 16:28:34.866572646 -0400
> @@ -534,7 +534,7 @@ throtl_slice_used(struct throtl_data *td
>  static inline void
>  throtl_trim_slice(struct throtl_data *td, struct throtl_grp *tg, bool rw)
>  {
> -	unsigned long nr_slices, time_elapsed, io_trim;
> +	unsigned long nr_slices, time_elapsed, io_trim, io_remainder;
>  	u64 bytes_trim, tmp;
>  
>  	BUG_ON(time_before(tg->slice_end[rw], tg->slice_start[rw]));
> @@ -569,6 +569,19 @@ throtl_trim_slice(struct throtl_data *td
>  
>  	io_trim = (tg->iops[rw] * throtl_slice * nr_slices)/HZ;
>  
> +	/*
> +	 * Due to division operation of input rate, we can lose some accuracy
> +	 * as raminder is discarded. For example with iops=69, we will dispatch
> +	 * 6 ios but then trim slice after 100ms and never extend slice enough
> +	 * so that over a period of 1 second 69 IOs are dispatched. Instead we
> +	 * dispatch 6 IO at each slice interval and trim the slice. So go
> +	 * ahead with trim operation only when there is no remainder. That
> +	 */
> +	io_remainder = (tg->iops[rw] * throtl_slice * nr_slices)%HZ;
> +
> +	if (io_remainder)
> +		return;
> +
>  	if (!bytes_trim && !io_trim)
>  		return;
>  

      reply	other threads:[~2011-08-29 13:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 20:32 [PATCH] blk-throttle: Do not trim slices if there is remainder after division Vivek Goyal
2011-08-29 13:09 ` Vivek Goyal [this message]

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=20110829130916.GB3348@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=jaxboe@fusionio.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ryanh@us.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.