diff options
| author | Kui-Feng Lee <[email protected]> | 2024-02-24 14:34:18 -0800 | 
|---|---|---|
| committer | Martin KaFai Lau <[email protected]> | 2024-03-04 14:09:24 -0800 | 
| commit | 93bc28d859e57f1a654d3b63600d14c85c5630a4 (patch) | |
| tree | c3e977ac6a70cf40b315f9d84c42ad51b5d35799 /tools/testing/selftests/bpf/prog_tests | |
| parent | 187e2af05abe6bf80581490239c449456627d17a (diff) | |
selftests/bpf: Test struct_ops maps with a large number of struct_ops program.
Create and load a struct_ops map with a large number of struct_ops
programs to generate trampolines taking a size over multiple pages. The
map includes 40 programs. Their trampolines takes 6.6k+, more than 1.5
pages, on x86.
Signed-off-by: Kui-Feng Lee <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin KaFai Lau <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/test_struct_ops_multi_pages.c | 30 | 
1 files changed, 30 insertions, 0 deletions
| diff --git a/tools/testing/selftests/bpf/prog_tests/test_struct_ops_multi_pages.c b/tools/testing/selftests/bpf/prog_tests/test_struct_ops_multi_pages.c new file mode 100644 index 000000000000..645d32b5160c --- /dev/null +++ b/tools/testing/selftests/bpf/prog_tests/test_struct_ops_multi_pages.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ +#include <test_progs.h> + +#include "struct_ops_multi_pages.skel.h" + +static void do_struct_ops_multi_pages(void) +{ +	struct struct_ops_multi_pages *skel; +	struct bpf_link *link; + +	/* The size of all trampolines of skel->maps.multi_pages should be +	 * over 1 page (at least for x86). +	 */ +	skel = struct_ops_multi_pages__open_and_load(); +	if (!ASSERT_OK_PTR(skel, "struct_ops_multi_pages_open_and_load")) +		return; + +	link = bpf_map__attach_struct_ops(skel->maps.multi_pages); +	ASSERT_OK_PTR(link, "attach_multi_pages"); + +	bpf_link__destroy(link); +	struct_ops_multi_pages__destroy(skel); +} + +void test_struct_ops_multi_pages(void) +{ +	if (test__start_subtest("multi_pages")) +		do_struct_ops_multi_pages(); +} |