On Fri, Sep 1, 2023 at 4:20 AM Hou Tao <houtao@xxxxxxxxxxxxxxx> wrote: > > From: Hou Tao <houtao1@xxxxxxxxxx> > > Hi, > > The patchset aims to fix the problem that bpf_mem_alloc() may return > NULL unexpectedly when multiple bpf_mem_alloc() are invoked concurrently > under process context and there is still free memory available. The > problem was found when doing stress test for qp-trie but the same > problem also exists for bpf_obj_new() as demonstrated in patch #3. > > As pointed out by Alexei, the patchset can only fix ENOMEM problem for > normal process context and can not fix the problem for irq-disabled > context or RT-enabled kernel. > > Patch #1 fixes the race between unit_alloc() and unit_alloc(). Patch #2 > fixes the race between unit_alloc() and unit_free(). And patch #3 adds Looks good, but I disagree that patch 1 and 2 are fixes. They're surely improvements to bpf_ma logic, but not bug fixes. They decrease the probability of returning NULL, but can never eliminate it. Async alloc behavior of bpf_ma cannot be "fixed". We can make further improvements to it. Like do synchronous kmalloc() when bpf_ma is used in sleepable or other safe context. Such future improvements will not be "fixes" either. So I've applied the set to bpf-next.