tools/testing/selftests/bpf/prog_tests/fexit_stress.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/fexit_stress.c- Extension
.c- Size
- 1556 bytes
- Lines
- 61
- 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_util.h
Detected Declarations
function serial_test_fexit_stress
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2019 Facebook */
#include <test_progs.h>
#include "bpf_util.h"
void serial_test_fexit_stress(void)
{
int bpf_max_tramp_links, err, i;
int *fd, *fexit_fd, *link_fd;
bpf_max_tramp_links = get_bpf_max_tramp_links();
if (!ASSERT_GE(bpf_max_tramp_links, 1, "bpf_max_tramp_links"))
return;
fd = calloc(bpf_max_tramp_links * 2, sizeof(*fd));
if (!ASSERT_OK_PTR(fd, "fd"))
return;
fexit_fd = fd;
link_fd = fd + bpf_max_tramp_links;
const struct bpf_insn trace_program[] = {
BPF_MOV64_IMM(BPF_REG_0, 0),
BPF_EXIT_INSN(),
};
LIBBPF_OPTS(bpf_prog_load_opts, trace_opts,
.expected_attach_type = BPF_TRACE_FEXIT,
);
LIBBPF_OPTS(bpf_test_run_opts, topts);
err = libbpf_find_vmlinux_btf_id("bpf_fentry_test1",
trace_opts.expected_attach_type);
if (!ASSERT_GT(err, 0, "find_vmlinux_btf_id"))
goto out;
trace_opts.attach_btf_id = err;
for (i = 0; i < bpf_max_tramp_links; i++) {
fexit_fd[i] = bpf_prog_load(BPF_PROG_TYPE_TRACING, NULL, "GPL",
trace_program,
ARRAY_SIZE(trace_program),
&trace_opts);
if (!ASSERT_GE(fexit_fd[i], 0, "fexit load"))
goto out;
link_fd[i] = bpf_link_create(fexit_fd[i], 0, BPF_TRACE_FEXIT, NULL);
if (!ASSERT_GE(link_fd[i], 0, "fexit attach"))
goto out;
}
err = bpf_prog_test_run_opts(fexit_fd[0], &topts);
ASSERT_OK(err, "bpf_prog_test_run_opts");
out:
for (i = 0; i < bpf_max_tramp_links; i++) {
if (link_fd[i] > 0)
close(link_fd[i]);
if (fexit_fd[i] > 0)
close(fexit_fd[i]);
}
free(fd);
}
Annotation
- Immediate include surface: `test_progs.h`, `bpf_util.h`.
- Detected declarations: `function serial_test_fexit_stress`.
- 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.