Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf: Clarify BPF_RB_NO_WAKEUP behavior for bpf_ringbuf_discard()

Clarify bpf_ringbuf_discard() documentation for BPF_RB_NO_WAKEUP.

Discarded ring buffer records are still left in the ring buffer and are
only skipped when user space consumes them. This can matter when
BPF_RB_NO_WAKEUP is used: a later submit relying on adaptive wakeup
might not wake the consumer, because the discarded record still needs to
be consumed first.

Scenario:

epoll_wait(rb_fd); // blocks

rec = bpf_ringbuf_reserve(&rb, ...);
bpf_ringbuf_discard(rec, BPF_RB_NO_WAKEUP);

rec = bpf_ringbuf_reserve(&rb, ...);
bpf_ringbuf_submit(rec, 0); // valid record, but no wakeup

Document this in bpf_ringbuf_discard() to make the interaction between
discarded records, user-space consumption, and adaptive wakeups explicit.

Reported-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260331130612.3762433-1-eyal.birger@gmail.com

----

v2: adapt wording per feedback from Andrii.

authored by

Eyal Birger and committed by
Andrii Nakryiko
f9a80c7c 9eccdd38

+6 -2
+3 -1
include/uapi/linux/bpf.h
··· 4645 4645 * Description 4646 4646 * Discard reserved ring buffer sample, pointed to by *data*. 4647 4647 * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification 4648 - * of new data availability is sent. 4648 + * of new data availability is sent. Discarded records remain in 4649 + * the ring buffer until consumed by user space, so a later submit 4650 + * using adaptive wakeup might not wake up the consumer. 4649 4651 * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification 4650 4652 * of new data availability is sent unconditionally. 4651 4653 * If **0** is specified in *flags*, an adaptive notification
+3 -1
tools/include/uapi/linux/bpf.h
··· 4645 4645 * Description 4646 4646 * Discard reserved ring buffer sample, pointed to by *data*. 4647 4647 * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification 4648 - * of new data availability is sent. 4648 + * of new data availability is sent. Discarded records remain in 4649 + * the ring buffer until consumed by user space, so a later submit 4650 + * using adaptive wakeup might not wake up the consumer. 4649 4651 * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification 4650 4652 * of new data availability is sent unconditionally. 4651 4653 * If **0** is specified in *flags*, an adaptive notification