Re: [PATCHv3 1/2] block: move elevator queue allocation logic into blk_mq_init_sched

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 16, 2025 at 11:02:25PM +0530, Nilay Shroff wrote:
> In preparation for allocating sched_tags before freezing the request
> queue and acquiring ->elevator_lock, move the elevator queue allocation
> logic from the elevator ops ->init_sched callback into blk_mq_init_sched.
> 
> This refactoring provides a centralized location for elevator queue
> initialization, which makes it easier to store pre-allocated sched_tags
> in the struct elevator_queue during later changes.
> 
> Signed-off-by: Nilay Shroff <nilay@xxxxxxxxxxxxx>
> ---
>  block/bfq-iosched.c   | 13 +++----------
>  block/blk-mq-sched.c  |  7 ++++++-
>  block/elevator.h      |  2 +-
>  block/kyber-iosched.c | 11 ++---------
>  block/mq-deadline.c   | 14 ++------------
>  5 files changed, 14 insertions(+), 33 deletions(-)
> 
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index 0cb1e9873aab..fd26dc1901b0 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -7232,22 +7232,16 @@ static void bfq_init_root_group(struct bfq_group *root_group,
>  	root_group->sched_data.bfq_class_idle_last_service = jiffies;
>  }
>  
> -static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
> +static int bfq_init_queue(struct request_queue *q, struct elevator_queue *eq)
>  {
>  	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)
> -		return -ENOMEM;
> -
>  	bfqd = kzalloc_node(sizeof(*bfqd), GFP_KERNEL, q->node);
> -	if (!bfqd) {
> -		kobject_put(&eq->kobj);
> +	if (!bfqd)
>  		return -ENOMEM;
> -	}
> +
>  	eq->elevator_data = bfqd;
>  
>  	spin_lock_irq(&q->queue_lock);
> @@ -7405,7 +7399,6 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
>  
>  out_free:
>  	kfree(bfqd);
> -	kobject_put(&eq->kobj);
>  	return -ENOMEM;
>  }
>  
> diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
> index 55a0fd105147..d914eb9d61a6 100644
> --- a/block/blk-mq-sched.c
> +++ b/block/blk-mq-sched.c
> @@ -475,6 +475,10 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
>  	q->nr_requests = 2 * min_t(unsigned int, q->tag_set->queue_depth,
>  				   BLKDEV_DEFAULT_RQ);
>  
> +	eq = elevator_alloc(q, e);
> +	if (!eq)
> +		return -ENOMEM;
> +
>  	if (blk_mq_is_shared_tags(flags)) {
>  		ret = blk_mq_init_sched_shared_tags(q);
>  		if (ret)

The above failure needs to be handled by kobject_put(&eq->kobj).

Otherwise, feel free to add:

Reviewed-by: Ming Lei <ming.lei@xxxxxxxxxx>


Thanks,
Ming





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux