linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Chao Leng <lengchao@huawei.com>
To: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
	Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>
Cc: Ming Lei <ming.lei@redhat.com>, <linux-nvme@lists.infradead.org>,
	<linux-block@vger.kernel.org>, Hannes Reinecke <hare@suse.de>
Subject: Re: [PATCH 14/17] blk-mq: move the srcu_struct used for quiescing to the tagset
Date: Wed, 26 Oct 2022 16:48:55 +0800	[thread overview]
Message-ID: <12eb7ad8-6b70-092a-978c-a2c1ba595ad4@huawei.com> (raw)
In-Reply-To: <20221025144020.260458-15-hch@lst.de>



On 2022/10/25 22:40, Christoph Hellwig wrote:
> All I/O submissions have fairly similar latencies, and a tagset-wide
> quiesce is a fairly common operation.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Keith Busch <kbusch@kernel.org>
> Reviewed-by: Ming Lei <ming.lei@redhat.com>
> Reviewed-by: Chao Leng <lengchao@huawei.com>
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
> Reviewed-by: Hannes Reinecke <hare@suse.de>
> ---
>   block/blk-core.c       | 27 +++++----------------------
>   block/blk-mq.c         | 33 +++++++++++++++++++++++++--------
>   block/blk-mq.h         | 14 +++++++-------
>   block/blk-sysfs.c      |  9 ++-------
>   block/blk.h            |  9 +--------
>   block/genhd.c          |  2 +-
>   include/linux/blk-mq.h |  4 ++++
>   include/linux/blkdev.h |  9 ---------
>   8 files changed, 45 insertions(+), 62 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 17667159482e0..3a2ed8dadf738 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -65,7 +65,6 @@ DEFINE_IDA(blk_queue_ida);
>    * For queue allocation
>    */
>   struct kmem_cache *blk_requestq_cachep;
> -struct kmem_cache *blk_requestq_srcu_cachep;
>   
>   /*
>    * Controlling structure to kblockd
> @@ -373,26 +372,20 @@ static void blk_timeout_work(struct work_struct *work)
>   {
>   }
>   
> -struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu)
> +struct request_queue *blk_alloc_queue(int node_id)
>   {
>   	struct request_queue *q;
>   
> -	q = kmem_cache_alloc_node(blk_get_queue_kmem_cache(alloc_srcu),
> -			GFP_KERNEL | __GFP_ZERO, node_id);
> +	q = kmem_cache_alloc_node(blk_requestq_cachep, GFP_KERNEL | __GFP_ZERO,
> +				  node_id);
>   	if (!q)
>   		return NULL;
>   
> -	if (alloc_srcu) {
> -		blk_queue_flag_set(QUEUE_FLAG_HAS_SRCU, q);
> -		if (init_srcu_struct(q->srcu) != 0)
> -			goto fail_q;
> -	}
> -
>   	q->last_merge = NULL;
>   
>   	q->id = ida_alloc(&blk_queue_ida, GFP_KERNEL);
>   	if (q->id < 0)
> -		goto fail_srcu;
> +		goto fail_q;
>   
>   	q->stats = blk_alloc_queue_stats();
>   	if (!q->stats)
> @@ -435,11 +428,8 @@ struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu)
>   	blk_free_queue_stats(q->stats);
>   fail_id:
>   	ida_free(&blk_queue_ida, q->id);
> -fail_srcu:
> -	if (alloc_srcu)
> -		cleanup_srcu_struct(q->srcu);
>   fail_q:
> -	kmem_cache_free(blk_get_queue_kmem_cache(alloc_srcu), q);
> +	kmem_cache_free(blk_requestq_cachep, q);
>   	return NULL;
>   }
>   
> @@ -1184,9 +1174,6 @@ int __init blk_dev_init(void)
>   			sizeof_field(struct request, cmd_flags));
>   	BUILD_BUG_ON(REQ_OP_BITS + REQ_FLAG_BITS > 8 *
>   			sizeof_field(struct bio, bi_opf));
> -	BUILD_BUG_ON(ALIGN(offsetof(struct request_queue, srcu),
> -			   __alignof__(struct request_queue)) !=
> -		     sizeof(struct request_queue));
>   
>   	/* used for unplugging and affects IO latency/throughput - HIGHPRI */
>   	kblockd_workqueue = alloc_workqueue("kblockd",
> @@ -1197,10 +1184,6 @@ int __init blk_dev_init(void)
>   	blk_requestq_cachep = kmem_cache_create("request_queue",
>   			sizeof(struct request_queue), 0, SLAB_PANIC, NULL);
>   
> -	blk_requestq_srcu_cachep = kmem_cache_create("request_queue_srcu",
> -			sizeof(struct request_queue) +
> -			sizeof(struct srcu_struct), 0, SLAB_PANIC, NULL);
> -
>   	blk_debugfs_root = debugfs_create_dir("block", NULL);
>   
>   	return 0;
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 802fdd3d737e3..6cbf34921e33f 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -261,8 +261,8 @@ EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue_nowait);
>    */
>   void blk_mq_wait_quiesce_done(struct request_queue *q)
>   {
> -	if (blk_queue_has_srcu(q))
> -		synchronize_srcu(q->srcu);
> +	if (q->tag_set->flags & BLK_MQ_F_BLOCKING)
> +		synchronize_srcu(q->tag_set->srcu);
>   	else
>   		synchronize_rcu();
>   }
> @@ -3971,7 +3971,7 @@ static struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set,
>   	struct request_queue *q;
>   	int ret;
>   
> -	q = blk_alloc_queue(set->numa_node, set->flags & BLK_MQ_F_BLOCKING);
> +	q = blk_alloc_queue(set->numa_node);
>   	if (!q)
>   		return ERR_PTR(-ENOMEM);
>   	q->queuedata = queuedata;
> @@ -4138,9 +4138,6 @@ static void blk_mq_update_poll_flag(struct request_queue *q)
>   int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
>   		struct request_queue *q)
>   {
> -	WARN_ON_ONCE(blk_queue_has_srcu(q) !=
> -			!!(set->flags & BLK_MQ_F_BLOCKING));
> -
>   	/* mark the queue as mq asap */
>   	q->mq_ops = set->ops;
>   
> @@ -4398,9 +4395,19 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
>   	 */
>   	if (set->nr_maps == 1 && set->nr_hw_queues > nr_cpu_ids)
>   		set->nr_hw_queues = nr_cpu_ids;
> +
> +	if (set->flags & BLK_MQ_F_BLOCKING) {
> +		set->srcu = kmalloc(sizeof(*set->srcu), GFP_KERNEL);
Memory with contiguous physical addresses is not necessary, maybe it is a better choice to use kvmalloc,
because sizeof(*set->srcu) is a little large.
kvmalloc() is more friendly to scenarios where memory is insufficient and running for a long time.


  reply	other threads:[~2022-10-26  8:49 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 14:40 per-tagset SRCU struct and quiesce v2 Christoph Hellwig
2022-10-25 14:40 ` [PATCH 01/17] block: set the disk capacity to 0 in blk_mark_disk_dead Christoph Hellwig
2022-10-26 12:39   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 02/17] nvme-pci: refactor the tagset handling in nvme_reset_work Christoph Hellwig
2022-10-26 12:46   ` Sagi Grimberg
2022-10-30  9:17     ` Christoph Hellwig
2022-10-25 14:40 ` [PATCH 03/17] nvme-pci: don't warn about the lack of I/O queues for admin controllers Christoph Hellwig
2022-10-26 12:49   ` Sagi Grimberg
2022-10-30  9:18     ` Christoph Hellwig
2022-10-25 14:40 ` [PATCH 04/17] nvme: don't call nvme_kill_queues from nvme_remove_namespaces Christoph Hellwig
2022-10-25 17:43   ` Keith Busch
2022-10-25 20:17     ` Sagi Grimberg
2022-10-30  9:22     ` Christoph Hellwig
2022-10-25 14:40 ` [PATCH 05/17] nvme: don't remove namespaces in nvme_passthru_end Christoph Hellwig
2022-10-26 12:50   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 06/17] nvme: remove the NVME_NS_DEAD check in nvme_remove_invalid_namespaces Christoph Hellwig
2022-10-26 12:50   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 07/17] nvme: remove the NVME_NS_DEAD check in nvme_validate_ns Christoph Hellwig
2022-10-26 12:52   ` Sagi Grimberg
2022-10-30  9:28     ` Christoph Hellwig
2022-10-25 14:40 ` [PATCH 08/17] nvme: don't unquiesce the admin queue in nvme_kill_queues Christoph Hellwig
2022-10-26 12:53   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 09/17] nvme: don't unquiesce the I/O queues " Christoph Hellwig
2022-10-26 12:54   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 10/17] nvme-pci: mark the namespaces dead earlier in nvme_remove Christoph Hellwig
2022-10-25 18:53   ` Keith Busch
2022-10-26 12:55   ` Sagi Grimberg
2022-10-26 12:57     ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 11/17] nvme-pci: don't unquiesce the I/O queues in nvme_remove_dead_ctrl Christoph Hellwig
2022-10-26  8:34   ` Chao Leng
2022-10-26 12:58     ` Sagi Grimberg
2022-10-27  2:46       ` Chao Leng
2022-10-25 14:40 ` [PATCH 12/17] nvme-pci: don't unquiesce the I/O queues in apple_nvme_reset_work Christoph Hellwig
2022-10-26  8:37   ` Chao Leng
2022-10-26 12:58   ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 13/17] blk-mq: skip non-mq queues in blk_mq_quiesce_queue Christoph Hellwig
2022-10-25 14:40 ` [PATCH 14/17] blk-mq: move the srcu_struct used for quiescing to the tagset Christoph Hellwig
2022-10-26  8:48   ` Chao Leng [this message]
2022-10-26 13:01     ` Sagi Grimberg
2022-10-27  2:49       ` Chao Leng
2022-10-27 10:02         ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 15/17] blk-mq: pass a tagset to blk_mq_wait_quiesce_done Christoph Hellwig
2022-10-25 14:40 ` [PATCH 16/17] blk-mq: add tagset quiesce interface Christoph Hellwig
2022-10-26  8:51   ` Chao Leng
2022-10-26 13:02     ` Sagi Grimberg
2022-10-25 14:40 ` [PATCH 17/17] nvme: use blk_mq_[un]quiesce_tagset Christoph Hellwig
2022-10-26 13:03   ` Sagi Grimberg

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=12eb7ad8-6b70-092a-978c-a2c1ba595ad4@huawei.com \
    --to=lengchao@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=ming.lei@redhat.com \
    --cc=sagi@grimberg.me \
    /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).