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

Support direct mapped memory consumers for ring buffer and perf event array maps #4163

Open
mikeagun opened this issue Jan 27, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request optimization Affects perf but not correctness or applicability

Comments

@mikeagun
Copy link
Contributor

Describe the feature you'd like supported

The current ringbuffer uses a pure callback-based approach to reading the ringbuffer.

Linux also supports direct memory-mapped polling consumers, which can't be directly supported in the current model. the direct mapped memory consumers on linux use mmap() to map the ring into user space, and epoll_wait() to wait for data notifications.

The perf event array map has a similar API, but with per-cpu rings, and can also support direct memory mapped consumers on Linux.

  • Perf event arrays are not yet supported in ebpf-for-windows, but the work is in progress.
  • Perf event array proposal: Proposal for perf event arrays #4122
  • Implementation: DRAFT Perf event array map implementation. #4144
  • The initial perf event array support will work similar to the ebpf-for-windows ring buffer, but with synchronous callbacks supported and used by default, but without support for direct memory mapped consumers.

Proposed solution

Supporting direct memory-mapped consumers will require changes to the ring buffer data structures and memory mapping.

  • Keep producer and consumer pages in ring buffer structure (instead of just offsets).
  • Create memory mapping with producer+consumer page inserted before the double-mapped buffer.
  • Document the acquire/release semantics for consumer to directly access producer and consumer offsets.

The internal ring data structure mapped into user space is shared between the perf event array and the ring buffer map, so the changes to support direct memory mapped consumers for both are tightly coupled.

There is already a PR out to document and plan these changes for the ring buffer: #3848

Additional context

No response

@mikeagun mikeagun added enhancement New feature or request optimization Affects perf but not correctness or applicability labels Jan 27, 2025
@mikeagun mikeagun self-assigned this Jan 27, 2025
@lmb
Copy link
Collaborator

lmb commented Jan 28, 2025

This is going to be important for the Tetragon work.

@shankarseal shankarseal modified the milestones: Backlog, 2501, 2502 Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request optimization Affects perf but not correctness or applicability
Projects
None yet
Development

No branches or pull requests

3 participants