From: Caleb Sander Mateos <csander@purestorage.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
io-uring@vger.kernel.org, Akilesh Kailash <akailash@google.com>,
bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH 1/5] io_uring: prepare for extending io_uring with bpf
Date: Tue, 30 Dec 2025 20:13:40 -0500 [thread overview]
Message-ID: <CADUfDZoTWvDspuyLRsHXZRa3D__dffyAptF=BpaF+h6pREbPug@mail.gmail.com> (raw)
In-Reply-To: <20251104162123.1086035-2-ming.lei@redhat.com>
On Tue, Nov 4, 2025 at 8:22 AM Ming Lei <ming.lei@redhat.com> wrote:
>
> Add one bpf operation & related framework and prepare for extending io_uring
> with bpf.
>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> include/uapi/linux/io_uring.h | 1 +
> init/Kconfig | 7 +++++++
> io_uring/Makefile | 1 +
> io_uring/bpf.c | 26 ++++++++++++++++++++++++++
> io_uring/opdef.c | 10 ++++++++++
> io_uring/uring_bpf.h | 26 ++++++++++++++++++++++++++
> 6 files changed, 71 insertions(+)
> create mode 100644 io_uring/bpf.c
> create mode 100644 io_uring/uring_bpf.h
>
> diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
> index 04797a9b76bc..b167c1d4ce6e 100644
> --- a/include/uapi/linux/io_uring.h
> +++ b/include/uapi/linux/io_uring.h
> @@ -303,6 +303,7 @@ enum io_uring_op {
> IORING_OP_PIPE,
> IORING_OP_NOP128,
> IORING_OP_URING_CMD128,
> + IORING_OP_BPF,
>
> /* this goes last, obviously */
> IORING_OP_LAST,
> diff --git a/init/Kconfig b/init/Kconfig
> index cab3ad28ca49..14d566516643 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1843,6 +1843,13 @@ config IO_URING
> applications to submit and complete IO through submission and
> completion rings that are shared between the kernel and application.
>
> +config IO_URING_BPF
> + bool "Enable IO uring bpf extension" if EXPERT
> + depends on IO_URING && BPF
> + help
> + This option enables bpf extension for the io_uring interface, so
> + application can define its own io_uring operation by bpf program.
> +
> config GCOV_PROFILE_URING
> bool "Enable GCOV profiling on the io_uring subsystem"
> depends on IO_URING && GCOV_KERNEL
> diff --git a/io_uring/Makefile b/io_uring/Makefile
> index bc4e4a3fa0a5..35eeeaf64489 100644
> --- a/io_uring/Makefile
> +++ b/io_uring/Makefile
> @@ -22,3 +22,4 @@ obj-$(CONFIG_NET_RX_BUSY_POLL) += napi.o
> obj-$(CONFIG_NET) += net.o cmd_net.o
> obj-$(CONFIG_PROC_FS) += fdinfo.o
> obj-$(CONFIG_IO_URING_MOCK_FILE) += mock_file.o
> +obj-$(CONFIG_IO_URING_BPF) += bpf.o
> diff --git a/io_uring/bpf.c b/io_uring/bpf.c
> new file mode 100644
> index 000000000000..8c47df13c7b5
> --- /dev/null
> +++ b/io_uring/bpf.c
> @@ -0,0 +1,26 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2024 Red Hat */
> +
> +#include <linux/kernel.h>
> +#include <linux/errno.h>
> +#include <uapi/linux/io_uring.h>
> +#include "io_uring.h"
> +#include "uring_bpf.h"
> +
> +int io_uring_bpf_issue(struct io_kiocb *req, unsigned int issue_flags)
> +{
> + return -ECANCELED;
> +}
> +
> +int io_uring_bpf_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
> +{
> + return -EOPNOTSUPP;
> +}
> +
> +void io_uring_bpf_fail(struct io_kiocb *req)
> +{
> +}
> +
> +void io_uring_bpf_cleanup(struct io_kiocb *req)
> +{
> +}
> diff --git a/io_uring/opdef.c b/io_uring/opdef.c
> index df52d760240e..d93ee3d577d4 100644
> --- a/io_uring/opdef.c
> +++ b/io_uring/opdef.c
> @@ -38,6 +38,7 @@
> #include "futex.h"
> #include "truncate.h"
> #include "zcrx.h"
> +#include "uring_bpf.h"
>
> static int io_no_issue(struct io_kiocb *req, unsigned int issue_flags)
> {
> @@ -593,6 +594,10 @@ const struct io_issue_def io_issue_defs[] = {
> .prep = io_uring_cmd_prep,
> .issue = io_uring_cmd,
> },
> + [IORING_OP_BPF] = {
> + .prep = io_uring_bpf_prep,
> + .issue = io_uring_bpf_issue,
Should this set .prep = io_eopnotsupp_prep for !CONFIG_IO_URING_BPF
and remove the stub implementations? That would be more consistent
with the other opcodes when they are configured out, and ensure
io_uring_op_supported(IORING_OP_BPF) returns false for
!CONFIG_IO_URING_BPF.
Best,
Caleb
> + },
> };
>
> const struct io_cold_def io_cold_defs[] = {
> @@ -851,6 +856,11 @@ const struct io_cold_def io_cold_defs[] = {
> .sqe_copy = io_uring_cmd_sqe_copy,
> .cleanup = io_uring_cmd_cleanup,
> },
> + [IORING_OP_BPF] = {
> + .name = "BPF",
> + .cleanup = io_uring_bpf_cleanup,
> + .fail = io_uring_bpf_fail,
> + },
> };
>
> const char *io_uring_get_opcode(u8 opcode)
> diff --git a/io_uring/uring_bpf.h b/io_uring/uring_bpf.h
> new file mode 100644
> index 000000000000..bde774ce6ac0
> --- /dev/null
> +++ b/io_uring/uring_bpf.h
> @@ -0,0 +1,26 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#ifndef IOU_BPF_H
> +#define IOU_BPF_H
> +
> +#ifdef CONFIG_IO_URING_BPF
> +int io_uring_bpf_issue(struct io_kiocb *req, unsigned int issue_flags);
> +int io_uring_bpf_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
> +void io_uring_bpf_fail(struct io_kiocb *req);
> +void io_uring_bpf_cleanup(struct io_kiocb *req);
> +#else
> +static inline int io_uring_bpf_issue(struct io_kiocb *req, unsigned int issue_flags)
> +{
> + return -ECANCELED;
> +}
> +static inline int io_uring_bpf_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
> +{
> + return -EOPNOTSUPP;
> +}
> +static inline void io_uring_bpf_fail(struct io_kiocb *req)
> +{
> +}
> +static inline void io_uring_bpf_cleanup(struct io_kiocb *req)
> +{
> +}
> +#endif
> +#endif
> --
> 2.47.0
>
next prev parent reply other threads:[~2025-12-31 1:13 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 16:21 [PATCH 0/5] io_uring: add IORING_OP_BPF for extending io_uring Ming Lei
2025-11-04 16:21 ` [PATCH 1/5] io_uring: prepare for extending io_uring with bpf Ming Lei
2025-12-31 1:13 ` Caleb Sander Mateos [this message]
2025-12-31 9:33 ` Ming Lei
2025-11-04 16:21 ` [PATCH 2/5] io_uring: bpf: add io_uring_ctx setup for BPF into one list Ming Lei
2025-12-31 1:13 ` Caleb Sander Mateos
2025-12-31 9:49 ` Ming Lei
2025-12-31 16:19 ` Caleb Sander Mateos
2025-11-04 16:21 ` [PATCH 3/5] io_uring: bpf: extend io_uring with bpf struct_ops Ming Lei
2025-11-07 19:02 ` kernel test robot
2025-11-08 6:53 ` kernel test robot
2025-11-13 10:32 ` Stefan Metzmacher
2025-11-13 10:59 ` Ming Lei
2025-11-13 11:19 ` Stefan Metzmacher
2025-11-14 3:00 ` Ming Lei
2025-12-08 22:45 ` Caleb Sander Mateos
2025-12-09 3:08 ` Ming Lei
2025-12-10 16:11 ` Caleb Sander Mateos
2025-11-19 14:39 ` Jonathan Corbet
2025-11-20 1:46 ` Ming Lei
2025-11-20 1:51 ` Ming Lei
2025-12-31 1:19 ` Caleb Sander Mateos
2025-12-31 10:32 ` Ming Lei
2025-12-31 16:48 ` Caleb Sander Mateos
2025-11-04 16:21 ` [PATCH 4/5] io_uring: bpf: add buffer support for IORING_OP_BPF Ming Lei
2025-11-13 10:42 ` Stefan Metzmacher
2025-11-13 11:04 ` Ming Lei
2025-11-13 11:25 ` Stefan Metzmacher
2025-12-31 1:42 ` Caleb Sander Mateos
2025-12-31 11:02 ` Ming Lei
2025-12-31 17:02 ` Caleb Sander Mateos
2025-11-04 16:21 ` [PATCH 5/5] io_uring: bpf: add io_uring_bpf_req_memcpy() kfunc Ming Lei
2025-11-07 18:51 ` kernel test robot
2025-12-31 1:42 ` Caleb Sander Mateos
2025-11-05 12:47 ` [PATCH 0/5] io_uring: add IORING_OP_BPF for extending io_uring Pavel Begunkov
2025-11-05 15:57 ` Ming Lei
2025-11-06 16:03 ` Pavel Begunkov
2025-11-07 15:54 ` Ming Lei
2025-11-11 14:07 ` Pavel Begunkov
2025-11-13 4:18 ` Ming Lei
2025-11-19 19:00 ` Pavel Begunkov
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='CADUfDZoTWvDspuyLRsHXZRa3D__dffyAptF=BpaF+h6pREbPug@mail.gmail.com' \
--to=csander@purestorage.com \
--cc=akailash@google.com \
--cc=ast@kernel.org \
--cc=axboe@kernel.dk \
--cc=bpf@vger.kernel.org \
--cc=io-uring@vger.kernel.org \
--cc=ming.lei@redhat.com \
/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