On Tue, Jul 18, 2023 at 9:15 AM Barret Rhoden <brho@xxxxxxxxxx> wrote: > > Hi - > > Is there any interest in a repo or something for reusable BPF code bits? > I've got some stuff that I do in my programs that might be useful to > others, but not to the level of a full bpf helper. > > For instance, one technique I've developed is to have list-like data > structures for *mmappable* data that are e.g. per-cpu and per-task. > Internally, it's an Array map, and each element is identified by its > index in the array instead of by point. And the linked-list is built > with index integers instead of pointers. > > Anyway, that's just an example, and I imagine other people have their > own techniques. I've got the code sitting in an open-source repo > elsewhere, and had a couple people off-list ask me about it. I could > email it to the list, but it'd get lost in the noise. > > If you're curious about specifics, the linked list code is here [1], and > I briefly mentioned the data structures in my LPC 22 talk [2]. I've got > an AVL tree that works with this stuff too. I think github would be the best place for such code. https://github.com/libbpf/.../ maybe? > Thanks, > Barret > > > [1] https://github.com/google/ghost-userspace/blob/main/lib/queue.bpf.h btw, I'm working on adding 32-bit pointers to BPF, so such link lists, AVL or anything else will look more natural and will be mmap-able to user space as well. So bpf program can implement its own hash table or rbtree and user space can walk/modify it in parallel without crashing the kernel, but potentially 'segfaulting' bpf program. Still need to figure out a sane locking mechanism. > [2] > https://lpc.events/event/16/contributions/1365/attachments/986/1912/lpc22-ebpf-kernel-scheduling-with-ghost.pdf >