On Thu, Jun 11, 2026 at 10:03 PM <[email protected]> wrote: > > > libbpf: Allow callbacks at consumption time > > > > Ring buffer callbacks and contexts are fixed when each ring is added to > > a manager. Callers that drain records into per-operation state, such as > > a bounded destination buffer, must therefore keep mutable dispatch state > > alive for the lifetime of the manager or rebuild it for each operation. > > > > Add bounded manager and per-ring consumption APIs that take a callback > > and context for one operation. The supplied callback overrides the > > configured callback without changing it. This also allows managers used > > only through the new APIs to be created without a setup-time callback. > > > > Make zero-record requests return without invoking callbacks so all > > bounded consumption APIs preserve their bound. > > > > Signed-off-by: Tamir Duberstein <[email protected]> > > Part of this change looks like a bug fix. The early return added to > ringbuf_process_ring(): > > if (n == 0) > return 0; > > makes a request for zero records return without consuming or dispatching > anything. Before this, the cnt >= n limit was only checked after the > sample callback ran, so an n == 0 request still consumed and dispatched > one record and violated the requested bound. > > That bound-violation behavior came in with the bounded consumption APIs > ring_buffer__consume_n() / ring__consume_n() and the n parameter on > ringbuf_process_ring(). Should this carry: > > Fixes: 4d22ea94ea33 ("libbpf: Add ring__consume_n / ring_buffer__consume_n")
Thanks. My clanker flagged the same. I will extract this fix into a separate patch in v2.

