-
First, many thanks 🙇🏼 (again) for this incredibly useful project that frees me from the horrors of While working with eBPF task iterators to see if they improve things in term of performance but also data fidelity way beyond I've seen the various Now, Do I basically need to build my eBPF iterator program to some size I deem sufficient for my user base, such as 8192 and copy the cpumask into my fixed size array, zeroing any surplus elements? Is there a better way to handle the situation? What are the limitations of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I haven't used bpf_seq_write in anger, but my understanding is it works just like perf and ringbuf maps, so from my point of view, the same concepts apply. Push data from bpf to user space in whatever format you like. In practice, this often means you either send fixed-length messages using a shared struct definition between Go/C to keep the decoding operation simple. Or, you devise your own little TLV-based protocol, or literally anything else you can come up with that best fits your use case.
https://nakryiko.com/posts/bpf-core-reference-guide/#reading-bitfields-and-integers-of-varying-sizes may be of interest here. You'll want to lean on CO-RE as much as you can. See https://docs.ebpf.io/concepts/core and related pages (there are doc pages for individual CO-RE macros), the post on Andrii's blog hasn't really evolved over time iirc.
Depends what you mean by limitations; from bpf side it's almost exactly like writing to a file or socket in a typical user space application. You can make multiple writes per read() in user space, so you can combine input from multiple sources, for example a header you allocated on the bpf stack, followed by the bitmask, followed by some more data you've generated in the program. Instead of plumbing through the whole cpumask to user space, I'd suggest putting as much logic into the bpf program itself. (I assume there's some info you want to extract from the cpumask) Only communicate the result of the computation to user space to avoid copying and decoding as much as possible. |
Beta Was this translation helpful? Give feedback.
I haven't used bpf_seq_write in anger, but my understanding is it works just like perf and ringbuf maps, so from my point of view, the same concepts apply. Push data from bpf to user space in whatever format you like. In practice, this often means you either send fixed-length messages using a shared struct definition between Go/C to keep the decoding operation simple. Or, you devise your own little TLV-based protocol,…