-
Notifications
You must be signed in to change notification settings - Fork 240
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
Design proposal for new ring buffer API #3848
base: main
Are you sure you want to change the base?
Conversation
Converting to draft while I make a few design updates. |
* @returns Pointer to ring buffer manager. | ||
*/ | ||
struct ring_buffer * | ||
ring_buffer__new(int map_fd, ring_buffer_sample_fn sample_cb, void *ctx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we differentiate between callback vs poll?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the design so callback consumers now use the libbpf ring buffer manager, and direct mapped memory consumers use the new functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow. How does Linux differentiate? Why would we want a different answer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the sample code. Its broken as it will not work correctly on weakly ordered systems (ARM64 as an example).
Splits the design so callback consumers use the existing libbpf APIs, and mapped memory consumers use the new windows-specific functions.
docs/RingBuffer.md
Outdated
|
||
// Update consumer offset (and pad record length to multiple of 8). | ||
consumer_offset += sizeof(rb_header_t) + (record->length + 7 & ~7); | ||
WriteRelease64(cons_offset, consumer_offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WriteNoFence64
1. Call `ebpf_ring_buffer_get_buffer` to get pointers to the mapped producer/consumer pages. | ||
2. Call `ebpf_ring_buffer_get_wait_handle` to get the wait handle. | ||
3. Directly read records from the producer pages (and update consumer offset as we read). | ||
4. Call `WaitForSingleObject`/`WaitForMultipleObject` as needed to wait for new data to be available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 6 says Linux supports polling consumers. What APIs do callers use on Linux to get this behavior?
Why can't those APIs work on Windows? Why are new ebpf_
APIs needed?
This document doesn't appear to answer any of these questions.
* @returns Pointer to ring buffer manager. | ||
*/ | ||
struct ring_buffer * | ||
ring_buffer__new(int map_fd, ring_buffer_sample_fn sample_cb, void *ctx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow. How does Linux differentiate? Why would we want a different answer?
docs/RingBuffer.md
Outdated
const struct ring_buffer_opts *opts); | ||
|
||
/** | ||
* @brief poll ringbuf for new data (NOT CURRENTLY SUPPORTED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not currently supported?
Description
Add docs/RingBuffer.md with proposal for new ebpf ring buffer map API exposing mapped memory so consumers can directly read the records written by the producer (similar to linux mmap/epoll style ring buffer consumer).
Testing
N/A
Documentation
Documentation only.
Installation
N/A