tools/testing/selftests/bpf/libarena/include/libarena/userspace.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/libarena/include/libarena/userspace.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h- Extension
.h- Size
- 2791 bytes
- Lines
- 139
- 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
errno.hstdlib.hunistd.hsys/mman.hbpf/libbpf.hbpf/bpf.h
Detected Declarations
function libarena_run_progfunction libarena_is_test_progfunction libarena_is_asan_test_progfunction libarena_is_parallel_test_progfunction libarena_run_prog_argsfunction libarena_get_arena_basefunction libarena_get_globals_pagesfunction libarena_asan_init
Annotated Snippet
// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause
/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
#pragma once
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <bpf/libbpf.h>
#include <bpf/bpf.h>
static inline int libarena_run_prog(int prog_fd)
{
LIBBPF_OPTS(bpf_test_run_opts, opts);
int ret;
ret = bpf_prog_test_run_opts(prog_fd, &opts);
if (ret)
return ret;
return opts.retval;
}
static inline bool libarena_is_test_prog(const char *name)
{
return strstr(name, "test_") == name;
}
static inline bool libarena_is_asan_test_prog(const char *name)
{
return strstr(name, "asan_test") == name;
}
static inline bool libarena_is_parallel_test_prog(const char *name)
{
return strstr(name, "parallel_test") == name;
}
static inline int libarena_run_prog_args(int prog_fd, void *args, size_t argsize)
{
LIBBPF_OPTS(bpf_test_run_opts, opts);
int ret;
opts.ctx_in = args;
opts.ctx_size_in = argsize;
ret = bpf_prog_test_run_opts(prog_fd, &opts);
return ret ?: opts.retval;
}
static inline int libarena_get_arena_base(int arena_get_info_fd,
void **arena_base)
{
LIBBPF_OPTS(bpf_test_run_opts, opts);
struct arena_get_info_args args = { .arena_base = NULL };
int ret;
opts.ctx_in = &args;
opts.ctx_size_in = sizeof(args);
ret = bpf_prog_test_run_opts(arena_get_info_fd, &opts);
if (ret)
return ret;
if (opts.retval)
return opts.retval;
*arena_base = args.arena_base;
return 0;
}
static inline int libarena_get_globals_pages(int arena_get_globals_fd,
size_t arena_all_pages,
u64 *globals_pages)
{
size_t pgsize = sysconf(_SC_PAGESIZE);
void *arena_base;
ssize_t i;
u8 *vec;
int ret;
ret = libarena_get_arena_base(arena_get_globals_fd, &arena_base);
if (ret)
return ret;
if (!arena_base)
return -EINVAL;
Annotation
- Immediate include surface: `errno.h`, `stdlib.h`, `unistd.h`, `sys/mman.h`, `bpf/libbpf.h`, `bpf/bpf.h`.
- Detected declarations: `function libarena_run_prog`, `function libarena_is_test_prog`, `function libarena_is_asan_test_prog`, `function libarena_is_parallel_test_prog`, `function libarena_run_prog_args`, `function libarena_get_arena_base`, `function libarena_get_globals_pages`, `function libarena_asan_init`.
- 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.