kernel/trace/trace_uprobe.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_uprobe.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_uprobe.c- Extension
.c- Size
- 40278 bytes
- Lines
- 1712
- 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/bpf-cgroup.hlinux/cleanup.hlinux/ctype.hlinux/filter.hlinux/module.hlinux/namei.hlinux/percpu.hlinux/rculist.hlinux/security.hlinux/string.hlinux/uaccess.hlinux/uprobes.htrace.htrace_dynevent.htrace_probe.htrace_probe_tmpl.h
Detected Declarations
struct uprobe_trace_entry_headstruct trace_uprobestruct uprobe_cpu_bufferfunction is_trace_uprobefunction adjust_stack_addrfunction adjust_stack_addrfunction get_user_stack_nthfunction probe_mem_readfunction probe_mem_read_userfunction fetch_store_stringfunction fetch_store_string_userfunction fetch_store_strlenfunction fetch_store_strlen_userfunction translate_user_vaddrfunction process_fetch_insnfunction init_trace_uprobe_filterfunction uprobe_filter_is_emptyfunction is_ret_probefunction trace_uprobe_is_busyfunction trace_uprobe_match_command_headfunction trace_uprobe_matchfunction trace_uprobe_primary_from_callfunction itfunction free_trace_uprobefunction unregister_trace_uprobefunction trace_uprobe_has_same_uprobefunction list_for_each_entryfunction append_trace_uprobefunction onefunction for_each_trace_uprobefunction register_trace_uprobefunction __trace_uprobe_createfunction trace_uprobe_createfunction create_or_delete_trace_uprobefunction trace_uprobe_releasefunction trace_uprobe_showfunction probes_seq_showfunction probes_openfunction probes_writefunction probes_profile_seq_showfunction profile_openfunction uprobe_buffer_initfunction for_each_possible_cpufunction uprobe_buffer_enablefunction uprobe_buffer_disablefunction uprobe_buffer_putfunction __uprobe_trace_funcfunction uprobe_trace_func
Annotated Snippet
static const struct file_operations uprobe_events_ops = {
.owner = THIS_MODULE,
.open = probes_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
.write = probes_write,
};
/* Probes profiling interfaces */
static int probes_profile_seq_show(struct seq_file *m, void *v)
{
struct dyn_event *ev = v;
struct trace_uprobe *tu;
unsigned long nhits;
int cpu;
if (!is_trace_uprobe(ev))
return 0;
tu = to_trace_uprobe(ev);
nhits = 0;
for_each_possible_cpu(cpu) {
nhits += per_cpu(*tu->nhits, cpu);
}
seq_printf(m, " %s %-44s %15lu\n", tu->filename,
trace_probe_name(&tu->tp), nhits);
return 0;
}
static const struct seq_operations profile_seq_op = {
.start = dyn_event_seq_start,
.next = dyn_event_seq_next,
.stop = dyn_event_seq_stop,
.show = probes_profile_seq_show
};
static int profile_open(struct inode *inode, struct file *file)
{
int ret;
ret = security_locked_down(LOCKDOWN_TRACEFS);
if (ret)
return ret;
return seq_open(file, &profile_seq_op);
}
static const struct file_operations uprobe_profile_ops = {
.owner = THIS_MODULE,
.open = profile_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
struct uprobe_cpu_buffer {
struct mutex mutex;
void *buf;
int dsize;
};
static struct uprobe_cpu_buffer __percpu *uprobe_cpu_buffer;
static int uprobe_buffer_refcnt;
#define MAX_UCB_BUFFER_SIZE PAGE_SIZE
static int uprobe_buffer_init(void)
{
int cpu, err_cpu;
uprobe_cpu_buffer = alloc_percpu(struct uprobe_cpu_buffer);
if (uprobe_cpu_buffer == NULL)
return -ENOMEM;
for_each_possible_cpu(cpu) {
struct page *p = alloc_pages_node(cpu_to_node(cpu),
GFP_KERNEL, 0);
if (p == NULL) {
err_cpu = cpu;
goto err;
}
per_cpu_ptr(uprobe_cpu_buffer, cpu)->buf = page_address(p);
mutex_init(&per_cpu_ptr(uprobe_cpu_buffer, cpu)->mutex);
}
return 0;
err:
for_each_possible_cpu(cpu) {
Annotation
- Immediate include surface: `linux/bpf-cgroup.h`, `linux/cleanup.h`, `linux/ctype.h`, `linux/filter.h`, `linux/module.h`, `linux/namei.h`, `linux/percpu.h`, `linux/rculist.h`.
- Detected declarations: `struct uprobe_trace_entry_head`, `struct trace_uprobe`, `struct uprobe_cpu_buffer`, `function is_trace_uprobe`, `function adjust_stack_addr`, `function adjust_stack_addr`, `function get_user_stack_nth`, `function probe_mem_read`, `function probe_mem_read_user`, `function fetch_store_string`.
- 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.