tools/testing/selftests/bpf/libarena/src/common.bpf.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/libarena/src/common.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/libarena/src/common.bpf.c- Extension
.c- Size
- 945 bytes
- Lines
- 53
- 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
libarena/common.hlibarena/asan.hlibarena/buddy.h
Detected Declarations
function arena_flsfunction arena_get_infofunction arena_alloc_reservefunction arena_buddy_resetfunction arena_free
Annotated Snippet
// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause
/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
#include <libarena/common.h>
#include <libarena/asan.h>
#include <libarena/buddy.h>
const volatile u32 zero = 0;
struct buddy __arena buddy;
int arena_fls(__u64 word)
{
if (!word)
return 0;
return 64 - __builtin_clzll(word);
}
SEC("syscall")
__weak int arena_get_info(struct arena_get_info_args *args)
{
args->arena_base = arena_base(&arena);
return 0;
}
SEC("syscall")
__weak int arena_alloc_reserve(struct arena_alloc_reserve_args *args)
{
return bpf_arena_reserve_pages(&arena, NULL, args->nr_pages);
}
SEC("syscall")
__weak int arena_buddy_reset(void)
{
buddy_destroy(&buddy);
return buddy_init(&buddy);
}
__weak void __arena *arena_malloc(size_t size)
{
return buddy_alloc(&buddy, size);
}
__weak void arena_free(void __arena *ptr)
{
buddy_free(&buddy, ptr);
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `libarena/common.h`, `libarena/asan.h`, `libarena/buddy.h`.
- Detected declarations: `function arena_fls`, `function arena_get_info`, `function arena_alloc_reserve`, `function arena_buddy_reset`, `function arena_free`.
- 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.