kernel/trace/trace_remote.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_remote.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_remote.c- Extension
.c- Size
- 31967 bytes
- Lines
- 1385
- 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.
- 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/kstrtox.hlinux/lockdep.hlinux/mutex.hlinux/tracefs.hlinux/trace_remote.hlinux/trace_seq.hlinux/types.htrace.h
Detected Declarations
struct trace_remote_iteratorstruct trace_remoteenum tri_typefunction trace_remote_loadedfunction trace_remote_loadfunction trace_remote_try_unloadfunction trace_remote_enable_tracingfunction trace_remote_disable_tracingfunction trace_remote_resetfunction tracing_on_writefunction tracing_on_showfunction buffer_size_kb_writefunction buffer_size_kb_showfunction trace_remote_getfunction trace_remote_putfunction trace_remote_has_cpufunction __poll_remotefunction __free_ring_buffer_iterfunction for_each_possible_cpufunction __alloc_ring_buffer_iterfunction for_each_possible_cpufunction trace_remote_iter_freefunction trace_remote_iter_read_startfunction trace_remote_iter_read_finishedfunction __peek_eventfunction trace_remote_iter_read_eventfunction trace_remote_iter_movefunction trace_remote_iter_print_eventfunction trace_pipe_openfunction trace_pipe_releasefunction trace_pipe_readfunction trace_showfunction trace_stopfunction trace_openfunction trace_releasefunction trace_writefunction trace_remote_init_tracefsfunction for_each_possible_cpufunction trace_remote_registerfunction trace_remote_free_bufferfunction for_each_ring_buffer_descfunction trace_remote_alloc_bufferfunction for_each_cpufunction trace_remote_enable_eventfunction remote_event_enable_showfunction remote_event_enable_writefunction remote_event_id_showfunction remote_event_format_show
Annotated Snippet
static const struct file_operations trace_pipe_fops = {
.open = trace_pipe_open,
.read = trace_pipe_read,
.release = trace_pipe_release,
};
static void *trace_next(struct seq_file *m, void *v, loff_t *pos)
{
struct trace_remote_iterator *iter = m->private;
++*pos;
if (!iter || !trace_remote_iter_read_event(iter))
return NULL;
trace_remote_iter_move(iter);
iter->pos++;
return iter;
}
static void *trace_start(struct seq_file *m, loff_t *pos)
{
struct trace_remote_iterator *iter = m->private;
loff_t i;
if (!iter)
return NULL;
trace_remote_iter_read_start(iter);
if (!*pos) {
iter->pos = -1;
return trace_next(m, NULL, &i);
}
i = iter->pos;
while (i < *pos) {
iter = trace_next(m, NULL, &i);
if (!iter)
return NULL;
}
return iter;
}
static int trace_show(struct seq_file *m, void *v)
{
struct trace_remote_iterator *iter = v;
trace_seq_init(&iter->seq);
if (trace_remote_iter_print_event(iter)) {
seq_printf(m, "[EVENT %d PRINT TOO BIG]\n", iter->evt->id);
return 0;
}
return trace_print_seq(m, &iter->seq);
}
static void trace_stop(struct seq_file *m, void *v)
{
struct trace_remote_iterator *iter = m->private;
if (iter)
trace_remote_iter_read_finished(iter);
}
static const struct seq_operations trace_sops = {
.start = trace_start,
.next = trace_next,
.show = trace_show,
.stop = trace_stop,
};
static int trace_open(struct inode *inode, struct file *filp)
{
struct trace_remote *remote = inode->i_private;
struct trace_remote_iterator *iter = NULL;
int cpu = tracing_get_cpu(inode);
int ret;
if (!(filp->f_mode & FMODE_READ))
return 0;
guard(mutex)(&remote->lock);
iter = trace_remote_iter(remote, cpu, TRI_NONCONSUMING);
if (IS_ERR(iter))
return PTR_ERR(iter);
Annotation
- Immediate include surface: `linux/kstrtox.h`, `linux/lockdep.h`, `linux/mutex.h`, `linux/tracefs.h`, `linux/trace_remote.h`, `linux/trace_seq.h`, `linux/types.h`, `trace.h`.
- Detected declarations: `struct trace_remote_iterator`, `struct trace_remote`, `enum tri_type`, `function trace_remote_loaded`, `function trace_remote_load`, `function trace_remote_try_unload`, `function trace_remote_enable_tracing`, `function trace_remote_disable_tracing`, `function trace_remote_reset`, `function tracing_on_write`.
- 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.
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.