Re: [PATCH v2 bpf-next 20/20] selftests/bpf: Convert simple page_frag allocator to per-cpu.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 9, 2024 at 11:06 PM Kumar Kartikeya Dwivedi
<memxor@xxxxxxxxx> wrote:
>
> On Fri, 9 Feb 2024 at 05:07, Alexei Starovoitov
> <alexei.starovoitov@xxxxxxxxx> wrote:
> >
> > From: Alexei Starovoitov <ast@xxxxxxxxxx>
> >
> > Convert simple page_frag allocator to per-cpu page_frag to further stress test
> > a combination of __arena global and static variables and alloc/free from arena.
> >
> > Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
> > ---
>
> I know this organically grew from a toy implementation, but since
> people will most likely be looking at selftests as usage examples, it
> might be better to expose bpf_preempt_disable/enable and use it in the
> case of per-CPU page_frag allocator? No need to block on this, can be
> added on top later.
>
> The kfunc is useful on its own for writing safe per-CPU data
> structures or other memory allocators like bpf_ma on top of arenas.
> It is also necessary as a building block for writing spin locks
> natively in BPF on top of the arena map which we may add later.
> I have a patch lying around for this, verifier plumbing is mostly the
> same as rcu_read_lock.
> I can send it out with tests, or otherwise if you want to add it to
> this series, you go ahead.

Please send it.
I think the verifier checks need to be more tight than rcu_read_lock.
preempt_enable/disable should be as strict as bpf_spin_lock.

The plan is to add bpf_arena_spin_lock() in the follow up and use
it in this bpf page_frag allocator to make it work properly out of
tracing context.
I'm not sure yet whether bpf_preemp_disable() will be sufficient.

And in the long run the idea is to convert all these bpf_arena*
facilities into libc equivalent.
Probably not part of libbpf, but some new package. name tbd.





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux