tools/testing/selftests/bpf/progs/verifier_arena_large.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_arena_large.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_arena_large.c- Extension
.c- Size
- 7237 bytes
- Lines
- 317
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hbpf/bpf_helpers.hbpf/bpf_tracing.hbpf_misc.hbpf_experimental.hbpf_arena_common.h
Detected Declarations
function __retvalfunction __retvalfunction __retvalfunction __retvalfunction alloc_pagesfunction __retvalfunction __retval
Annotated Snippet
if (first_pass) {
/* Pages must be allocated sequentially */
if (pg_idx != i)
return step + 100;
} else {
/* Allocator must fill into gaps */
if (pg_idx >= max_idx || (pg_idx & 1))
return step + 200;
}
*pg = pg_idx;
page[pg_idx] = pg;
cond_break;
}
return 0;
}
SEC("syscall")
__success __retval(0)
int big_alloc2(void *ctx)
{
__u8 __arena *pg;
int i, err;
base = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0);
if (!base)
return 1;
bpf_arena_free_pages(&arena, (void __arena *)base, 1);
err = alloc_pages(PAGE_CNT, 1, true, PAGE_CNT, 2);
if (err)
return err;
/* Clear all even pages */
for (i = 0; i < PAGE_CNT; i += 2) {
pg = page[i];
if (*pg != i)
return 3;
bpf_arena_free_pages(&arena, (void __arena *)pg, 1);
page[i] = NULL;
cond_break;
}
/* Allocate into freed gaps */
err = alloc_pages(PAGE_CNT / 2, 1, false, PAGE_CNT, 4);
if (err)
return err;
/* Free pairs of pages */
for (i = 0; i < PAGE_CNT; i += 4) {
pg = page[i];
if (*pg != i)
return 5;
bpf_arena_free_pages(&arena, (void __arena *)pg, 2);
page[i] = NULL;
barrier();
page[i + 1] = NULL;
cond_break;
}
/* Allocate 2 pages at a time into freed gaps */
err = alloc_pages(PAGE_CNT / 4, 2, false, PAGE_CNT, 6);
if (err)
return err;
/* Check pages without freeing */
for (i = 0; i < PAGE_CNT; i += 2) {
pg = page[i];
if (*pg != i)
return 7;
cond_break;
}
pg = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0);
if (!pg)
return 8;
/*
* The first PAGE_CNT pages are occupied. The new page
* must be above.
*/
if ((pg - base) / PAGE_SIZE < PAGE_CNT)
return 9;
return 0;
}
SEC("socket")
__success __retval(0)
int big_alloc3(void *ctx)
{
#if defined(__BPF_FEATURE_ADDR_SPACE_CAST)
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf_misc.h`, `bpf_experimental.h`, `bpf_arena_common.h`.
- Detected declarations: `function __retval`, `function __retval`, `function __retval`, `function __retval`, `function alloc_pages`, `function __retval`, `function __retval`.
- 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.