tools/testing/selftests/bpf/progs/cpumask_common.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/cpumask_common.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/cpumask_common.h- Extension
.h- Size
- 4228 bytes
- Lines
- 130
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.hstdbool.h
Detected Declarations
struct __cpumask_map_valuestruct array_mapfunction cpumask_map_insert
Annotated Snippet
struct __cpumask_map_value {
struct bpf_cpumask __kptr * cpumask;
};
struct array_map {
__uint(type, BPF_MAP_TYPE_ARRAY);
__type(key, int);
__type(value, struct __cpumask_map_value);
__uint(max_entries, 1);
} __cpumask_map SEC(".maps");
struct bpf_cpumask *bpf_cpumask_create(void) __ksym __weak;
void bpf_cpumask_release(struct bpf_cpumask *cpumask) __ksym __weak;
struct bpf_cpumask *bpf_cpumask_acquire(struct bpf_cpumask *cpumask) __ksym __weak;
u32 bpf_cpumask_first(const struct cpumask *cpumask) __ksym __weak;
u32 bpf_cpumask_first_zero(const struct cpumask *cpumask) __ksym __weak;
u32 bpf_cpumask_first_and(const struct cpumask *src1,
const struct cpumask *src2) __ksym __weak;
void bpf_cpumask_set_cpu(u32 cpu, struct bpf_cpumask *cpumask) __ksym __weak;
void bpf_cpumask_clear_cpu(u32 cpu, struct bpf_cpumask *cpumask) __ksym __weak;
bool bpf_cpumask_test_cpu(u32 cpu, const struct cpumask *cpumask) __ksym __weak;
bool bpf_cpumask_test_and_set_cpu(u32 cpu, struct bpf_cpumask *cpumask) __ksym __weak;
bool bpf_cpumask_test_and_clear_cpu(u32 cpu, struct bpf_cpumask *cpumask) __ksym __weak;
void bpf_cpumask_setall(struct bpf_cpumask *cpumask) __ksym __weak;
void bpf_cpumask_clear(struct bpf_cpumask *cpumask) __ksym __weak;
bool bpf_cpumask_and(struct bpf_cpumask *cpumask,
const struct cpumask *src1,
const struct cpumask *src2) __ksym __weak;
void bpf_cpumask_or(struct bpf_cpumask *cpumask,
const struct cpumask *src1,
const struct cpumask *src2) __ksym __weak;
void bpf_cpumask_xor(struct bpf_cpumask *cpumask,
const struct cpumask *src1,
const struct cpumask *src2) __ksym __weak;
bool bpf_cpumask_equal(const struct cpumask *src1, const struct cpumask *src2) __ksym __weak;
bool bpf_cpumask_intersects(const struct cpumask *src1, const struct cpumask *src2) __ksym __weak;
bool bpf_cpumask_subset(const struct cpumask *src1, const struct cpumask *src2) __ksym __weak;
bool bpf_cpumask_empty(const struct cpumask *cpumask) __ksym __weak;
bool bpf_cpumask_full(const struct cpumask *cpumask) __ksym __weak;
void bpf_cpumask_copy(struct bpf_cpumask *dst, const struct cpumask *src) __ksym __weak;
u32 bpf_cpumask_any_distribute(const struct cpumask *src) __ksym __weak;
u32 bpf_cpumask_any_and_distribute(const struct cpumask *src1,
const struct cpumask *src2) __ksym __weak;
u32 bpf_cpumask_weight(const struct cpumask *cpumask) __ksym __weak;
int bpf_cpumask_populate(struct cpumask *cpumask, void *src, size_t src__sz) __ksym __weak;
void bpf_rcu_read_lock(void) __ksym __weak;
void bpf_rcu_read_unlock(void) __ksym __weak;
static inline const struct cpumask *cast(struct bpf_cpumask *cpumask)
{
return (const struct cpumask *)cpumask;
}
static inline struct bpf_cpumask *create_cpumask(void)
{
struct bpf_cpumask *cpumask;
cpumask = bpf_cpumask_create();
if (!cpumask) {
err = 1;
return NULL;
}
if (!bpf_cpumask_empty(cast(cpumask))) {
err = 2;
bpf_cpumask_release(cpumask);
return NULL;
}
return cpumask;
}
static inline struct __cpumask_map_value *cpumask_map_value_lookup(void)
{
u32 key = 0;
return bpf_map_lookup_elem(&__cpumask_map, &key);
}
static inline int cpumask_map_insert(struct bpf_cpumask *mask)
{
struct __cpumask_map_value local, *v;
long status;
struct bpf_cpumask *old;
u32 key = 0;
local.cpumask = NULL;
status = bpf_map_update_elem(&__cpumask_map, &key, &local, 0);
if (status) {
Annotation
- Immediate include surface: `errno.h`, `stdbool.h`.
- Detected declarations: `struct __cpumask_map_value`, `struct array_map`, `function cpumask_map_insert`.
- 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.