public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Ming Lei <tom.leiming@gmail.com>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	io-uring <io-uring@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Jens Axboe <axboe@kernel.dk>, Xiao Ni <xni@redhat.com>,
	Caleb Sander Mateos <csander@purestorage.com>
Subject: Re: [PATCH v8 5/5] selftests/io_uring: add a bpf io_uring selftest
Date: Wed, 25 Feb 2026 11:12:24 +0000	[thread overview]
Message-ID: <22073d2a-31ea-46c2-bb4a-b771b2fcf8ee@gmail.com> (raw)
In-Reply-To: <CAFj5m9L_WPH_du4GMVYGBdYA_NX1kbGtJpAP0hbfuEjuk5faZw@mail.gmail.com>

On 2/25/26 08:41, Ming Lei wrote:
> On Tue, Feb 24, 2026 at 12:30 AM Pavel Begunkov <asml.silence@gmail.com> wrote:
>>
>> On 2/23/26 15:23, Ming Lei wrote:
>>> On Sat, Feb 21, 2026 at 6:35 AM Pavel Begunkov <asml.silence@gmail.com> wrote:
>>>>
>>>> On 2/20/26 17:45, Alexei Starovoitov wrote:
>>>>> On Fri, Feb 20, 2026 at 3:41 AM Pavel Begunkov <asml.silence@gmail.com> wrote:
>>>>>>
>>>>>> I had such examples, but selftests is not the best place for that.
>>>>>> It can use abstractions, and I want to make them reusable instead
>>>>>> of people copy-pasting from selftests.
>>>>>
>>>>> Sure, but please still post them as extra patches so it's easier
>>>>> to see what's the end result.
>>>>>
>>>>> Also please reply to that thread:
>>>>> https://lore.kernel.org/bpf/CALTww28QMg=YXqKWpWLZrLO+xiqOe3LGyput8dx68-dnQsxg=g@mail.gmail.com/
>>>>>
>>>>> It's not clear to me whether your io_uring+bpf setup will work
>>>>> for Xiao's use case.
>>>>> I don't think we need 2 ways of doing it.
>>>>
>>>> We discussed this with Ming on the list before, that's one of the use
>>>> cases I target as well, there is no reason why it shouldn't work. The
>>>> difference is that this approach gives a flexible framework for
>>>> extensibility and covers a good bunch of other needs, which is exactly
>>>> the reason I moved from a BPF opcode approach, while Ming's proposal is
>>>> more specific but argued to be a way easier to plug into ublk servers.
>>>> If you ask me, we need a solution that covers a broader spectrum of
>>>> use cases, but I guess it all can be argued in either way.
>>>
>>> One big drawback of  Pavel's approach is that it needs a totally
>>> different userspace
>>> implementation for using BPF, which is just hard to use in existing
>>> io_uring applications.
>>
>> Not really, it depends on how you write it. If you need to rewrite CQ
> 
> I meant SQE has to be allocated & built in bpf prog, then it is inevitable
> to move application logic into bpf prog.

But that's what I'm saying, you don't need building sqes in bpf
to augment it with BPF checksumming / etc. I can elaborate when I
get some time, but to give a short example:

# bpf-prog.c:

unsigned csum_jobs;
unsigned regbuf_idx_to_csum;

loop() {
	if (csum_jobs) {
		kfunc_regbuf_do_csum(regbuf_idx_to_csum);
		csum_jobs = 0;
		...
	}

	// proceed to the default submit / lopp implementation
	// you'd expect from normal io_uring_submit_and_wait()
}

# user-prog.c

ring = create_ring();
load_my_bpf();

sqe = get_and_prep_sqe();
// normal submit+wait
io_uring_submit_and_wait();

cqe = get_cqes();
if (cqe->type == ...) {
	skel->bss->csum_jobs++;
	skel->bss->regbuf_idx_to_csum = idx_from_cqe(cqe);
	// use bpf arenas, io_uring regions for the real tning
}

// queue more sqes if needed

// this will do csum'ing and followed by submit+wait
io_uring_submit_and_wait();

> If the logic is complicated, it is one big thing.

The implementation above would be simple enough. And on top,
someone could try to do BPF submissions to cover cases like
you had with group request ordering (forgot the actual name).

> raid5 is a great example with complicated fast io code path, I'd suggest someone
> or Xiao or Caleb, try it. Compare your approach to the bpf opcode and draw
> some useful conclusions.  Code should be more convincing.
> 
> For bpf opcode approach I believe Xiao has already built an example.

It might be entertaining, but I wanted to stress that it's not
a blocker for my work. It can handle the use case with registered
buffers, but I aim at a more wider range of applications, which
wouldn't be covered by the opcode approach. And that's the reason
why I moved away from opcodes, it wasn't flexible enough.

-- 
Pavel Begunkov


  reply	other threads:[~2026-02-25 12:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-17 11:33 [PATCH v8 0/5] BPF controlled io_uring Pavel Begunkov
2026-02-17 11:33 ` [PATCH v8 1/5] io_uring: introduce callback driven main loop Pavel Begunkov
2026-02-17 11:33 ` [PATCH v8 2/5] io_uring/bpf-ops: implement loop_step with BPF struct_ops Pavel Begunkov
2026-02-17 11:33 ` [PATCH v8 3/5] io_uring/bpf-ops: add kfunc helpers Pavel Begunkov
2026-02-17 11:33 ` [PATCH v8 4/5] io_uring/bpf-ops: implement bpf ops registration Pavel Begunkov
2026-02-17 11:33 ` [PATCH v8 5/5] selftests/io_uring: add a bpf io_uring selftest Pavel Begunkov
2026-02-19 19:01   ` Alexei Starovoitov
2026-02-20 11:41     ` Pavel Begunkov
2026-02-20 17:45       ` Alexei Starovoitov
2026-02-20 22:35         ` Pavel Begunkov
2026-02-23 15:23           ` Ming Lei
2026-02-23 16:26             ` Pavel Begunkov
2026-02-25  8:41               ` Ming Lei
2026-02-25 11:12                 ` Pavel Begunkov [this message]
2026-02-23 14:37         ` 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=22073d2a-31ea-46c2-bb4a-b771b2fcf8ee@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bpf@vger.kernel.org \
    --cc=csander@purestorage.com \
    --cc=io-uring@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=tom.leiming@gmail.com \
    --cc=xni@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