diff --git a/bpf/headers/include/bpf/BpfRingbuf.h b/bpf/headers/include/bpf/BpfRingbuf.h index 4bcd259725..5fe4ef7cd5 100644 --- a/bpf/headers/include/bpf/BpfRingbuf.h +++ b/bpf/headers/include/bpf/BpfRingbuf.h @@ -99,6 +99,7 @@ class BpfRingbufBase { // 32-bit kernel will just ignore the high-order bits. std::atomic_uint64_t* mConsumerPos = nullptr; std::atomic_uint32_t* mProducerPos = nullptr; + std::atomic_uint32_t* mLength = nullptr; // In order to guarantee atomic access in a 32 bit userspace environment, atomic_uint64_t is used // in addition to std::atomic::is_always_lock_free that guarantees that read / write operations @@ -247,7 +248,8 @@ inline base::Result BpfRingbufBase::ConsumeAll( // u32 len; // u32 pg_off; // }; - uint32_t length = *reinterpret_cast(start_ptr); + mLength = reinterpret_cast(start_ptr); + uint32_t length = mLength->load(std::memory_order_acquire); // If the sample isn't committed, we're caught up with the producer. if (length & BPF_RINGBUF_BUSY_BIT) return count;