On Wed, Aug 24, 2022 at 1:03 PM Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> wrote: > > On Fri, 19 Aug 2022 at 23:42, Alexei Starovoitov > <alexei.starovoitov@xxxxxxxxx> wrote: > > > > From: Alexei Starovoitov <ast@xxxxxxxxxx> > > > > Introduce any context BPF specific memory allocator. > > > > Tracing BPF programs can attach to kprobe and fentry. Hence they > > run in unknown context where calling plain kmalloc() might not be safe. > > Front-end kmalloc() with per-cpu cache of free elements. > > Refill this cache asynchronously from irq_work. > > > > Major achievements enabled by bpf_mem_alloc: > > - Dynamically allocated hash maps used to be 10 times slower than fully preallocated. > > With bpf_mem_alloc and subsequent optimizations the speed of dynamic maps is equal to full prealloc. > > - Tracing bpf programs can use dynamically allocated hash maps. > > Potentially saving lots of memory. Typical hash map is sparsely populated. > > - Sleepable bpf programs can used dynamically allocated hash maps. > > > > From my side, for the whole series: > Acked-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> Thanks a bunch for all the suggestions. Especially for ideas that led to rewrite of patch 1. It looks much simpler now. I've missed #include <asm/local.h> in the patch 1. In the respin I'm going to keep your Ack if you don't mind. Thanks!