kernel/trace/trace_kprobe.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_kprobe.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_kprobe.c- Extension
.c- Size
- 54901 bytes
- Lines
- 2216
- 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.
- 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/error-injection.hlinux/module.hlinux/rculist.hlinux/security.hlinux/uaccess.hasm/setup.htrace_dynevent.htrace_kprobe_selftest.htrace_probe.htrace_probe_kernel.htrace_probe_tmpl.h
Detected Declarations
struct trace_kprobestruct sym_count_ctxfunction set_kprobe_boot_eventsfunction is_trace_kprobefunction trace_kprobe_offsetfunction trace_kprobe_has_gonefunction trace_kprobe_within_modulefunction trace_kprobe_module_existfunction trace_kprobe_module_existfunction trace_kprobe_is_busyfunction trace_kprobe_match_command_headfunction trace_kprobe_matchfunction trace_kprobe_nhitfunction trace_kprobe_is_registeredfunction trace_kprobe_addressfunction trace_kprobe_primary_from_callfunction trace_kprobe_on_func_entryfunction trace_kprobe_error_injectablefunction free_trace_kprobefunction itfunction __enable_trace_kprobefunction __disable_trace_kprobefunction list_for_each_entryfunction enable_trace_kprobefunction list_for_each_entryfunction disable_trace_kprobefunction __within_notrace_funcfunction within_notrace_funcfunction __register_trace_kprobefunction __unregister_trace_kprobefunction unregister_trace_kprobefunction trace_kprobe_has_same_kprobefunction list_for_each_entryfunction append_trace_kprobefunction register_trace_kprobefunction register_module_trace_kprobefunction trace_kprobe_module_callbackfunction trace_kprobe_register_module_notifierfunction trace_kprobe_register_module_notifierfunction count_symbolsfunction count_mod_symbolsfunction number_of_same_symbolsfunction validate_module_probe_symbolfunction validate_probe_symbolfunction trace_kprobe_create_internalfunction trace_kprobe_create_cbfunction trace_kprobe_createfunction create_or_delete_trace_kprobe
Annotated Snippet
static const struct file_operations kprobe_events_ops = {
.owner = THIS_MODULE,
.open = probes_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
.write = probes_write,
};
static unsigned long trace_kprobe_missed(struct trace_kprobe *tk)
{
return trace_kprobe_is_return(tk) ?
tk->rp.kp.nmissed + tk->rp.nmissed : tk->rp.kp.nmissed;
}
/* Probes profiling interfaces */
static int probes_profile_seq_show(struct seq_file *m, void *v)
{
struct dyn_event *ev = v;
struct trace_kprobe *tk;
unsigned long nmissed;
if (!is_trace_kprobe(ev))
return 0;
tk = to_trace_kprobe(ev);
nmissed = trace_kprobe_missed(tk);
seq_printf(m, " %-44s %15lu %15lu\n",
trace_probe_name(&tk->tp),
trace_kprobe_nhit(tk),
nmissed);
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 kprobe_profile_ops = {
.owner = THIS_MODULE,
.open = profile_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
/* Note that we don't verify it, since the code does not come from user space */
static int
process_fetch_insn(struct fetch_insn *code, void *rec, void *edata,
void *dest, void *base)
{
struct pt_regs *regs = rec;
unsigned long val;
int ret;
retry:
/* 1st stage: get value from context */
switch (code->op) {
case FETCH_OP_REG:
val = regs_get_register(regs, code->param);
break;
case FETCH_OP_STACK:
val = regs_get_kernel_stack_nth(regs, code->param);
break;
case FETCH_OP_STACKP:
val = kernel_stack_pointer(regs);
break;
case FETCH_OP_RETVAL:
val = regs_return_value(regs);
break;
#ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API
case FETCH_OP_ARG:
val = regs_get_kernel_argument(regs, code->param);
break;
case FETCH_OP_EDATA:
Annotation
- Immediate include surface: `linux/bpf-cgroup.h`, `linux/cleanup.h`, `linux/error-injection.h`, `linux/module.h`, `linux/rculist.h`, `linux/security.h`, `linux/uaccess.h`, `asm/setup.h`.
- Detected declarations: `struct trace_kprobe`, `struct sym_count_ctx`, `function set_kprobe_boot_events`, `function is_trace_kprobe`, `function trace_kprobe_offset`, `function trace_kprobe_has_gone`, `function trace_kprobe_within_module`, `function trace_kprobe_module_exist`, `function trace_kprobe_module_exist`, `function trace_kprobe_is_busy`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: pattern implementation candidate.
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.