bpf: Add a hint to allocated objects.
authorAlexei Starovoitov <ast@kernel.org>
Thu, 6 Jul 2023 03:34:41 +0000 (20:34 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 12 Jul 2023 21:45:23 +0000 (23:45 +0200)
commit822fb26bdb55932d0635f43cc418d2004b19e358
tree56396c29343e4e62eae039ebddd869614d774e0d
parentd114dde245f9115b73756203b03a633a6fc1b36a
bpf: Add a hint to allocated objects.

To address OOM issue when one cpu is allocating and another cpu is freeing add
a target bpf_mem_cache hint to allocated objects and when local cpu free_llist
overflows free to that bpf_mem_cache. The hint addresses the OOM while
maintaining the same performance for common case when alloc/free are done on the
same cpu.

Note that do_call_rcu_ttrace() now has to check 'draining' flag in one more case,
since do_call_rcu_ttrace() is called not only for current cpu.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/bpf/20230706033447.54696-9-alexei.starovoitov@gmail.com
kernel/bpf/memalloc.c