linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, osandov@fb.com, efault@gmx.de,
	paolo.valente@linaro.org
Subject: Re: [PATCH 3/9] bfq: calculate shallow depths at init time
Date: Thu, 10 May 2018 10:00:11 -0700	[thread overview]
Message-ID: <20180510170011.GC30485@vader> (raw)
In-Reply-To: <1525969467-12476-4-git-send-email-axboe@kernel.dk>

On Thu, May 10, 2018 at 10:24:21AM -0600, Jens Axboe wrote:
> It doesn't change, so don't put it in the per-IO hot path.
> 
> Acked-by: Paolo Valente <paolo.valente@linaro.org>

Reviewed-by: Omar Sandoval <osandov@fb.com>

> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
>  block/bfq-iosched.c | 97 +++++++++++++++++++++++++++--------------------------
>  1 file changed, 50 insertions(+), 47 deletions(-)
> 
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index db38e88a5670..0cd8aa80c32d 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -487,46 +487,6 @@ static struct request *bfq_choose_req(struct bfq_data *bfqd,
>  }
>  
>  /*
> - * See the comments on bfq_limit_depth for the purpose of
> - * the depths set in the function.
> - */
> -static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)
> -{
> -	bfqd->sb_shift = bt->sb.shift;
> -
> -	/*
> -	 * In-word depths if no bfq_queue is being weight-raised:
> -	 * leaving 25% of tags only for sync reads.
> -	 *
> -	 * In next formulas, right-shift the value
> -	 * (1U<<bfqd->sb_shift), instead of computing directly
> -	 * (1U<<(bfqd->sb_shift - something)), to be robust against
> -	 * any possible value of bfqd->sb_shift, without having to
> -	 * limit 'something'.
> -	 */
> -	/* no more than 50% of tags for async I/O */
> -	bfqd->word_depths[0][0] = max((1U<<bfqd->sb_shift)>>1, 1U);
> -	/*
> -	 * no more than 75% of tags for sync writes (25% extra tags
> -	 * w.r.t. async I/O, to prevent async I/O from starving sync
> -	 * writes)
> -	 */
> -	bfqd->word_depths[0][1] = max(((1U<<bfqd->sb_shift) * 3)>>2, 1U);
> -
> -	/*
> -	 * In-word depths in case some bfq_queue is being weight-
> -	 * raised: leaving ~63% of tags for sync reads. This is the
> -	 * highest percentage for which, in our tests, application
> -	 * start-up times didn't suffer from any regression due to tag
> -	 * shortage.
> -	 */
> -	/* no more than ~18% of tags for async I/O */
> -	bfqd->word_depths[1][0] = max(((1U<<bfqd->sb_shift) * 3)>>4, 1U);
> -	/* no more than ~37% of tags for sync writes (~20% extra tags) */
> -	bfqd->word_depths[1][1] = max(((1U<<bfqd->sb_shift) * 6)>>4, 1U);
> -}
> -
> -/*
>   * Async I/O can easily starve sync I/O (both sync reads and sync
>   * writes), by consuming all tags. Similarly, storms of sync writes,
>   * such as those that sync(2) may trigger, can starve sync reads.
> @@ -535,18 +495,11 @@ static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)
>   */
>  static void bfq_limit_depth(unsigned int op, struct blk_mq_alloc_data *data)
>  {
> -	struct blk_mq_tags *tags = blk_mq_tags_from_data(data);
>  	struct bfq_data *bfqd = data->q->elevator->elevator_data;
> -	struct sbitmap_queue *bt;
>  
>  	if (op_is_sync(op) && !op_is_write(op))
>  		return;
>  
> -	bt = &tags->bitmap_tags;
> -
> -	if (unlikely(bfqd->sb_shift != bt->sb.shift))
> -		bfq_update_depths(bfqd, bt);
> -
>  	data->shallow_depth =
>  		bfqd->word_depths[!!bfqd->wr_busy_queues][op_is_sync(op)];
>  
> @@ -5126,6 +5079,55 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg)
>  	__bfq_put_async_bfqq(bfqd, &bfqg->async_idle_bfqq);
>  }
>  
> +/*
> + * See the comments on bfq_limit_depth for the purpose of
> + * the depths set in the function.
> + */
> +static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt)
> +{
> +	bfqd->sb_shift = bt->sb.shift;
> +
> +	/*
> +	 * In-word depths if no bfq_queue is being weight-raised:
> +	 * leaving 25% of tags only for sync reads.
> +	 *
> +	 * In next formulas, right-shift the value
> +	 * (1U<<bfqd->sb_shift), instead of computing directly
> +	 * (1U<<(bfqd->sb_shift - something)), to be robust against
> +	 * any possible value of bfqd->sb_shift, without having to
> +	 * limit 'something'.
> +	 */
> +	/* no more than 50% of tags for async I/O */
> +	bfqd->word_depths[0][0] = max((1U<<bfqd->sb_shift)>>1, 1U);
> +	/*
> +	 * no more than 75% of tags for sync writes (25% extra tags
> +	 * w.r.t. async I/O, to prevent async I/O from starving sync
> +	 * writes)
> +	 */
> +	bfqd->word_depths[0][1] = max(((1U<<bfqd->sb_shift) * 3)>>2, 1U);
> +
> +	/*
> +	 * In-word depths in case some bfq_queue is being weight-
> +	 * raised: leaving ~63% of tags for sync reads. This is the
> +	 * highest percentage for which, in our tests, application
> +	 * start-up times didn't suffer from any regression due to tag
> +	 * shortage.
> +	 */
> +	/* no more than ~18% of tags for async I/O */
> +	bfqd->word_depths[1][0] = max(((1U<<bfqd->sb_shift) * 3)>>4, 1U);
> +	/* no more than ~37% of tags for sync writes (~20% extra tags) */
> +	bfqd->word_depths[1][1] = max(((1U<<bfqd->sb_shift) * 6)>>4, 1U);
> +}
> +
> +static int bfq_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int index)
> +{
> +	struct bfq_data *bfqd = hctx->queue->elevator->elevator_data;
> +	struct blk_mq_tags *tags = hctx->sched_tags;
> +
> +	bfq_update_depths(bfqd, &tags->bitmap_tags);
> +	return 0;
> +}
> +
>  static void bfq_exit_queue(struct elevator_queue *e)
>  {
>  	struct bfq_data *bfqd = e->elevator_data;
> @@ -5547,6 +5549,7 @@ static struct elevator_type iosched_bfq_mq = {
>  		.requests_merged	= bfq_requests_merged,
>  		.request_merged		= bfq_request_merged,
>  		.has_work		= bfq_has_work,
> +		.init_hctx		= bfq_init_hctx,
>  		.init_sched		= bfq_init_queue,
>  		.exit_sched		= bfq_exit_queue,
>  	},
> -- 
> 2.7.4
> 

  reply	other threads:[~2018-05-10 17:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10 16:24 [PATCHSET v3 0/9] blk-mq-sched and sbitmap shallow depth Jens Axboe
2018-05-10 16:24 ` [PATCH 1/9] blk-mq: don't call into depth limiting for reserved tags Jens Axboe
2018-05-10 16:59   ` Omar Sandoval
2018-05-10 16:24 ` [PATCH 2/9] bfq-iosched: don't worry about reserved tags in limit_depth Jens Axboe
2018-05-10 16:59   ` Omar Sandoval
2018-05-10 16:24 ` [PATCH 3/9] bfq: calculate shallow depths at init time Jens Axboe
2018-05-10 17:00   ` Omar Sandoval [this message]
2018-05-10 16:24 ` [PATCH 4/9] bfq-iosched: remove unused variable Jens Axboe
2018-05-10 17:00   ` Omar Sandoval
2018-05-10 16:24 ` [PATCH 5/9] sbitmap: fix missed wakeups caused by sbitmap_queue_get_shallow() Jens Axboe
2018-05-10 17:01   ` Omar Sandoval
2018-05-10 17:09     ` Jens Axboe
2018-05-10 16:24 ` [PATCH 6/9] sbitmap: warn if using smaller shallow depth than was setup Jens Axboe
2018-05-10 17:02   ` Omar Sandoval
2018-05-10 17:09     ` Jens Axboe
2018-05-10 16:24 ` [PATCH 7/9] bfq-iosched: update shallow depth to smallest one used Jens Axboe
2018-05-10 17:03   ` Omar Sandoval
2018-05-10 16:24 ` [PATCH 8/9] kyber-iosched: update shallow depth when setting up hardware queue Jens Axboe
2018-05-10 17:03   ` Omar Sandoval
2018-05-10 16:24 ` [PATCH 9/9] sbitmap: fix race in wait batch accounting Jens Axboe

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=20180510170011.GC30485@vader \
    --to=osandov@osandov.com \
    --cc=axboe@kernel.dk \
    --cc=efault@gmx.de \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    --cc=paolo.valente@linaro.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).