* [PATCH 1/3] nvme-pci: ensure we're polling a polled queue
@ 2026-02-10 19:37 Keith Busch
2026-02-10 19:37 ` [PATCH 2/3] nvme-pci: cap queue creation to used queues Keith Busch
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Keith Busch @ 2026-02-10 19:37 UTC (permalink / raw)
To: linux-nvme, hch; +Cc: Keith Busch
From: Keith Busch <kbusch@kernel.org>
A user can change the polled queue count at run time. There's a brief
window during a reset where a hipri task may try to poll that queue
before the block layer has updated the queue maps, which would race with
the now irq driven queue, which can cause double completions.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/pci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 80df992d1ae82..5a3e27305176f 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1496,7 +1496,8 @@ static int nvme_poll(struct blk_mq_hw_ctx *hctx, struct io_comp_batch *iob)
struct nvme_queue *nvmeq = hctx->driver_data;
bool found;
- if (!nvme_cqe_pending(nvmeq))
+ if (!test_bit(NVMEQ_POLLED, &nvmeq->flags) ||
+ !nvme_cqe_pending(nvmeq))
return 0;
spin_lock(&nvmeq->cq_poll_lock);
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/3] nvme-pci: cap queue creation to used queues
2026-02-10 19:37 [PATCH 1/3] nvme-pci: ensure we're polling a polled queue Keith Busch
@ 2026-02-10 19:37 ` Keith Busch
2026-02-11 15:56 ` Christoph Hellwig
2026-02-12 14:57 ` Kanchan Joshi
2026-02-10 19:37 ` [PATCH 3/3] nvme-pci: do not try to add queue maps at runtime Keith Busch
2026-02-11 15:56 ` [PATCH 1/3] nvme-pci: ensure we're polling a polled queue Christoph Hellwig
2 siblings, 2 replies; 7+ messages in thread
From: Keith Busch @ 2026-02-10 19:37 UTC (permalink / raw)
To: linux-nvme, hch; +Cc: Keith Busch
From: Keith Busch <kbusch@kernel.org>
If the user reduces the special queue count at runtime and resets the
controller, we need to reduce the number of queues and interrupts
requested accordingly rather than start with the pre-allocated queue
count.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/pci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 5a3e27305176f..f6d5c242fb689 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2775,7 +2775,8 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
dev->nr_write_queues = write_queues;
dev->nr_poll_queues = poll_queues;
- nr_io_queues = dev->nr_allocated_queues - 1;
+ nr_io_queues = min(nvme_max_io_queues(dev),
+ dev->nr_allocated_queues - 1);
result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues);
if (result < 0)
return result;
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] nvme-pci: cap queue creation to used queues
2026-02-10 19:37 ` [PATCH 2/3] nvme-pci: cap queue creation to used queues Keith Busch
@ 2026-02-11 15:56 ` Christoph Hellwig
2026-02-12 14:57 ` Kanchan Joshi
1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2026-02-11 15:56 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, hch, Keith Busch
On Tue, Feb 10, 2026 at 11:37:14AM -0800, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> If the user reduces the special queue count at runtime and resets the
> controller, we need to reduce the number of queues and interrupts
> requested accordingly rather than start with the pre-allocated queue
> count.
Maybe add a comment as the code isn't quite obvious?
Otherwise looks good.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] nvme-pci: cap queue creation to used queues
2026-02-10 19:37 ` [PATCH 2/3] nvme-pci: cap queue creation to used queues Keith Busch
2026-02-11 15:56 ` Christoph Hellwig
@ 2026-02-12 14:57 ` Kanchan Joshi
1 sibling, 0 replies; 7+ messages in thread
From: Kanchan Joshi @ 2026-02-12 14:57 UTC (permalink / raw)
To: Keith Busch, linux-nvme, hch; +Cc: Keith Busch
On 2/11/2026 1:07 AM, Keith Busch wrote:
> From: Keith Busch<kbusch@kernel.org>
>
> If the user reduces the special queue count at runtime and resets the
> controller,
Yes, I did see a crash on doing just that. Which is gone after this
patch. And I guess you have reasons not to mark this for backport.
So
Reviewed-and-Tested-by: Kanchan Joshi <joshi.k@samsung.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] nvme-pci: do not try to add queue maps at runtime
2026-02-10 19:37 [PATCH 1/3] nvme-pci: ensure we're polling a polled queue Keith Busch
2026-02-10 19:37 ` [PATCH 2/3] nvme-pci: cap queue creation to used queues Keith Busch
@ 2026-02-10 19:37 ` Keith Busch
2026-02-11 15:58 ` Christoph Hellwig
2026-02-11 15:56 ` [PATCH 1/3] nvme-pci: ensure we're polling a polled queue Christoph Hellwig
2 siblings, 1 reply; 7+ messages in thread
From: Keith Busch @ 2026-02-10 19:37 UTC (permalink / raw)
To: linux-nvme, hch; +Cc: Keith Busch
From: Keith Busch <kbusch@kernel.org>
The block layer allocates the set's maps once. We can't add special
purpose queues at runtime if they weren't allocated at initialization
time.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/pci.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index f6d5c242fb689..43d214d31a8cf 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2775,6 +2775,20 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
dev->nr_write_queues = write_queues;
dev->nr_poll_queues = poll_queues;
+ if (dev->ctrl.tagset) {
+ switch (dev->ctrl.tagset->nr_maps) {
+ case 1:
+ dev->nr_write_queues = 0;
+ dev->nr_poll_queues = 0;
+ break;
+ case 2:
+ dev->nr_poll_queues = 0;
+ break;
+ default:
+ break;
+ }
+ }
+
nr_io_queues = min(nvme_max_io_queues(dev),
dev->nr_allocated_queues - 1);
result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues);
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 3/3] nvme-pci: do not try to add queue maps at runtime
2026-02-10 19:37 ` [PATCH 3/3] nvme-pci: do not try to add queue maps at runtime Keith Busch
@ 2026-02-11 15:58 ` Christoph Hellwig
0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2026-02-11 15:58 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, hch, Keith Busch
On Tue, Feb 10, 2026 at 11:37:15AM -0800, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> The block layer allocates the set's maps once. We can't add special
> purpose queues at runtime if they weren't allocated at initialization
> time.
Same here, a comment in the code would be helpful.
> + if (dev->ctrl.tagset) {
> + switch (dev->ctrl.tagset->nr_maps) {
> + case 1:
> + dev->nr_write_queues = 0;
> + dev->nr_poll_queues = 0;
> + break;
> + case 2:
> + dev->nr_poll_queues = 0;
> + break;
Maybe use fallthrough or just two ifs to condense this a tiny bit?
Otherwise looks good.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] nvme-pci: ensure we're polling a polled queue
2026-02-10 19:37 [PATCH 1/3] nvme-pci: ensure we're polling a polled queue Keith Busch
2026-02-10 19:37 ` [PATCH 2/3] nvme-pci: cap queue creation to used queues Keith Busch
2026-02-10 19:37 ` [PATCH 3/3] nvme-pci: do not try to add queue maps at runtime Keith Busch
@ 2026-02-11 15:56 ` Christoph Hellwig
2 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2026-02-11 15:56 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, hch, Keith Busch
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-02-12 14:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10 19:37 [PATCH 1/3] nvme-pci: ensure we're polling a polled queue Keith Busch
2026-02-10 19:37 ` [PATCH 2/3] nvme-pci: cap queue creation to used queues Keith Busch
2026-02-11 15:56 ` Christoph Hellwig
2026-02-12 14:57 ` Kanchan Joshi
2026-02-10 19:37 ` [PATCH 3/3] nvme-pci: do not try to add queue maps at runtime Keith Busch
2026-02-11 15:58 ` Christoph Hellwig
2026-02-11 15:56 ` [PATCH 1/3] nvme-pci: ensure we're polling a polled queue Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox