tools/testing/selftests/bpf/prog_tests/find_vma.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/find_vma.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/find_vma.c- Extension
.c- Size
- 3163 bytes
- Lines
- 128
- 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.hsys/types.hunistd.hfind_vma.skel.hfind_vma_fail1.skel.hfind_vma_fail2.skel.h
Detected Declarations
function test_and_reset_skelfunction open_pefunction find_vma_pe_conditionfunction test_find_vma_pefunction test_find_vma_kprobefunction test_illegal_write_vmafunction test_illegal_write_taskfunction serial_test_find_vma
Annotated Snippet
if (pfd == -ENOENT || pfd == -EOPNOTSUPP) {
printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n", __func__);
test__skip();
goto cleanup;
}
if (!ASSERT_GE(pfd, 0, "perf_event_open"))
goto cleanup;
}
link = bpf_program__attach_perf_event(skel->progs.handle_pe, pfd);
if (!ASSERT_OK_PTR(link, "attach_perf_event"))
goto cleanup;
for (i = 0; i < one_bn && find_vma_pe_condition(skel); ++i)
++j;
test_and_reset_skel(skel, -EBUSY /* in nmi, irq_work is busy */, i == one_bn);
cleanup:
bpf_link__destroy(link);
close(pfd);
}
static void test_find_vma_kprobe(struct find_vma *skel)
{
int err;
err = find_vma__attach(skel);
if (!ASSERT_OK(err, "get_branch_snapshot__attach"))
return;
getpgid(skel->bss->target_pid);
test_and_reset_skel(skel, -ENOENT /* could not find vma for ptr 0 */, true);
}
static void test_illegal_write_vma(void)
{
struct find_vma_fail1 *skel;
skel = find_vma_fail1__open_and_load();
if (!ASSERT_ERR_PTR(skel, "find_vma_fail1__open_and_load"))
find_vma_fail1__destroy(skel);
}
static void test_illegal_write_task(void)
{
struct find_vma_fail2 *skel;
skel = find_vma_fail2__open_and_load();
if (!ASSERT_ERR_PTR(skel, "find_vma_fail2__open_and_load"))
find_vma_fail2__destroy(skel);
}
void serial_test_find_vma(void)
{
struct find_vma *skel;
skel = find_vma__open_and_load();
if (!ASSERT_OK_PTR(skel, "find_vma__open_and_load"))
return;
skel->bss->target_pid = getpid();
skel->bss->addr = (__u64)(uintptr_t)test_find_vma_pe;
test_find_vma_pe(skel);
test_find_vma_kprobe(skel);
find_vma__destroy(skel);
test_illegal_write_vma();
test_illegal_write_task();
}
Annotation
- Immediate include surface: `test_progs.h`, `sys/types.h`, `unistd.h`, `find_vma.skel.h`, `find_vma_fail1.skel.h`, `find_vma_fail2.skel.h`.
- Detected declarations: `function test_and_reset_skel`, `function open_pe`, `function find_vma_pe_condition`, `function test_find_vma_pe`, `function test_find_vma_kprobe`, `function test_illegal_write_vma`, `function test_illegal_write_task`, `function serial_test_find_vma`.
- 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.