kernel/trace/trace_boot.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_boot.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_boot.c- Extension
.c- Size
- 16180 bytes
- Lines
- 673
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
linux/bootconfig.hlinux/cpumask.hlinux/ftrace.hlinux/init.hlinux/kernel.hlinux/mutex.hlinux/string.hlinux/slab.hlinux/trace.hlinux/trace_events.htrace.h
Detected Declarations
function trace_boot_set_instance_optionsfunction trace_boot_enable_eventsfunction xbc_node_for_each_array_valuefunction trace_boot_add_kprobe_eventfunction xbc_node_for_each_array_valuefunction trace_boot_add_kprobe_eventfunction trace_boot_add_synth_eventfunction xbc_node_for_each_array_valuefunction trace_boot_add_synth_eventfunction __printffunction append_str_nospacefunction trace_boot_hist_add_arrayfunction xbc_array_for_each_valuefunction trace_boot_hist_add_one_handlerfunction xbc_array_for_each_valuefunction trace_boot_hist_add_handlersfunction xbc_node_for_each_subkeyfunction trace_boot_compose_hist_cmdfunction xbc_node_for_each_key_valuefunction trace_boot_init_histogramsfunction xbc_node_for_each_subkeyfunction trace_boot_init_histogramsfunction trace_boot_init_eventsfunction xbc_node_for_each_subkeyfunction trace_boot_set_ftrace_filterfunction xbc_node_for_each_array_valuefunction trace_boot_enable_tracerfunction trace_boot_init_one_instancefunction trace_boot_init_instancesfunction xbc_node_for_each_subkeyfunction trace_boot_init
Annotated Snippet
if (strscpy(buf, p, ARRAY_SIZE(buf)) < 0) {
pr_err("String is too long: %s\n", p);
continue;
}
if (trace_set_options(tr, buf) < 0)
pr_err("Failed to set option: %s\n", buf);
}
p = xbc_node_find_value(node, "tracing_on", NULL);
if (p && *p != '\0') {
if (kstrtoul(p, 10, &v))
pr_err("Failed to set tracing on: %s\n", p);
if (v)
tracer_tracing_on(tr);
else
tracer_tracing_off(tr);
}
p = xbc_node_find_value(node, "trace_clock", NULL);
if (p && *p != '\0') {
if (tracing_set_clock(tr, p) < 0)
pr_err("Failed to set trace clock: %s\n", p);
}
p = xbc_node_find_value(node, "buffer_size", NULL);
if (p && *p != '\0') {
v = memparse(p, NULL);
if (v < PAGE_SIZE)
pr_err("Buffer size is too small: %s\n", p);
if (trace_array_is_readonly(tr) ||
tracing_resize_ring_buffer(tr, v, RING_BUFFER_ALL_CPUS) < 0)
pr_err("Failed to resize trace buffer to %s\n", p);
}
p = xbc_node_find_value(node, "cpumask", NULL);
if (p && *p != '\0') {
cpumask_var_t new_mask;
if (alloc_cpumask_var(&new_mask, GFP_KERNEL)) {
if (cpumask_parse(p, new_mask) < 0 ||
tracing_set_cpumask(tr, new_mask) < 0)
pr_err("Failed to set new CPU mask %s\n", p);
free_cpumask_var(new_mask);
}
}
}
#ifdef CONFIG_EVENT_TRACING
static void __init
trace_boot_enable_events(struct trace_array *tr, struct xbc_node *node)
{
struct xbc_node *anode;
char buf[MAX_BUF_LEN];
const char *p;
xbc_node_for_each_array_value(node, "events", anode, p) {
if (strscpy(buf, p, ARRAY_SIZE(buf)) < 0) {
pr_err("String is too long: %s\n", p);
continue;
}
if (ftrace_set_clr_event(tr, buf, 1) < 0)
pr_err("Failed to enable event: %s\n", p);
}
}
#ifdef CONFIG_KPROBE_EVENTS
static int __init
trace_boot_add_kprobe_event(struct xbc_node *node, const char *event)
{
struct dynevent_cmd cmd;
struct xbc_node *anode;
char buf[MAX_BUF_LEN];
const char *val;
int ret = 0;
xbc_node_for_each_array_value(node, "probes", anode, val) {
kprobe_event_cmd_init(&cmd, buf, MAX_BUF_LEN);
ret = kprobe_event_gen_cmd_start(&cmd, event, val);
if (ret) {
pr_err("Failed to generate probe: %s\n", buf);
break;
}
ret = kprobe_event_gen_cmd_end(&cmd);
if (ret) {
pr_err("Failed to add probe: %s\n", buf);
break;
Annotation
- Immediate include surface: `linux/bootconfig.h`, `linux/cpumask.h`, `linux/ftrace.h`, `linux/init.h`, `linux/kernel.h`, `linux/mutex.h`, `linux/string.h`, `linux/slab.h`.
- Detected declarations: `function trace_boot_set_instance_options`, `function trace_boot_enable_events`, `function xbc_node_for_each_array_value`, `function trace_boot_add_kprobe_event`, `function xbc_node_for_each_array_value`, `function trace_boot_add_kprobe_event`, `function trace_boot_add_synth_event`, `function xbc_node_for_each_array_value`, `function trace_boot_add_synth_event`, `function __printf`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration 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.