include/linux/ftrace.h
Source file repositories/reference/linux-study-clean/include/linux/ftrace.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/ftrace.h- Extension
.h- Size
- 46841 bytes
- Lines
- 1401
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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/trace_recursion.hlinux/trace_clock.hlinux/jump_label.hlinux/kallsyms.hlinux/linkage.hlinux/bitops.hlinux/ptrace.hlinux/ktime.hlinux/sched.hlinux/types.hlinux/init.hlinux/fs.hasm/ftrace.hlinux/ftrace_regs.h
Detected Declarations
struct ftrace_opsstruct ftrace_regsstruct dyn_ftracestruct modulestruct ftrace_hashstruct ftrace_func_entrystruct ftrace_regsstruct ftrace_ops_hashstruct ftrace_opsstruct ftrace_func_entrystruct ftrace_opsstruct seq_filestruct dyn_ftracestruct ftrace_rec_iterstruct ftrace_graph_entstruct fgraph_retaddr_entstruct ftrace_graph_retstruct fgraph_opsstruct fgraph_opsstruct ftrace_ret_stackenum ftrace_ops_cmdenum ftrace_tracing_type_tenum ftrace_bug_typeenum ftrace_dump_modefunction ftrace_boot_snapshotfunction trace_initfunction ftrace_mod_address_lookupfunction ftrace_mod_get_kallsymfunction arch_ftrace_get_regsfunction ftrace_partial_regsfunction perf_arch_fetch_caller_regsfunction ftrace_fill_perf_regsfunction ftrace_regs_has_argsfunction ftrace_regs_get_kernel_stack_nthfunction ftrace_free_init_memfunction ftrace_free_memfunction ftrace_killfunction ftrace_find_rec_directfunction register_ftrace_directfunction unregister_ftrace_directfunction modify_ftrace_directfunction modify_ftrace_direct_nolockfunction update_ftrace_direct_addfunction update_ftrace_direct_delfunction update_ftrace_direct_modfunction ftrace_hash_countfunction ftracefunction ftrace_jmp_set
Annotated Snippet
struct ftrace_regs {
/* Nothing to see here, use the accessor functions! */
};
#define ftrace_regs_size() sizeof(struct __arch_ftrace_regs)
#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
/*
* Architectures that define HAVE_DYNAMIC_FTRACE_WITH_ARGS must define their own
* arch_ftrace_get_regs() where it only returns pt_regs *if* it is fully
* populated. It should return NULL otherwise.
*/
static inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
{
return &arch_ftrace_regs(fregs)->regs;
}
/*
* ftrace_regs_set_instruction_pointer() is to be defined by the architecture
* if to allow setting of the instruction pointer from the ftrace_regs when
* HAVE_DYNAMIC_FTRACE_WITH_ARGS is set and it supports live kernel patching.
*/
#define ftrace_regs_set_instruction_pointer(fregs, ip) do { } while (0)
#endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */
#ifdef CONFIG_HAVE_FTRACE_REGS_HAVING_PT_REGS
static_assert(sizeof(struct pt_regs) == ftrace_regs_size());
#endif /* CONFIG_HAVE_FTRACE_REGS_HAVING_PT_REGS */
static __always_inline struct pt_regs *ftrace_get_regs(struct ftrace_regs *fregs)
{
if (!fregs)
return NULL;
return arch_ftrace_get_regs(fregs);
}
#if !defined(CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS) || \
defined(CONFIG_HAVE_FTRACE_REGS_HAVING_PT_REGS)
#ifndef arch_ftrace_partial_regs
#define arch_ftrace_partial_regs(regs) do {} while (0)
#endif
static __always_inline struct pt_regs *
ftrace_partial_regs(struct ftrace_regs *fregs, struct pt_regs *regs)
{
/*
* If CONFIG_HAVE_FTRACE_REGS_HAVING_PT_REGS=y, ftrace_regs memory
* layout is including pt_regs. So always returns that address.
* Since arch_ftrace_get_regs() will check some members and may return
* NULL, we can not use it.
*/
regs = &arch_ftrace_regs(fregs)->regs;
/* Allow arch specific updates to regs. */
arch_ftrace_partial_regs(regs);
return regs;
}
#endif /* !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS || CONFIG_HAVE_FTRACE_REGS_HAVING_PT_REGS */
#ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
/*
* Please define arch dependent pt_regs which compatible to the
* perf_arch_fetch_caller_regs() but based on ftrace_regs.
* This requires
* - user_mode(_regs) returns false (always kernel mode).
* - able to use the _regs for stack trace.
*/
#ifndef arch_ftrace_fill_perf_regs
/* As same as perf_arch_fetch_caller_regs(), do nothing by default */
#define arch_ftrace_fill_perf_regs(fregs, _regs) do {} while (0)
#endif
static __always_inline struct pt_regs *
ftrace_fill_perf_regs(struct ftrace_regs *fregs, struct pt_regs *regs)
{
arch_ftrace_fill_perf_regs(fregs, regs);
return regs;
}
#else /* !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */
static __always_inline struct pt_regs *
ftrace_fill_perf_regs(struct ftrace_regs *fregs, struct pt_regs *regs)
{
Annotation
- Immediate include surface: `linux/trace_recursion.h`, `linux/trace_clock.h`, `linux/jump_label.h`, `linux/kallsyms.h`, `linux/linkage.h`, `linux/bitops.h`, `linux/ptrace.h`, `linux/ktime.h`.
- Detected declarations: `struct ftrace_ops`, `struct ftrace_regs`, `struct dyn_ftrace`, `struct module`, `struct ftrace_hash`, `struct ftrace_func_entry`, `struct ftrace_regs`, `struct ftrace_ops_hash`, `struct ftrace_ops`, `struct ftrace_func_entry`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.