Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ebpf_ring_buffer to remove lock #4204

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

mikeagun
Copy link
Contributor

@mikeagun mikeagun commented Feb 12, 2025

Remove lock from ebpf_ring_buffer and use acquire/release and atomics to ensure safe ordering.

Description

The ring buffer now uses acquire/release semantics to synchronize between producers and consumers, and an interlocked compare-exchange to serialize producer reservations.

This change also updates the record header to match the 64 bit header used on linux.

There is no effect on the public API (the implementation details aren't currently exposed by libbpf).

The new producer and consumer algorithms are described in docs/RingBuffer.md and libs/runtime/ebpf_ring_buffer.c.

Testing

Updated existing ring buffer tests and added new stress tests to test the synchronization changes.

Documentation

The new producer and consumer algorithms are described in docs/RingBuffer.md.

The implementation details are documented in libs/runtime/ebpf_ring_buffer.c.

Installation

N/A

Michael Agun added 2 commits February 11, 2025 16:49
@mikeagun mikeagun changed the title Refactor ebpf_ring_buffer and redesign synchronization Refactor ebpf_ring_buffer to remove lock Feb 12, 2025
@mikeagun mikeagun marked this pull request as ready for review February 13, 2025 00:52
@Alan-Jowett Alan-Jowett modified the milestone: 2502 Feb 19, 2025
Alan-Jowett
Alan-Jowett previously approved these changes Feb 21, 2025
matthewige
matthewige previously approved these changes Feb 21, 2025
@mikeagun mikeagun dismissed stale reviews from matthewige and Alan-Jowett via 04a92f0 February 21, 2025 21:22
Alan-Jowett
Alan-Jowett previously approved these changes Feb 21, 2025
matthewige
matthewige previously approved these changes Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants