tools/testing/selftests/bpf/progs/test_task_local_data.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_task_local_data.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_task_local_data.c- Extension
.c- Size
- 1184 bytes
- Lines
- 66
- 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
vmlinux.herrno.hbpf/bpf_helpers.htask_local_data.bpf.h
Detected Declarations
struct tld_keysstruct test_tld_structfunction task_main
Annotated Snippet
struct tld_keys {
tld_key_t value0;
tld_key_t value1;
tld_key_t value2;
tld_key_t value_not_exist;
};
struct test_tld_struct {
__u64 a;
__u64 b;
__u64 c;
__u64 d;
};
int test_value0;
int test_value1;
struct test_tld_struct test_value2;
SEC("syscall")
int task_main(void *ctx)
{
struct tld_object tld_obj;
struct test_tld_struct *struct_p;
struct task_struct *task;
int err, *int_p;
task = bpf_get_current_task_btf();
err = tld_object_init(task, &tld_obj);
if (err)
return 1;
int_p = tld_get_data(&tld_obj, value0, "value0", sizeof(int));
if (int_p)
test_value0 = *int_p;
else
return 2;
int_p = tld_get_data(&tld_obj, value1, "value1", sizeof(int));
if (int_p)
test_value1 = *int_p;
else
return 3;
struct_p = tld_get_data(&tld_obj, value2, "value2", sizeof(struct test_tld_struct));
if (struct_p)
test_value2 = *struct_p;
else
return 4;
int_p = tld_get_data(&tld_obj, value_not_exist, "value_not_exist", sizeof(int));
if (int_p)
return 5;
return 0;
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `vmlinux.h`, `errno.h`, `bpf/bpf_helpers.h`, `task_local_data.bpf.h`.
- Detected declarations: `struct tld_keys`, `struct test_tld_struct`, `function task_main`.
- 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.