Re: [PATCH bpf-next v3 4/8] libbpf: ringbuf: Add a caller-owned iterator
From: Kumar Kartikeya Dwivedi
Date: Mon Nov 23 2026 - 16:18:57 EST
On Fri Nov 20, 2026 at 9:33 PM CET, Tamir Duberstein wrote:
> Ring buffer records are exposed only through callbacks. Callers that
> need to stop at an operation-specific condition have no non-error way to
> end consumption early.
>
> Add a caller-owned iterator that returns borrowed records one at a time.
> Each next call ends the borrow and can publish consumed records before
> inspecting another one, allowing callers to batch consumer updates.
> Implement callback consumption on the same internal iterator core so
> both paths share the record traversal and publication protocol. Allow
> iterator-only rings to omit the setup callback.
>
> Preserve callback validation, so callback-based consumption of an
> iterator-only ring still returns -EINVAL. Keep the consumer-publication
> barrier on early destruction, including bounded and callback-error
> returns.
>
> Keep overwrite maps out of the public iterator; handling a stale
> consumer position requires a separate resynchronization protocol.
> Require iterator users to observe exhaustion before waiting for another
> readiness notification.
>
> Signed-off-by: Tamir Duberstein <tamird@xxxxxxxxxx>
> ---
Hi Tamir,
I had a similar patch set in flight, to ressurect your older changes (which
explains why I sent out some your fixes which were landable).
We can compare notes on the API design and decide on the path forward here.
Feel free to provide feedback on [0], I have put you in the Cc list.
Thanks.
[0]: https://lore.kernel.org/bpf/cover.1795467315.git.memxor@xxxxxxxxx
> [...]