linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/6] nvme multipath eBPF path selector
@ 2025-07-29  7:06 hare
  2025-07-29  7:06 ` [PATCH 1/6] nvme-multipath: do not assign ->current_path in __nvme_find_path() hare
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: hare @ 2025-07-29  7:06 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Keith Busch, Sagi Grimberg, linux-nvme, Hannes Reinecke

From: Hannes Reinecke <hare@kernel.org>

Hi all,

there are discussion on having to deploy more complex I/O scheduling
algorithms for NVMe, but then there's the question whether we really
want to carry these in the kernel.
Which sounded like an ideal testbed for eBPF struct_ops to me.
Taking a cue from Ming Lei's patchset for eBPF on ublk (thanks, Ming!)
I've started messing around with eBPF.

So here's a patchset to implement nvme multipath eBPF path selectors.
Idea's quite simple: the eBPF 'struct_ops' program is providing a
'select_path' function, which selects a nvme_ns struct to use for
the I/O starting at a given sector.
Unfortunately ePBF doesn't allow to pass pointers, _and_ the definitions
for 'struct nvme_ns_head' and 'struct nvme_ns' are internal to the
nvme subsystem. So I kept those structures as opaque pointers for
ePBF, and introduced a 'nvme_bpf_iter' structure as a path iterator.
There are two functions 'nvme_bpf_first_path' and 'nvme_bpf_next_path'
which can be used for an open-coded loop over all paths.
I've also added sample code as an example how the loop can be coded.

It's all pretty rudimentary (as I'm sure people will need accessors
to get to any namespace or controller details), but that's why I sent
it out as an RFC. And I am by no means an eBPF expert, so I'd be
glad for any corrections or suggestions for a better eBPF integration.

The entire patchset can be found at:
git.kernel.org:/pub/scm/linux/kernel/git/hare/scsi-devel.git
branch nvme-bpf

As usual, reviews and comments are welcome.

Hannes Reinecke (6):
  nvme-multipath: do not assign ->current_path in __nvme_find_path()
  nvme: export nvme_find_get_subsystem()/nvme_put_subsystem()
  nvme: add per-namespace iopolicy sysfs attribute
  nvme: add 'sector' parameter to nvme_find_path()
  nvme-bpf: eBPF struct_ops path selectors
  tools/testing/selftests: add sample nvme bpf path selector

 drivers/nvme/host/Kconfig                     |   9 +
 drivers/nvme/host/Makefile                    |   1 +
 drivers/nvme/host/bpf.h                       |  33 ++
 drivers/nvme/host/bpf_ops.c                   | 347 ++++++++++++++++++
 drivers/nvme/host/core.c                      |  17 +-
 drivers/nvme/host/ioctl.c                     |   7 +-
 drivers/nvme/host/multipath.c                 |  69 +++-
 drivers/nvme/host/nvme.h                      |  11 +-
 drivers/nvme/host/pr.c                        |   2 +-
 drivers/nvme/host/sysfs.c                     |   9 +-
 include/linux/nvme-bpf.h                      |  54 +++
 .../selftests/bpf/progs/bpf_nvme_simple.c     |  52 +++
 12 files changed, 585 insertions(+), 26 deletions(-)
 create mode 100644 drivers/nvme/host/bpf.h
 create mode 100644 drivers/nvme/host/bpf_ops.c
 create mode 100644 include/linux/nvme-bpf.h
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_nvme_simple.c

-- 
2.43.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-07-30 14:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29  7:06 [RFC PATCH 0/6] nvme multipath eBPF path selector hare
2025-07-29  7:06 ` [PATCH 1/6] nvme-multipath: do not assign ->current_path in __nvme_find_path() hare
2025-07-29  7:06 ` [PATCH 2/6] nvme: export nvme_find_get_subsystem()/nvme_put_subsystem() hare
2025-07-29  7:06 ` [PATCH 3/6] nvme: add per-namespace iopolicy sysfs attribute hare
2025-07-29  7:06 ` [PATCH 4/6] nvme: add 'sector' parameter to nvme_find_path() hare
2025-07-29  7:06 ` [PATCH 5/6] nvme-bpf: eBPF struct_ops path selectors hare
2025-07-29  7:06 ` [PATCH 6/6] tools/testing/selftests: add sample nvme bpf path selector hare
2025-07-30  2:03   ` Geliang Tang
2025-07-30  5:56     ` Hannes Reinecke
2025-07-29  7:54 ` [RFC PATCH 0/6] nvme multipath eBPF " Christoph Hellwig
2025-07-29 14:53   ` Mike Christie
2025-07-30 14:06     ` Christoph Hellwig
2025-07-30  2:03 ` Geliang Tang

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).