selftests/bpf: Add more test cases for bpf memory allocator
authorHou Tao <houtao1@huawei.com>
Fri, 20 Oct 2023 13:32:02 +0000 (21:32 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 20 Oct 2023 21:15:13 +0000 (14:15 -0700)
commitd440ba91ca4d3004709876779d40713a99e21f6a
treee00e8bcbaedd9a6bc3783abe6edcb71b3c2ac382
parente383a45902337356d9ccad797094a27c6b2150f9
selftests/bpf: Add more test cases for bpf memory allocator

Add the following 3 test cases for bpf memory allocator:
1) Do allocation in bpf program and free through map free
2) Do batch per-cpu allocation and per-cpu free in bpf program
3) Do per-cpu allocation in bpf program and free through map free

For per-cpu allocation, because per-cpu allocation can not refill timely
sometimes, so test 2) and test 3) consider it is OK for
bpf_percpu_obj_new_impl() to return NULL.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20231020133202.4043247-8-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/test_bpf_ma.c
tools/testing/selftests/bpf/progs/test_bpf_ma.c