tools/testing/selftests/bpf/prog_tests/core_read_macros.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/core_read_macros.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/core_read_macros.c- Extension
.c- Size
- 1779 bytes
- Lines
- 65
- 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
test_progs.htest_core_read_macros.skel.h
Detected Declarations
struct callback_headstruct callback_head___shuffledfunction test_core_read_macros
Annotated Snippet
struct callback_head {
struct callback_head *next;
void (*func)(struct callback_head *head);
};
/* ___shuffled flavor is just an illusion for BPF code, it doesn't really
* exist and user-space needs to provide data in the memory layout that
* matches callback_head. We just defined ___shuffled flavor to make it easier
* to work with the skeleton
*/
struct callback_head___shuffled {
struct callback_head___shuffled *next;
void (*func)(struct callback_head *head);
};
#include "test_core_read_macros.skel.h"
void test_core_read_macros(void)
{
int duration = 0, err;
struct test_core_read_macros* skel;
struct test_core_read_macros__bss *bss;
struct callback_head u_probe_in;
struct callback_head___shuffled u_core_in;
skel = test_core_read_macros__open_and_load();
if (CHECK(!skel, "skel_open", "failed to open skeleton\n"))
return;
bss = skel->bss;
bss->my_pid = getpid();
/* next pointers have to be set from the kernel side */
bss->k_probe_in.func = (void *)(long)0x1234;
bss->k_core_in.func = (void *)(long)0xabcd;
u_probe_in.next = &u_probe_in;
u_probe_in.func = (void *)(long)0x5678;
bss->u_probe_in = &u_probe_in;
u_core_in.next = &u_core_in;
u_core_in.func = (void *)(long)0xdbca;
bss->u_core_in = &u_core_in;
err = test_core_read_macros__attach(skel);
if (CHECK(err, "skel_attach", "skeleton attach failed: %d\n", err))
goto cleanup;
/* trigger tracepoint */
usleep(1);
ASSERT_EQ(bss->k_probe_out, 0x1234, "k_probe_out");
ASSERT_EQ(bss->k_core_out, 0xabcd, "k_core_out");
ASSERT_EQ(bss->u_probe_out, 0x5678, "u_probe_out");
ASSERT_EQ(bss->u_core_out, 0xdbca, "u_core_out");
cleanup:
test_core_read_macros__destroy(skel);
}
Annotation
- Immediate include surface: `test_progs.h`, `test_core_read_macros.skel.h`.
- Detected declarations: `struct callback_head`, `struct callback_head___shuffled`, `function test_core_read_macros`.
- 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.