[PATCH RFC v2 00/14] nvme: Controller Data Queue (CDQ) support

Joel Granados posted 14 patches 9 hours ago
drivers/nvme/host/Makefile      |   2 +-
drivers/nvme/host/cdq.c         | 667 ++++++++++++++++++++++++++++++++++++++++
drivers/nvme/host/cdq.h         | 110 +++++++
drivers/nvme/host/core.c        |  46 ++-
drivers/nvme/host/ioctl.c       |  44 ++-
drivers/nvme/host/nvme.h        |   1 +
include/linux/nvme.h            |  78 ++++-
include/uapi/linux/nvme_ioctl.h |  22 ++
8 files changed, 966 insertions(+), 4 deletions(-)
[PATCH RFC v2 00/14] nvme: Controller Data Queue (CDQ) support
Posted by Joel Granados 9 hours ago
This RFC implements Controller Data Queue (CDQ) support in the NVMe
driver, a variation on my two ([2] & [5]) previously shared approaches.
A CDQ is how an NVMe controller reports modified ranges; user space
consumes that stream to aid in data migration.

Motivation
==========
This is about enabling NVMe namespace migration. The timing feels right
as hardware with CDQ capability exists, NVMe fully specifies the feature
and there is growing interest in Live Migration which by extension
includes CDQ.

What
====
Implement CDQ (the backing memory, the controller-side create/delete,
the queue traversal and the asynchronous-event handling) inside the nvme
driver. User space drives everything through a single ioctl. The CDQ is
read through an FD handed back by the nvme driver, which copies new
entries to a user space buffer. A tail pointer trigger can be armed
automatically when there are no new entries. The one shot AEN event
is routed to an eventfd whenever new entries become available.

NVMe LM SW WG
=============
The NVMe Live Migration SoftWare Working Group (mentioned in [6]) was
one of the main feedback points in my previous RFC. My main goal in this
respect is to keep exploring different approaches in the hope that when
it materializes we can "hit the ground running".

vfio-nvme ([1], [4])
====================
This is what I rebased onto [4] and relates to the handling of
controller state in live migration. I was curious to see how it would
interact (if at all) with my CDQ approach; IMO, for now, they are quite
orthogonal. It is **neither** a rejection nor an endorsement of the vfio
approach. From my point of view there is still no consensus on how this
will make its way into mainline.

Feedback
========
1. The CDQ is introduced into core.c. Would putting it in pci.c make
   more sense?
2. I create a new type of submission-less queue for the CDQ. There is no
   way of using the NVMe queue pairs for a submission-less queue, right?
3. Any feedback that can be shared publicly is greatly appreciated.

As always, please tell me if you want to be removed from these moving
forward or if I have missed someone.

Best

Changes in v2:
- CDQ logic (traversal, memory, AEN, ...) is all in the nvme driver.
- CDQ entries are now copied from the CDQ mem to the user space buffer
- Reduced IOCTL command size
- Rebased on top of [4] (wich is [3] with some fixes from my part)
- Don't wait for the completion of the set feature cmd. We handle it
  separately from sending the command to avoid having to wait for the
  round trip to/from the controller.
- Link to v1: [5]

[1] https://lore.kernel.org/20221206055816.292304-1-lei.rao@intel.com
[2] https://lore.kernel.org/20250714-jag-cdq-v1-0-01e027d256d5@kernel.org
[3] https://lore.kernel.org/20250803024705.10256-1-kch@nvidia.com
[4] https://git.kernel.org/pub/scm/linux/kernel/git/joel.granados/linux.git/log/?h=jag/vfio-nvme
[5] https://lore.kernel.org/r/20260424-jag-cdq-lkml-v1-0-d773343a717c@kernel.org
[6] https://lore.kernel.org/de162155-b03a-4626-a416-3425db9235c7@nvidia.com

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
---
Joel Granados (14):
      nvme: Add NVME_AER_ONE_SHOT callback handler
      nvme: Add NVMe Controller Data Queue command
      nvme: Add track send command
      nvme: Add CDQ to xarray and define delete path
      nvme: Allocate CDQ backing memory from coherent DMA chunks
      nvme: Add file descriptor to read CDQs
      nvme: Add the create CDQ functionality
      nvme: Submit track send command to start/stop the CDQ
      nvme: Coordinate CDQ backing mem and CDQ FD
      nvme: Pin a ctrl ref to every CDQ
      nvme: Implement CDQ traversal on the read path
      nvme: Update the controller with the CDQ set-feature cmd
      nvme: Use eventfd for CDQ Tail pointer triggers
      nvme: Add NVME_IOCTL_CDQ to create/delete migration CDQs

 drivers/nvme/host/Makefile      |   2 +-
 drivers/nvme/host/cdq.c         | 667 ++++++++++++++++++++++++++++++++++++++++
 drivers/nvme/host/cdq.h         | 110 +++++++
 drivers/nvme/host/core.c        |  46 ++-
 drivers/nvme/host/ioctl.c       |  44 ++-
 drivers/nvme/host/nvme.h        |   1 +
 include/linux/nvme.h            |  78 ++++-
 include/uapi/linux/nvme_ioctl.h |  22 ++
 8 files changed, 966 insertions(+), 4 deletions(-)
---
base-commit: 087c08850a40fb37753475f90b0cb706effd752c
change-id: 20260424-jag-cdq-lkml-cd9b7c79983d

Best regards,
-- 
Joel Granados <joel.granados@kernel.org>