tools/testing/selftests/bpf/progs/preempted_bpf_ma_op.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/preempted_bpf_ma_op.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/preempted_bpf_ma_op.c- Extension
.c- Size
- 1772 bytes
- Lines
- 107
- 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
vmlinux.hbpf/bpf_tracing.hbpf/bpf_helpers.hbpf_experimental.h
Detected Declarations
struct bin_datastruct map_valuefunction del_arrayfunction add_arrayfunction del_then_add_arrayfunction BPF_PROG2function BPF_PROG2function BPF_PROG2function BPF_PROG2
Annotated Snippet
struct bin_data {
char data[256];
struct bpf_spin_lock lock;
};
struct map_value {
struct bin_data __kptr * data;
};
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__type(key, int);
__type(value, struct map_value);
__uint(max_entries, 2048);
} array SEC(".maps");
char _license[] SEC("license") = "GPL";
bool nomem_err = false;
static int del_array(unsigned int i, int *from)
{
struct map_value *value;
struct bin_data *old;
value = bpf_map_lookup_elem(&array, from);
if (!value)
return 1;
old = bpf_kptr_xchg(&value->data, NULL);
if (old)
bpf_obj_drop(old);
(*from)++;
return 0;
}
static int add_array(unsigned int i, int *from)
{
struct bin_data *old, *new;
struct map_value *value;
value = bpf_map_lookup_elem(&array, from);
if (!value)
return 1;
new = bpf_obj_new(typeof(*new));
if (!new) {
nomem_err = true;
return 1;
}
old = bpf_kptr_xchg(&value->data, new);
if (old)
bpf_obj_drop(old);
(*from)++;
return 0;
}
static void del_then_add_array(int from)
{
int i;
i = from;
bpf_loop(512, del_array, &i, 0);
i = from;
bpf_loop(512, add_array, &i, 0);
}
SEC("fentry/bpf_fentry_test1")
int BPF_PROG2(test0, int, a)
{
del_then_add_array(0);
return 0;
}
SEC("fentry/bpf_fentry_test2")
int BPF_PROG2(test1, int, a, u64, b)
{
del_then_add_array(512);
return 0;
}
SEC("fentry/bpf_fentry_test3")
int BPF_PROG2(test2, char, a, int, b, u64, c)
{
del_then_add_array(1024);
return 0;
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_tracing.h`, `bpf/bpf_helpers.h`, `bpf_experimental.h`.
- Detected declarations: `struct bin_data`, `struct map_value`, `function del_array`, `function add_array`, `function del_then_add_array`, `function BPF_PROG2`, `function BPF_PROG2`, `function BPF_PROG2`, `function BPF_PROG2`.
- 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.