kernel/trace/trace_selftest.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_selftest.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_selftest.c- Extension
.c- Size
- 35089 bytes
- Lines
- 1568
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
uapi/linux/sched/types.hlinux/stringify.hlinux/kthread.hlinux/delay.hlinux/slab.h
Detected Declarations
struct fgraph_fixturestruct wakeup_test_datafunction trace_valid_entryfunction trace_test_buffer_cpufunction trace_test_bufferfunction warn_failed_init_tracerfunction trace_selftest_test_probe1_funcfunction trace_selftest_test_probe2_funcfunction trace_selftest_test_probe3_funcfunction trace_selftest_test_global_funcfunction trace_selftest_test_dyn_funcfunction print_countsfunction reset_countsfunction trace_selftest_opsfunction trace_selftest_startup_dynamic_tracingfunction trace_selftest_test_recursion_funcfunction trace_selftest_test_recursion_safe_funcfunction trace_selftest_function_recursionfunction trace_selftest_test_regs_funcfunction trace_selftest_function_regsfunction trace_selftest_startup_functionfunction store_entryfunction store_returnfunction init_fgraph_fixturefunction test_graph_storage_singlefunction test_graph_storage_multifunction test_graph_storagefunction test_graph_storagefunction trace_graph_entry_watchdogfunction trace_selftest_startup_function_graphfunction trace_selftest_startup_irqsofffunction trace_selftest_startup_preemptofffunction trace_selftest_startup_preemptirqsofffunction trace_selftest_startup_nopfunction trace_wakeup_test_threadfunction trace_selftest_startup_wakeupfunction trace_selftest_startup_branch
Annotated Snippet
struct fgraph_fixture {
struct fgraph_ops gops;
int store_size;
const char *store_type_name;
char error_str_buf[ERRSTR_BUFLEN];
char *error_str;
};
static __init int store_entry(struct ftrace_graph_ent *trace,
struct fgraph_ops *gops,
struct ftrace_regs *fregs)
{
struct fgraph_fixture *fixture = container_of(gops, struct fgraph_fixture, gops);
const char *type = fixture->store_type_name;
int size = fixture->store_size;
void *p;
p = fgraph_reserve_data(gops->idx, size);
if (!p) {
snprintf(fixture->error_str_buf, ERRSTR_BUFLEN,
"Failed to reserve %s\n", type);
return 0;
}
switch (size) {
case 1:
*(char *)p = CHAR_NUMBER;
break;
case 2:
*(short *)p = SHORT_NUMBER;
break;
case 4:
*(int *)p = WORD_NUMBER;
break;
case 8:
*(long long *)p = LONG_NUMBER;
break;
}
return 1;
}
static __init void store_return(struct ftrace_graph_ret *trace,
struct fgraph_ops *gops,
struct ftrace_regs *fregs)
{
struct fgraph_fixture *fixture = container_of(gops, struct fgraph_fixture, gops);
const char *type = fixture->store_type_name;
long long expect = 0;
long long found = -1;
int size;
char *p;
p = fgraph_retrieve_data(gops->idx, &size);
if (!p) {
snprintf(fixture->error_str_buf, ERRSTR_BUFLEN,
"Failed to retrieve %s\n", type);
return;
}
if (fixture->store_size > size) {
snprintf(fixture->error_str_buf, ERRSTR_BUFLEN,
"Retrieved size %d is smaller than expected %d\n",
size, (int)fixture->store_size);
return;
}
switch (fixture->store_size) {
case 1:
expect = CHAR_NUMBER;
found = *(char *)p;
break;
case 2:
expect = SHORT_NUMBER;
found = *(short *)p;
break;
case 4:
expect = WORD_NUMBER;
found = *(int *)p;
break;
case 8:
expect = LONG_NUMBER;
found = *(long long *)p;
break;
}
if (found != expect) {
snprintf(fixture->error_str_buf, ERRSTR_BUFLEN,
"%s returned not %lld but %lld\n", type, expect, found);
return;
}
Annotation
- Immediate include surface: `uapi/linux/sched/types.h`, `linux/stringify.h`, `linux/kthread.h`, `linux/delay.h`, `linux/slab.h`.
- Detected declarations: `struct fgraph_fixture`, `struct wakeup_test_data`, `function trace_valid_entry`, `function trace_test_buffer_cpu`, `function trace_test_buffer`, `function warn_failed_init_tracer`, `function trace_selftest_test_probe1_func`, `function trace_selftest_test_probe2_func`, `function trace_selftest_test_probe3_func`, `function trace_selftest_test_global_func`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.