Re: [PATCH v2 bpf 3/4] bpf: Read producer_pos before overwrite_pos in ringbuf_avail_data_sz()
From: bot+bpf-ci
Date: Fri Aug 14 2026 - 09:31:14 EST
> bpf: Read producer_pos before overwrite_pos in ringbuf_avail_data_sz()
>
> The producer documents the order the consumer has to use, in
> __bpf_ringbuf_reserve():
>
> * smp_store_release(&rb->producer_pos, new_prod_pos) at
> * the end of the function ensures that when consumer sees
> * the updated rb->producer_pos, it always sees the updated
> * rb->overwrite_pos, so when consumer reads overwrite_pos
> * after smp_load_acquire(r->producer_pos), the overwrite_pos
> * will always be valid.
>
> ringbuf_avail_data_sz() reads them the other way round, so the acquire
> load of producer_pos no longer orders the load of overwrite_pos. Nothing
> then prevents the pair from being observed as a stale overwrite_pos next
> to an already advanced producer_pos, which overstates the amount of
> available data by however far the producer moved in between.
>
> Swap the two loads so the documented contract holds, and say why in a
> comment.
>
> Signed-off-by: Israel Téllez García <i.tellez@xxxxxxxxx>
This looks like a bug fix for a memory ordering issue. Should this include:
Fixes: b73246ff875b ("adding ci files")
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31802836964