mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 10:31:33 -04:00
selftests/bpf: libarena: Clean up allocation state before buddy tests
Summary: The buddy allocator requires the global BPF buddy allocator
to not be already initialized. However, the test currently merely resets
the allocator before the buddy tests instead of destroying it, and the
test worked because the buddy test happened to run first. Properly
destroy the allocator instead of resetting it.
Fixes: b1487dc1b1 ("selftests/bpf: Add selftests for libarena buddy allocator")
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
Acked-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Link: https://lore.kernel.org/bpf/20260706181730.21731-4-emil@etsalapatis.com
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
This commit is contained in:
committed by
Kumar Kartikeya Dwivedi
parent
857071efc3
commit
14c2b770d1
@@ -37,6 +37,12 @@ __weak int arena_buddy_reset(void)
|
||||
return buddy_init(&buddy);
|
||||
}
|
||||
|
||||
SEC("syscall")
|
||||
__weak int arena_buddy_destroy(void)
|
||||
{
|
||||
return buddy_destroy(&buddy);
|
||||
}
|
||||
|
||||
__weak void __arena *arena_malloc(size_t size)
|
||||
{
|
||||
return buddy_alloc(&buddy, size);
|
||||
|
||||
@@ -15,7 +15,12 @@ static void run_libarena_test(struct libarena *skel, struct bpf_program *prog,
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!strstr(name, "test_buddy")) {
|
||||
if (strstr(name, "test_buddy")) {
|
||||
/* Buddy tests initialize the allocator directly. */
|
||||
ret = libarena_run_prog(bpf_program__fd(skel->progs.arena_buddy_destroy));
|
||||
if (!ASSERT_OK(ret, "arena_buddy_destroy"))
|
||||
return;
|
||||
} else {
|
||||
ret = libarena_run_prog(bpf_program__fd(skel->progs.arena_buddy_reset));
|
||||
if (!ASSERT_OK(ret, "arena_buddy_reset"))
|
||||
return;
|
||||
@@ -24,7 +29,6 @@ static void run_libarena_test(struct libarena *skel, struct bpf_program *prog,
|
||||
ret = libarena_run_prog(bpf_program__fd(prog));
|
||||
|
||||
ASSERT_OK(ret, name);
|
||||
|
||||
}
|
||||
|
||||
static void *run_libarena_parallel_prog(void *arg)
|
||||
|
||||
@@ -17,7 +17,12 @@ static void run_libarena_asan_test(struct libarena_asan *skel,
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!strstr(name, "test_buddy")) {
|
||||
if (strstr(name, "test_buddy")) {
|
||||
/* Buddy tests initialize the allocator directly. */
|
||||
ret = libarena_run_prog(bpf_program__fd(skel->progs.arena_buddy_destroy));
|
||||
if (!ASSERT_OK(ret, "arena_buddy_destroy"))
|
||||
return;
|
||||
} else {
|
||||
ret = libarena_run_prog(bpf_program__fd(skel->progs.arena_buddy_reset));
|
||||
if (!ASSERT_OK(ret, "arena_buddy_reset"))
|
||||
return;
|
||||
@@ -90,4 +95,3 @@ void test_libarena_asan(void)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user