HomeFreeBSD

buf_ring: Use atomic operations with br_cons_tail

Description

buf_ring: Use atomic operations with br_cons_tail

Use an atomic operation with a memory barrier loading br_cons_tail
from the producer thread and storing to it in the consumer thread.

On dequeue we need to read the pointer value from the buf_ring before
moving the consumer tail as that indicates the entry is available to be
used. The store release atomic operation guarantees this.

In the enqueueing thread we then need to use a load acquire atomic
operation to ensure writing to this entry can only happen after the
tail has been read and checked.

Reported by: Ali Saidi <alisaidi@amazon.com>
Co-developed by: Ali Saidi <alisaidi@amazon.com>
Reviewed by: markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D46152

Details

Provenance
andrewAuthored on Aug 19 2024, 9:06 AM
Reviewer
markj
Differential Revision
D46152: buf_ring: Use atomic operations with br_cons_tail
Parents
rG3cc603909e09: buf_ring: Keep the full head and tail values
Branches
Unknown
Tags
Unknown