selftests/bpf: Test bpf_kptr_xchg stashing of bpf_rb_root
Subsystems (3)
PATCH 1/1 selftests/bpf: Test bpf_kptr_xchg stashing of bpf_rb_root
There was some confusion amongst Meta sched_ext folks regarding whether stashing bpf_rb_root - the tree itself, rather than a single node - was supported. This patch adds a small test which demonstrates this
functionality: a local kptr with rb_root is created, a node is created and added to the tree, then the tree is kptr_xchg'd into a mapval.
--- .../bpf/prog_tests/local_kptr_stash.c | 23 ++++++++ .../selftests/bpf/progs/local_kptr_stash.c | 53 +++++++++++++++++++ 2 files changed, 76 insertions(+)
tools/testing/selftests/bpf/prog_tests/local_kptr_stash.c +23 -0
@@ -48,6 +48,27 @@ static void test_local_kptr_stash_plain(void)local_kptr_stash__destroy (skel); } +static void test_local_kptr_stash_local_with_root (void ) +{ +LIBBPF_OPTS (bpf_test_run_opts, opts, + .data_in = &pkt_v4, + .data_size_in = sizeof(pkt_v4), + .repeat = 1, + ); +struct local_kptr_stash *skel; +int ret; + + skel =local_kptr_stash__open_and_load (); +if (!ASSERT_OK_PTR (skel,"local_kptr_stash__open_and_load" )) +return ; + + ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.stash_local_with_root), &opts); +ASSERT_OK (ret,"local_kptr_stash_add_local_with_root run" ); +ASSERT_OK (opts.retval,"local_kptr_stash_add_local_with_root retval" ); + +local_kptr_stash__destroy (skel); +} +static void test_local_kptr_stash_unstash (void ) { LIBBPF_OPTS(bpf_test_run_opts, opts,
@@ -115,6 +136,8 @@ void test_local_kptr_stash(void)test_local_kptr_stash_simple ();if (test__start_subtest ("local_kptr_stash_plain" ))test_local_kptr_stash_plain (); +if (test__start_subtest ("local_kptr_stash_local_with_root" )) +test_local_kptr_stash_local_with_root ();if (test__start_subtest ("local_kptr_stash_unstash" ))test_local_kptr_stash_unstash ();if (test__start_subtest ("refcount_acquire_without_unstash" ))
tools/testing/selftests/bpf/progs/local_kptr_stash.c +53 -0
76 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 7 lines · Dave Marchevsky
There was some confusion amongst Meta
sched_extfolks regarding whether stashingbpf_rb_root- the tree itself, rather than a single node - was supported. This patch adds a small test which demonstrates this
functionality: a local kptr withrb_rootis created, a node is created and added to the tree, then the tree is kptr_xchg'd into a mapval.Signed-off-by Dave Marchevsky <[email protected]>
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 9 lines · On Mon, 4 Dec 2023 13:17:22 -0800 you wrote:
There was some confusion amongst Meta
sched_extfolks regarding whether stashingbpf_rb_root- the tree itself, rather than a single node - was supported. This patch adds a small test which demonstrates this
functionality: a local kptr withrb_rootis created, a node is created and added to the tree, then the tree is kptr_xchg'd into a mapval.Signed-off-by Dave Marchevsky <[email protected]>[...]
Here is the summary with links:
- [v1,bpf-next] selftests/bpf: Test bpf_kptr_xchg stashing of bpf_rb_root
https://git.kernel.org/bpf/bpf-next/c/1b4c7e20bfd6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html