From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Damien Le Moal <dlemoal@kernel.org>,
Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
virtualization@lists.linux.dev
Subject: Re: [PATCH 08/15] block: pass a queue_limits argument to blk_alloc_queue
Date: Mon, 12 Feb 2024 08:32:53 +0100 [thread overview]
Message-ID: <eded0bd7-ef9e-4cd3-96fb-cd7d312b677e@suse.de> (raw)
In-Reply-To: <20240212064609.1327143-9-hch@lst.de>
On 2/12/24 14:46, Christoph Hellwig wrote:
> Pass a queue_limits to blk_alloc_queue and apply it after validating and
> capping the values using blk_validate_limits. This will allow allocating
> queues with valid queue limits instead of setting the values one at a
> time later.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-core.c | 26 ++++++++++++++++++--------
> block/blk-mq.c | 7 ++++---
> block/genhd.c | 5 +++--
> 3 files changed, 25 insertions(+), 13 deletions(-)
>
> diff --git a/block/blk-core.c b/block/blk-core.c
> index cb56724a8dfb25..a16b5abdbbf56f 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -394,24 +394,34 @@ static void blk_timeout_work(struct work_struct *work)
> {
> }
>
> -struct request_queue *blk_alloc_queue(int node_id)
> +struct request_queue *blk_alloc_queue(struct queue_limits *lim, int node_id)
> {
> struct request_queue *q;
> + int error;
>
> q = kmem_cache_alloc_node(blk_requestq_cachep, GFP_KERNEL | __GFP_ZERO,
> node_id);
> if (!q)
> - return NULL;
> + return ERR_PTR(-ENOMEM);
>
> q->last_merge = NULL;
>
> q->id = ida_alloc(&blk_queue_ida, GFP_KERNEL);
> - if (q->id < 0)
> + if (q->id < 0) {
> + error = q->id;
> goto fail_q;
> + }
>
> q->stats = blk_alloc_queue_stats();
> - if (!q->stats)
> + if (!q->stats) {
> + error = -ENOMEM;
> goto fail_id;
> + }
> +
> + error = blk_set_default_limits(lim);
> + if (error)
> + goto fail_stats;
> + q->limits = *lim;
>
> q->node = node_id;
>
> @@ -436,12 +446,12 @@ struct request_queue *blk_alloc_queue(int node_id)
> * Init percpu_ref in atomic mode so that it's faster to shutdown.
> * See blk_register_queue() for details.
> */
> - if (percpu_ref_init(&q->q_usage_counter,
> + error = percpu_ref_init(&q->q_usage_counter,
> blk_queue_usage_counter_release,
> - PERCPU_REF_INIT_ATOMIC, GFP_KERNEL))
> + PERCPU_REF_INIT_ATOMIC, GFP_KERNEL);
> + if (error)
> goto fail_stats;
>
> - blk_set_default_limits(&q->limits);
> q->nr_requests = BLKDEV_DEFAULT_RQ;
>
> return q;
> @@ -452,7 +462,7 @@ struct request_queue *blk_alloc_queue(int node_id)
> ida_free(&blk_queue_ida, q->id);
> fail_q:
> kmem_cache_free(blk_requestq_cachep, q);
> - return NULL;
> + return ERR_PTR(error);
> }
>
> /**
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 6d2f7b5caa01d8..9dd8055cc5246d 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -4086,12 +4086,13 @@ void blk_mq_release(struct request_queue *q)
> static struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set,
> void *queuedata)
> {
> + struct queue_limits lim = { };
> struct request_queue *q;
> int ret;
>
> - q = blk_alloc_queue(set->numa_node);
> - if (!q)
> - return ERR_PTR(-ENOMEM);
> + q = blk_alloc_queue(&lim, set->numa_node);
> + if (IS_ERR(q))
> + return q;
> q->queuedata = queuedata;
> ret = blk_mq_init_allocated_queue(set, q);
> if (ret) {
> diff --git a/block/genhd.c b/block/genhd.c
> index d74fb5b4ae6818..7a8fd57c51f73c 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1393,11 +1393,12 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
>
> struct gendisk *__blk_alloc_disk(int node, struct lock_class_key *lkclass)
> {
> + struct queue_limits lim = { };
> struct request_queue *q;
> struct gendisk *disk;
>
> - q = blk_alloc_queue(node);
> - if (!q)
> + q = blk_alloc_queue(&lim, node);
> + if (IS_ERR(q))
> return NULL;
>
> disk = __alloc_disk_node(q, node, lkclass);
Ah, here it is.
Please move the declaration from patch #4 to this one.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Ivo Totev, Andrew McDonald,
Werner Knoblich
next prev parent reply other threads:[~2024-02-12 7:33 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 6:45 atomic queue limits updates v4 Christoph Hellwig
2024-02-12 6:45 ` [PATCH 01/15] block: move max_{open,active}_zones to struct queue_limits Christoph Hellwig
2024-02-12 6:45 ` [PATCH 02/15] block: refactor disk_update_readahead Christoph Hellwig
2024-02-12 6:45 ` [PATCH 03/15] block: decouple blk_set_stacking_limits from blk_set_default_limits Christoph Hellwig
2024-02-12 7:14 ` Damien Le Moal
2024-02-12 7:28 ` Christoph Hellwig
2024-02-12 7:25 ` Hannes Reinecke
2024-02-12 6:45 ` [PATCH 04/15] block: add an API to atomically update queue limits Christoph Hellwig
2024-02-12 7:24 ` Damien Le Moal
2024-02-12 7:29 ` Christoph Hellwig
2024-02-12 7:31 ` Hannes Reinecke
2024-02-12 6:45 ` [PATCH 05/15] block: use queue_limits_commit_update in queue_max_sectors_store Christoph Hellwig
2024-02-12 6:46 ` [PATCH 06/15] block: add a max_user_discard_sectors queue limit Christoph Hellwig
2024-02-12 6:46 ` [PATCH 07/15] block: use queue_limits_commit_update in queue_discard_max_store Christoph Hellwig
2024-02-12 6:46 ` [PATCH 08/15] block: pass a queue_limits argument to blk_alloc_queue Christoph Hellwig
2024-02-12 7:26 ` Damien Le Moal
2024-02-12 7:32 ` Hannes Reinecke [this message]
2024-02-12 6:46 ` [PATCH 09/15] block: pass a queue_limits argument to blk_mq_init_queue Christoph Hellwig
2024-02-12 6:46 ` [PATCH 10/15] block: pass a queue_limits argument to blk_mq_alloc_disk Christoph Hellwig
2024-02-12 6:46 ` [PATCH 11/15] virtio_blk: split virtblk_probe Christoph Hellwig
2024-02-12 6:46 ` [PATCH 12/15] virtio_blk: pass queue_limits to blk_mq_alloc_disk Christoph Hellwig
2024-02-12 6:46 ` [PATCH 13/15] loop: cleanup loop_config_discard Christoph Hellwig
2024-02-12 6:46 ` [PATCH 14/15] loop: pass queue_limits to blk_mq_alloc_disk Christoph Hellwig
2024-02-12 6:46 ` [PATCH 15/15] loop: use the atomic queue limits update API Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2024-02-13 7:34 atomic queue limits updates v5 Christoph Hellwig
2024-02-13 7:34 ` [PATCH 08/15] block: pass a queue_limits argument to blk_alloc_queue Christoph Hellwig
2024-02-13 12:01 ` Hannes Reinecke
2024-01-22 17:36 atomic queue limits updates Christoph Hellwig
2024-01-22 17:36 ` [PATCH 08/15] block: pass a queue_limits argument to blk_alloc_queue Christoph Hellwig
2024-01-23 5:17 ` Damien Le Moal
2024-01-24 6:14 ` Hannes Reinecke
2024-01-25 9:45 ` John Garry
2024-01-25 14:32 ` Christoph Hellwig
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=eded0bd7-ef9e-4cd3-96fb-cd7d312b677e@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=jasowang@redhat.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=martin.petersen@oracle.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=sagi@grimberg.me \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.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