* Repo for tips / tricks / common code?
@ 2023-07-18 16:15 Barret Rhoden
2023-07-18 22:17 ` Alexei Starovoitov
0 siblings, 1 reply; 3+ messages in thread
From: Barret Rhoden @ 2023-07-18 16:15 UTC (permalink / raw)
To: bpf
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.
Thanks,
Barret
[1] https://github.com/google/ghost-userspace/blob/main/lib/queue.bpf.h
[2]
https://lpc.events/event/16/contributions/1365/attachments/986/1912/lpc22-ebpf-kernel-scheduling-with-ghost.pdf
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Repo for tips / tricks / common code?
2023-07-18 16:15 Repo for tips / tricks / common code? Barret Rhoden
@ 2023-07-18 22:17 ` Alexei Starovoitov
2023-07-19 9:51 ` Donald Hunter
0 siblings, 1 reply; 3+ messages in thread
From: Alexei Starovoitov @ 2023-07-18 22:17 UTC (permalink / raw)
To: Barret Rhoden, Daniel Borkmann, Andrii Nakryiko; +Cc: bpf
On Tue, Jul 18, 2023 at 9:15 AM Barret Rhoden <brho@google.com> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Repo for tips / tricks / common code?
2023-07-18 22:17 ` Alexei Starovoitov
@ 2023-07-19 9:51 ` Donald Hunter
0 siblings, 0 replies; 3+ messages in thread
From: Donald Hunter @ 2023-07-19 9:51 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: Barret Rhoden, Daniel Borkmann, Andrii Nakryiko, bpf
Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:
> On Tue, Jul 18, 2023 at 9:15 AM Barret Rhoden <brho@google.com> 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?
Or potentially:
https://github.com/xdp-project/bpf-examples
>
>> Thanks,
>> Barret
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-19 10:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18 16:15 Repo for tips / tricks / common code? Barret Rhoden
2023-07-18 22:17 ` Alexei Starovoitov
2023-07-19 9:51 ` Donald Hunter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).