tools/testing/selftests/bpf/progs/verifier_arena.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_arena.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_arena.c- Extension
.c- Size
- 14056 bytes
- Lines
- 678
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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.herrno.hbpf/bpf_helpers.hbpf/bpf_tracing.hbpf_misc.hbpf_experimental.hbpf_arena_common.h
Detected Declarations
struct bpf_arena___lfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __log_levelfunction __msgfunction __msgfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retvalfunction __retval
Annotated Snippet
struct bpf_arena___l {
struct bpf_map map;
} __attribute__((preserve_access_index));
SEC("socket")
__success __retval(0) __log_level(2)
int basic_alloc3_nosleep(void *ctx)
{
struct bpf_arena___l *ar = (struct bpf_arena___l *)&arena;
volatile char __arena *pages;
pages = bpf_arena_alloc_pages(&ar->map, NULL, ar->map.max_entries, NUMA_NO_NODE, 0);
if (!pages)
return 1;
return 0;
}
SEC("syscall")
__success __retval(0) __log_level(2)
int basic_alloc3(void *ctx)
{
struct bpf_arena___l *ar = (struct bpf_arena___l *)&arena;
volatile char __arena *pages;
pages = bpf_arena_alloc_pages(&ar->map, NULL, ar->map.max_entries, NUMA_NO_NODE, 0);
if (!pages)
return 1;
return 0;
}
SEC("socket")
__success __retval(0)
int basic_reserve1_nosleep(void *ctx)
{
#if defined(__BPF_FEATURE_ADDR_SPACE_CAST)
char __arena *page;
int ret;
page = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0);
if (!page)
return 1;
page += __PAGE_SIZE;
/* Reserve the second page */
ret = bpf_arena_reserve_pages(&arena, page, 1);
if (ret)
return 2;
/* Try to explicitly allocate the reserved page. */
page = bpf_arena_alloc_pages(&arena, page, 1, NUMA_NO_NODE, 0);
if (page)
return 3;
/* Try to implicitly allocate the page (since there's only 2 of them). */
page = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0);
if (page)
return 4;
#endif
return 0;
}
SEC("syscall")
__success __retval(0)
int basic_reserve1(void *ctx)
{
#if defined(__BPF_FEATURE_ADDR_SPACE_CAST)
char __arena *page;
int ret;
page = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0);
if (!page)
return 1;
page += __PAGE_SIZE;
/* Reserve the second page */
ret = bpf_arena_reserve_pages(&arena, page, 1);
if (ret)
return 2;
/* Try to explicitly allocate the reserved page. */
page = bpf_arena_alloc_pages(&arena, page, 1, NUMA_NO_NODE, 0);
if (page)
return 3;
/* Try to implicitly allocate the page (since there's only 2 of them). */
page = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0);
if (page)
return 4;
Annotation
- Immediate include surface: `vmlinux.h`, `errno.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf_misc.h`, `bpf_experimental.h`, `bpf_arena_common.h`.
- Detected declarations: `struct bpf_arena___l`, `function __retval`, `function __retval`, `function __retval`, `function __retval`, `function __retval`, `function __retval`, `function __retval`, `function __retval`, `function __retval`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.