mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Paolo Valente <paolo.valente@linaro.org>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	jack@suse.cz, andrea.righi@canonical.com,
	glen.valante@linaro.org, arie.vanderhoeven@seagate.com,
	rory.c.chen@seagate.com, Federico Gavioli <f.gavioli97@gmail.com>
Subject: Re: [PATCH V3 6/8] block, bfq: retrieve independent access ranges from request queue
Date: Wed, 5 Oct 2022 07:53:38 +0900	[thread overview]
Message-ID: <5e696c5f-c39f-88a4-5f94-03fdf884bb34@opensource.wdc.com> (raw)
In-Reply-To: <20221004094010.80090-7-paolo.valente@linaro.org>

On 10/4/22 18:40, Paolo Valente wrote:
> From: Federico Gavioli <f.gavioli97@gmail.com>
> 
> This patch implements the code to gather the content of the
> independent_access_ranges structure from the request_queue and copy
> it into the queue's bfq_data. This copy is done at queue initialization.
> 
> We copy the access ranges into the bfq_data to avoid taking the queue
> lock each time we access the ranges.
> 
> This implementation, however, puts a limit to the maximum independent
> ranges supported by the scheduler. Such a limit is equal to the constant
> BFQ_MAX_ACTUATORS. This limit was placed to avoid the allocation of
> dynamic memory.
> 
> Reviewed-by: Damien Le Moal <Damien.LeMoal@wdc.com>

I merely commented on a point you raised. That was not a patch review. So
please do not add my RB tag without me sending it. And my preferred email
address is damien.lemoal@opensource.wdc.com.

Also, please send the whole series to have context for each patch.

> Co-developed-by: Rory Chen <rory.c.chen@seagate.com>
> Signed-off-by: Federico Gavioli <f.gavioli97@gmail.com>
> Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
> Signed-off-by: Rory Chen <rory.c.chen@seagate.com>
> ---
>  block/bfq-cgroup.c  |  2 +-
>  block/bfq-iosched.c | 59 ++++++++++++++++++++++++++++++++++++++-------
>  block/bfq-iosched.h | 12 +++++++++
>  3 files changed, 63 insertions(+), 10 deletions(-)
> 
> diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
> index 3b4a0363d617..080d9160217b 100644
> --- a/block/bfq-cgroup.c
> +++ b/block/bfq-cgroup.c
> @@ -764,7 +764,7 @@ static void *__bfq_bic_change_cgroup(struct bfq_data *bfqd,
>  	struct bfq_entity *entity;
>  	unsigned int act_idx;
>  
> -	for (act_idx = 0; act_idx < BFQ_MAX_ACTUATORS; act_idx++) {
> +	for (act_idx = 0; act_idx < bfqd->num_ia_ranges; act_idx++) {
>  		struct bfq_queue *async_bfqq = bic_to_bfqq(bic, 0, act_idx);
>  		struct bfq_queue *sync_bfqq = bic_to_bfqq(bic, 1, act_idx);
>  
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index d8a15427a96d..9203b4604da8 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -689,7 +689,7 @@ static void bfq_limit_depth(blk_opf_t opf, struct blk_mq_alloc_data *data)
>  		limit = (limit * depth) >> bfqd->full_depth_shift;
>  	}
>  
> -	for (act_idx = 0; act_idx < BFQ_MAX_ACTUATORS; act_idx++) {
> +	for (act_idx = 0; act_idx < bfqd->num_ia_ranges; act_idx++) {
>  		struct bfq_queue *bfqq =
>  			bic ? bic_to_bfqq(bic, op_is_sync(opf), act_idx) : NULL;
>  
> @@ -1829,10 +1829,25 @@ static bool bfq_bfqq_higher_class_or_weight(struct bfq_queue *bfqq,
>  /* get the index of the actuator that will serve bio */
>  static unsigned int bfq_actuator_index(struct bfq_data *bfqd, struct bio *bio)
>  {
> -	/*
> -	 * Multi-actuator support not complete yet, so always return 0
> -	 * for the moment.
> -	 */
> +	struct blk_independent_access_range *iar;
> +	unsigned int i;
> +	sector_t end;
> +
> +	if (bfqd->num_ia_ranges == 1)
> +		return 0;
> +
> +	/* bio_end_sector(bio) gives the sector after the last one */
> +	end = bio_end_sector(bio) - 1;
> +
> +	for (i = 0; i < bfqd->num_ia_ranges; i++) {
> +		iar = &(bfqd->ia_ranges[i]);
> +		if (end >= iar->sector && end < iar->sector + iar->nr_sectors)
> +			return i;
> +	}
> +
> +	WARN_ONCE(true,
> +		  "bfq_actuator_index: bio sector out of ranges: end=%llu\n",
> +		  end);
>  	return 0;
>  }
>  
> @@ -2477,7 +2492,6 @@ static void bfq_remove_request(struct request_queue *q,
>  
>  	if (rq->cmd_flags & REQ_META)
>  		bfqq->meta_pending--;
> -
>  }
>  
>  static bool bfq_bio_merge(struct request_queue *q, struct bio *bio,
> @@ -2673,7 +2687,7 @@ void bfq_end_wr_async_queues(struct bfq_data *bfqd,
>  {
>  	int i, j, k;
>  
> -	for (k = 0; k < BFQ_MAX_ACTUATORS; k++) {
> +	for (k = 0; k < bfqd->num_ia_ranges; k++) {
>  		for (i = 0; i < 2; i++)
>  			for (j = 0; j < IOPRIO_NR_LEVELS; j++)
>  				if (bfqg->async_bfqq[i][j][k])
> @@ -5432,7 +5446,7 @@ static void bfq_exit_icq(struct io_cq *icq)
>  	if (bfqd)
>  		spin_lock_irqsave(&bfqd->lock, flags);
>  
> -	for (act_idx = 0; act_idx < BFQ_MAX_ACTUATORS; act_idx++) {
> +	for (act_idx = 0; act_idx < bfqd->num_ia_ranges; act_idx++) {
>  		if (bic->stable_merge_bfqq[act_idx])
>  			bfq_put_stable_ref(bic->stable_merge_bfqq[act_idx]);
>  
> @@ -7003,7 +7017,7 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg)
>  {
>  	int i, j, k;
>  
> -	for (k = 0; k < BFQ_MAX_ACTUATORS; k++) {
> +	for (k = 0; k < bfqd->num_ia_ranges; k++) {
>  		for (i = 0; i < 2; i++)
>  			for (j = 0; j < IOPRIO_NR_LEVELS; j++)
>  				__bfq_put_async_bfqq(bfqd, &bfqg->async_bfqq[i][j][k]);
> @@ -7120,6 +7134,8 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
>  {
>  	struct bfq_data *bfqd;
>  	struct elevator_queue *eq;
> +	unsigned int i;
> +	struct blk_independent_access_ranges *ia_ranges = q->disk->ia_ranges;
>  
>  	eq = elevator_alloc(q, e);
>  	if (!eq)
> @@ -7162,6 +7178,31 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
>  
>  	bfqd->queue = q;
>  
> +	/*
> +	 * If the disk supports multiple actuators, we copy the independent
> +	 * access ranges from the request queue structure.
> +	 */
> +	spin_lock_irq(&q->queue_lock);
> +	if (ia_ranges) {
> +		/*
> +		 * Check if the disk ia_ranges size exceeds the current bfq
> +		 * actuator limit.
> +		 */
> +		if (ia_ranges->nr_ia_ranges > BFQ_MAX_ACTUATORS) {
> +			pr_crit("nr_ia_ranges higher than act limit: iars=%d, max=%d.\n",
> +					ia_ranges->nr_ia_ranges, BFQ_MAX_ACTUATORS);
> +			pr_crit("Falling back to single actuator mode.\n");
> +			bfqd->num_ia_ranges = 1;

Setting this to one, one would expect bfqd->ia_ranges[0] to contain valid
information. So shouldn't you set it to sector 0 and nr_sector == capacity ?

> +		} else {
> +			bfqd->num_ia_ranges = ia_ranges->nr_ia_ranges;
> +
> +			for (i = 0; i < bfqd->num_ia_ranges; i++)
> +				bfqd->ia_ranges[i] = ia_ranges->ia_range[i];
> +		}
> +	} else
> +		bfqd->num_ia_ranges = 1;

Missing the curly brackets after else.

> +	spin_unlock_irq(&q->queue_lock);
> +
>  	INIT_LIST_HEAD(&bfqd->dispatch);
>  
>  	hrtimer_init(&bfqd->idle_slice_timer, CLOCK_MONOTONIC,
> diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
> index f9ccf468edc2..34f7603bb62f 100644
> --- a/block/bfq-iosched.h
> +++ b/block/bfq-iosched.h
> @@ -796,6 +796,18 @@ struct bfq_data {
>  	 */
>  	unsigned int word_depths[2][2];
>  	unsigned int full_depth_shift;
> +
> +	/*
> +	 * Number of independent access ranges. This is equal to 1 in
> +	 * case of single actuator drives.
> +	 */
> +	unsigned int num_ia_ranges;
> +
> +	/*
> +	 * Disk independent access ranges for each actuator
> +	 * in this device.
> +	 */
> +	struct blk_independent_access_range ia_ranges[BFQ_MAX_ACTUATORS];
>  };
>  
>  enum bfqq_state_flags {

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2022-10-04 22:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-04  9:40 [PATCH V3 0/8] block, bfq: extend bfq to support multi-actuator drives Paolo Valente
2022-10-04  9:40 ` [PATCH V3 1/8] block, bfq: split sync bfq_queues on a per-actuator basis Paolo Valente
2022-10-04 23:04   ` Damien Le Moal
2022-10-11 15:45     ` Paolo VALENTE
2022-10-11 23:42       ` Damien Le Moal
2022-10-04  9:40 ` [PATCH V3 2/8] block, bfq: forbid stable merging of queues associated with different actuators Paolo Valente
2022-10-04  9:40 ` [PATCH V3 3/8] block, bfq: turn scalar fields into arrays in bfq_io_cq Paolo Valente
2022-10-04 23:06   ` Damien Le Moal
2022-10-04  9:40 ` [PATCH V3 4/8] block, bfq: split also async bfq_queues on a per-actuator basis Paolo Valente
2022-10-05 22:52   ` kernel test robot
2022-10-04  9:40 ` [PATCH V3 5/8] block, bfq: turn BFQ_NUM_ACTUATORS into BFQ_MAX_ACTUATORS Paolo Valente
2022-10-04  9:40 ` [PATCH V3 6/8] block, bfq: retrieve independent access ranges from request queue Paolo Valente
2022-10-04 22:53   ` Damien Le Moal [this message]
2022-10-04  9:40 ` [PATCH V3 7/8] block, bfq: inject I/O to underutilized actuators Paolo Valente
2022-10-04 13:27   ` kernel test robot
2022-10-04 18:48   ` kernel test robot
2022-10-04  9:40 ` [PATCH V3 8/8] block, bfq: balance I/O injection among " Paolo Valente

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=5e696c5f-c39f-88a4-5f94-03fdf884bb34@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=andrea.righi@canonical.com \
    --cc=arie.vanderhoeven@seagate.com \
    --cc=axboe@kernel.dk \
    --cc=f.gavioli97@gmail.com \
    --cc=glen.valante@linaro.org \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paolo.valente@linaro.org \
    --cc=rory.c.chen@seagate.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

all inboxes | Powered by JetHome®