kernel/trace/trace_osnoise.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_osnoise.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_osnoise.c- Extension
.c- Size
- 78502 bytes
- Lines
- 3185
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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
linux/kthread.hlinux/tracefs.hlinux/uaccess.hlinux/cpumask.hlinux/delay.hlinux/sched/clock.huapi/linux/sched/types.hlinux/sched.hlinux/string.htrace.hasm/trace/irq_vectors.htrace/events/irq.htrace/events/sched.htrace/events/osnoise.h
Detected Declarations
struct osnoise_instancestruct osn_nmistruct osn_irqstruct osn_softirqstruct osn_threadstruct osnoise_variablesstruct timerlat_variablesstruct trace_stackenum osnoise_options_indexfunction osnoise_printfunction osnoise_has_registered_instancesfunction osnoise_instance_registeredfunction osnoise_register_instancefunction osnoise_unregister_instancefunction lockdep_is_heldfunction tlat_var_resetfunction osn_var_resetfunction osn_var_reset_allfunction timerlat_enabledfunction timerlat_softirq_exitfunction timerlat_thread_exitfunction timerlat_enabledfunction timerlat_softirq_exitfunction timerlat_thread_exitfunction print_osnoise_headersfunction print_osnoise_headersfunction __record_osnoise_samplefunction record_osnoise_samplefunction print_timerlat_headersfunction print_timerlat_headersfunction __record_timerlat_samplefunction record_timerlat_samplefunction timerlat_save_stackfunction __timerlat_dump_stackfunction timerlat_dump_stackfunction get_int_safe_durationfunction get_int_safe_durationfunction get_int_safe_durationfunction get_int_safe_durationfunction get_int_safe_durationfunction copy_int_safe_timefunction trace_osnoise_callbackfunction trace_clock_localfunction variablefunction osnoise_trace_irq_exitfunction trace_irqentry_callbackfunction trace_irqexit_callbackfunction osnoise_arch_register
Annotated Snippet
static const struct file_operations timerlat_fd_fops = {
.open = timerlat_fd_open,
.read = timerlat_fd_read,
.release = timerlat_fd_release,
.llseek = generic_file_llseek,
};
#endif
static const struct file_operations cpus_fops = {
.open = tracing_open_generic,
.read = osnoise_cpus_read,
.write = osnoise_cpus_write,
.llseek = generic_file_llseek,
};
static const struct file_operations osnoise_options_fops = {
.open = osnoise_options_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
.write = osnoise_options_write
};
#ifdef CONFIG_TIMERLAT_TRACER
#ifdef CONFIG_STACKTRACE
static int init_timerlat_stack_tracefs(struct dentry *top_dir)
{
struct dentry *tmp;
tmp = tracefs_create_file("print_stack", TRACE_MODE_WRITE, top_dir,
&osnoise_print_stack, &trace_min_max_fops);
if (!tmp)
return -ENOMEM;
return 0;
}
#else /* CONFIG_STACKTRACE */
static int init_timerlat_stack_tracefs(struct dentry *top_dir)
{
return 0;
}
#endif /* CONFIG_STACKTRACE */
static int osnoise_create_cpu_timerlat_fd(struct dentry *top_dir)
{
struct dentry *timerlat_fd;
struct dentry *per_cpu;
struct dentry *cpu_dir;
char cpu_str[30]; /* see trace.c: tracing_init_tracefs_percpu() */
long cpu;
/*
* Why not using tracing instance per_cpu/ dir?
*
* Because osnoise/timerlat have a single workload, having
* multiple files like these are waste of memory.
*/
per_cpu = tracefs_create_dir("per_cpu", top_dir);
if (!per_cpu)
return -ENOMEM;
for_each_possible_cpu(cpu) {
snprintf(cpu_str, 30, "cpu%ld", cpu);
cpu_dir = tracefs_create_dir(cpu_str, per_cpu);
if (!cpu_dir)
goto out_clean;
timerlat_fd = trace_create_file("timerlat_fd", TRACE_MODE_READ,
cpu_dir, NULL, &timerlat_fd_fops);
if (!timerlat_fd)
goto out_clean;
/* Record the CPU */
d_inode(timerlat_fd)->i_cdev = (void *)(cpu);
}
return 0;
out_clean:
tracefs_remove(per_cpu);
return -ENOMEM;
}
/*
* init_timerlat_tracefs - A function to initialize the timerlat interface files
*/
static int init_timerlat_tracefs(struct dentry *top_dir)
{
struct dentry *tmp;
int retval;
Annotation
- Immediate include surface: `linux/kthread.h`, `linux/tracefs.h`, `linux/uaccess.h`, `linux/cpumask.h`, `linux/delay.h`, `linux/sched/clock.h`, `uapi/linux/sched/types.h`, `linux/sched.h`.
- Detected declarations: `struct osnoise_instance`, `struct osn_nmi`, `struct osn_irq`, `struct osn_softirq`, `struct osn_thread`, `struct osnoise_variables`, `struct timerlat_variables`, `struct trace_stack`, `enum osnoise_options_index`, `function osnoise_print`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.