tools/testing/selftests/bpf/prog_tests/pro_epilogue.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/pro_epilogue.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/pro_epilogue.c- Extension
.c- Size
- 1834 bytes
- Lines
- 63
- 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.hpro_epilogue.skel.hepilogue_tailcall.skel.hpro_epilogue_goto_start.skel.hepilogue_exit.skel.hpro_epilogue_with_kfunc.skel.h
Detected Declarations
struct st_ops_argsfunction test_tailcallfunction test_pro_epilogue
Annotated Snippet
struct st_ops_args {
__u64 a;
};
static void test_tailcall(void)
{
LIBBPF_OPTS(bpf_test_run_opts, topts);
struct epilogue_tailcall *skel;
struct st_ops_args args;
int err, prog_fd;
skel = epilogue_tailcall__open_and_load();
if (!ASSERT_OK_PTR(skel, "epilogue_tailcall__open_and_load"))
return;
topts.ctx_in = &args;
topts.ctx_size_in = sizeof(args);
skel->links.epilogue_tailcall =
bpf_map__attach_struct_ops(skel->maps.epilogue_tailcall);
if (!ASSERT_OK_PTR(skel->links.epilogue_tailcall, "attach_struct_ops"))
goto done;
/* Both test_epilogue_tailcall and test_epilogue_subprog are
* patched with epilogue. When syscall_epilogue_tailcall()
* is run, test_epilogue_tailcall() is triggered.
* It executes a tail call and control is transferred to
* test_epilogue_subprog(). Only test_epilogue_subprog()
* does args->a += 1, thus final args.a value of 10001
* guarantees that only the epilogue of the
* test_epilogue_subprog is executed.
*/
memset(&args, 0, sizeof(args));
prog_fd = bpf_program__fd(skel->progs.syscall_epilogue_tailcall);
err = bpf_prog_test_run_opts(prog_fd, &topts);
ASSERT_OK(err, "bpf_prog_test_run_opts");
ASSERT_EQ(args.a, 10001, "args.a");
ASSERT_EQ(topts.retval, 10001 * 2, "topts.retval");
done:
epilogue_tailcall__destroy(skel);
}
void test_pro_epilogue(void)
{
RUN_TESTS(pro_epilogue);
RUN_TESTS(pro_epilogue_goto_start);
RUN_TESTS(epilogue_exit);
RUN_TESTS(pro_epilogue_with_kfunc);
if (test__start_subtest("tailcall"))
test_tailcall();
}
Annotation
- Immediate include surface: `test_progs.h`, `pro_epilogue.skel.h`, `epilogue_tailcall.skel.h`, `pro_epilogue_goto_start.skel.h`, `epilogue_exit.skel.h`, `pro_epilogue_with_kfunc.skel.h`.
- Detected declarations: `struct st_ops_args`, `function test_tailcall`, `function test_pro_epilogue`.
- 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.