Re: [PATCH bpf 1/2] bpf: Load ringbuf consumer_pos under the spinlock

From: Alexei Starovoitov

Date: Fri Oct 16 2026 - 12:14:57 EST


On Fri, Oct 16, 2026 at 12:33 AM Igor Malovitsa <igor.malovitsa@xxxxxxxxx> wrote:
> - cons_pos = smp_load_acquire(&rb->consumer_pos);
> -
> if (raw_res_spin_lock_irqsave(&rb->spinlock, flags))
> return NULL;
>
> + /* Under the lock, so at most one ring behind producer_pos. */
> + cons_pos = smp_load_acquire(&rb->consumer_pos);
> +

libbpf writes consumer_pos after every record, so this load is
a cache miss most of the time.
Today it's done before the lock. With this patch all other producers
spin on the lock while this cpu waits for it. On 64-bit too.
So "Neither changes anything on 64-bit" in the cover letter is not correct.

imo it's not worth slowing down everyone for that.

pw-bot: cr