tools/testing/selftests/bpf/progs/linked_list.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/linked_list.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/linked_list.c- Extension
.c- Size
- 9658 bytes
- Lines
- 492
- 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/bpf_core_read.hbpf_experimental.hbpf_misc.hlinked_list.h
Detected Declarations
struct head_nested_innerstruct head_nestedfunction list_push_popfunction list_push_pop_multiplefunction list_in_listfunction test_list_push_popfunction test_list_push_pop_multiplefunction test_list_in_listfunction clear_listfunction clear_map_listfunction clear_inner_map_listfunction clear_global_listfunction clear_global_nested_listfunction clear_global_array_listfunction map_list_push_popfunction inner_map_list_push_popfunction global_list_push_popfunction global_list_push_pop_nestedfunction global_list_array_push_popfunction map_list_push_pop_multiplefunction inner_map_list_push_pop_multiplefunction global_list_push_pop_multiplefunction map_list_in_listfunction inner_map_list_in_listfunction global_list_in_list
Annotated Snippet
struct head_nested_inner {
struct bpf_spin_lock lock;
struct bpf_list_head head __contains(foo, node2);
};
struct head_nested {
int dummy;
struct head_nested_inner inner;
};
private(C) struct bpf_spin_lock glock_c;
private(C) struct bpf_list_head ghead_array[2] __contains(foo, node2);
private(C) struct bpf_list_head ghead_array_one[1] __contains(foo, node2);
private(D) struct head_nested ghead_nested;
static __always_inline
int list_push_pop(struct bpf_spin_lock *lock, struct bpf_list_head *head, bool leave_in_map)
{
struct bpf_list_node *n;
struct foo *f;
f = bpf_obj_new(typeof(*f));
if (!f)
return 2;
bpf_spin_lock(lock);
n = bpf_list_pop_front(head);
bpf_spin_unlock(lock);
if (n) {
bpf_obj_drop(container_of(n, struct foo, node2));
bpf_obj_drop(f);
return 3;
}
bpf_spin_lock(lock);
n = bpf_list_pop_back(head);
bpf_spin_unlock(lock);
if (n) {
bpf_obj_drop(container_of(n, struct foo, node2));
bpf_obj_drop(f);
return 4;
}
bpf_spin_lock(lock);
f->data = 42;
bpf_list_push_front(head, &f->node2);
bpf_spin_unlock(lock);
if (leave_in_map)
return 0;
bpf_spin_lock(lock);
n = bpf_list_pop_back(head);
bpf_spin_unlock(lock);
if (!n)
return 5;
f = container_of(n, struct foo, node2);
if (f->data != 42) {
bpf_obj_drop(f);
return 6;
}
bpf_spin_lock(lock);
f->data = 13;
bpf_list_push_front(head, &f->node2);
bpf_spin_unlock(lock);
bpf_spin_lock(lock);
n = bpf_list_pop_front(head);
bpf_spin_unlock(lock);
if (!n)
return 7;
f = container_of(n, struct foo, node2);
if (f->data != 13) {
bpf_obj_drop(f);
return 8;
}
bpf_obj_drop(f);
bpf_spin_lock(lock);
n = bpf_list_pop_front(head);
bpf_spin_unlock(lock);
if (n) {
bpf_obj_drop(container_of(n, struct foo, node2));
return 9;
}
bpf_spin_lock(lock);
n = bpf_list_pop_back(head);
bpf_spin_unlock(lock);
if (n) {
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_tracing.h`, `bpf/bpf_helpers.h`, `bpf/bpf_core_read.h`, `bpf_experimental.h`, `bpf_misc.h`, `linked_list.h`.
- Detected declarations: `struct head_nested_inner`, `struct head_nested`, `function list_push_pop`, `function list_push_pop_multiple`, `function list_in_list`, `function test_list_push_pop`, `function test_list_push_pop_multiple`, `function test_list_in_list`, `function clear_list`, `function clear_map_list`.
- 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.