-
Notifications
You must be signed in to change notification settings - Fork 245
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. |
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
* | ||
* @returns Pointer to consumer offset | ||
*/ | ||
uint64_t* rb__consumer_offset(void *cons); |
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.
Does this exact same prototype exist on Linux? I couldn't find it, I could only find
https://github.com/torvalds/linux/blob/master/include/uapi/linux/bpf.h#L4558 as a helper function.
This doesn't follow https://github.com/microsoft/ebpf-for-windows/blob/main/docs/DevelopmentGuide.md#coding-conventions so is only ok if it's identical to Linux.
docs/RingBuffer.md
Outdated
* | ||
* @returns Pointer to producer offset | ||
*/ | ||
volatile const uint64_t* rb__producer_offset(volatile const void *prod); |
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.
Does this exact same prototype exist on Linux? I couldn't find it, I could only find
https://github.com/torvalds/linux/blob/master/include/uapi/linux/bpf.h#L4558
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.
Thanks for this, the "Memory mapped consumers" API is pretty much what is necessary for a native ringbuf reader for ebpf-go
. Left some comments, excited to see this take shape!
* | ||
* @returns Wait handle | ||
*/ | ||
HANDLE ebpf_ring_buffer_get_wait_handle(fd_t map_fd); |
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.
HANDLE ebpf_ring_buffer_get_wait_handle(fd_t map_fd); | |
ebpf_handle_t ebpf_ring_buffer_get_wait_handle(fd_t map_fd); |
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.
Same question as above, can I get multiple handles? Do I need to close this?
* @retval EBPF_SUCCESS The operation was successful. | ||
* @retval other An error occurred. | ||
*/ | ||
ebpf_result_t ebpf_ring_buffer_get_buffer(fd_t map_fd, _Out_ void **producer, _Out_ void **consumer); |
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.
Does this return the same buffer every time it's called? How long is the mapping valid for? Until the fd is closed?
pages mapped into user space, and `ebpf_ring_buffer_get_wait_handle()` to get the SynchronizationEvent (auto-reset) KEVENT | ||
to use with `WaitForSingleObject`/`WaitForMultipleObject`. | ||
|
||
Similar to the linux memory layout, the first page of the producer and consumer memory is the "producer page" and "consumer page", |
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.
Are you going to document the layout, or are users required to use the C helpers to retrieve offsets?
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