tools/testing/selftests/bpf/prog_tests/tracing_multi.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/tracing_multi.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/tracing_multi.c- Extension
.c- Size
- 25508 bytes
- Lines
- 961
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
test_progs.hbpf/btf.hsearch.hbpf/libbpf_internal.htracing_multi.skel.htracing_multi_module.skel.htracing_multi_intersect.skel.htracing_multi_session.skel.htracing_multi_fail.skel.htracing_multi_verifier.skel.htracing_multi_bench.skel.htracing_multi_rollback.skel.htrace_helpers.h
Detected Declarations
function get_random_funcsfunction comparefunction tdestroy_free_nopfunction tracing_multi_test_runfunction test_skel_apifunction test_link_api_patternfunction test_link_api_idsfunction test_module_skel_apifunction test_module_link_api_patternfunction test_module_link_api_idsfunction is_setfunction __test_intersectfunction test_intersectfunction test_sessionfunction test_attach_api_failsfunction serial_test_tracing_multi_bench_attachfunction tracing_multi_rollback_runfunction test_rollback_putfunction fillers_cleanupfunction test_rollback_unlinkfunction serial_test_tracing_multi_attach_rollbackfunction test_tracing_multi_test
Annotated Snippet
if (!ASSERT_OK_PTR(btf, "btf__load_module_btf")) {
btf__free(vmlinux_btf);
return NULL;
}
}
ids = calloc(funcs_cnt, sizeof(ids[0]));
if (!ids)
goto out;
/*
* We sort function names by name and search them
* below for each function.
*/
for (i = 0; i < funcs_cnt; i++) {
if (!tsearch(&funcs[i], &root, compare)) {
ASSERT_FAIL("tsearch failed");
err = -1;
goto error;
}
}
nr = btf__type_cnt(btf);
for (type_id = 1; type_id < nr && cnt < funcs_cnt; type_id++) {
const struct btf_type *type;
const char *str, ***val;
unsigned int idx;
type = btf__type_by_id(btf, type_id);
if (!type) {
err = -1;
break;
}
if (BTF_INFO_KIND(type->info) != BTF_KIND_FUNC)
continue;
str = btf__name_by_offset(btf, type->name_off);
if (!str) {
err = -1;
break;
}
val = tfind(&str, &root, compare);
if (!val)
continue;
/*
* We keep pointer for each function name so we can get the original
* array index and have the resulting ids array matching the original
* function array.
*
* Doing it this way allow us to easily test the cookies support,
* because each cookie is attached to particular function/id.
*/
idx = *val - funcs;
ids[idx] = type_id;
cnt++;
}
error:
if (err) {
free(ids);
ids = NULL;
}
out:
tdestroy(root, tdestroy_free_nop);
btf__free(vmlinux_btf);
btf__free(btf);
return ids;
}
static void tracing_multi_test_run(struct tracing_multi *skel)
{
LIBBPF_OPTS(bpf_test_run_opts, topts);
int err, prog_fd;
prog_fd = bpf_program__fd(skel->progs.test_fentry);
err = bpf_prog_test_run_opts(prog_fd, &topts);
ASSERT_OK(err, "test_run");
/* extra +1 count for sleepable programs */
ASSERT_EQ(skel->bss->test_result_fentry, FUNCS_CNT + 1, "test_result_fentry");
ASSERT_EQ(skel->bss->test_result_fexit, FUNCS_CNT + 1, "test_result_fexit");
}
static void test_skel_api(void)
{
struct tracing_multi *skel;
Annotation
- Immediate include surface: `test_progs.h`, `bpf/btf.h`, `search.h`, `bpf/libbpf_internal.h`, `tracing_multi.skel.h`, `tracing_multi_module.skel.h`, `tracing_multi_intersect.skel.h`, `tracing_multi_session.skel.h`.
- Detected declarations: `function get_random_funcs`, `function compare`, `function tdestroy_free_nop`, `function tracing_multi_test_run`, `function test_skel_api`, `function test_link_api_pattern`, `function test_link_api_ids`, `function test_module_skel_api`, `function test_module_link_api_pattern`, `function test_module_link_api_ids`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.