From: hare@kernel.org
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@kernel.org>
Subject: [RFC PATCH 0/6] nvme multipath eBPF path selector
Date: Tue, 29 Jul 2025 09:06:47 +0200 [thread overview]
Message-ID: <20250729070653.125258-1-hare@kernel.org> (raw)
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
next reply other threads:[~2025-07-29 7:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 7:06 hare [this message]
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
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=20250729070653.125258-1-hare@kernel.org \
--to=hare@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.