samples/ftrace/ftrace-direct-too.c
Source file repositories/reference/linux-study-clean/samples/ftrace/ftrace-direct-too.c
File Facts
- System
- Linux kernel
- Corpus path
samples/ftrace/ftrace-direct-too.c- Extension
.c- Size
- 6337 bytes
- Lines
- 257
- Domain
- Support Tooling And Documentation
- Bucket
- samples
- Inferred role
- Support Tooling And Documentation: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/mm.hlinux/ftrace.hasm/asm-offsets.hasm/asm.hasm/ibt.hasm/nospec-branch.hasm/ppc_asm.h
Detected Declarations
function my_direct_funcfunction ftrace_direct_initfunction ftrace_direct_exitmodule init ftrace_direct_init
Annotated Snippet
#include <linux/mm.h> /* for handle_mm_fault() */
#include <linux/ftrace.h>
#if !defined(CONFIG_ARM64) && !defined(CONFIG_PPC32)
#include <asm/asm-offsets.h>
#endif
extern void my_direct_func(struct vm_area_struct *vma, unsigned long address,
unsigned int flags, struct pt_regs *regs);
void my_direct_func(struct vm_area_struct *vma, unsigned long address,
unsigned int flags, struct pt_regs *regs)
{
trace_printk("handle mm fault vma=%p address=%lx flags=%x regs=%p\n",
vma, address, flags, regs);
}
extern void my_tramp(void *);
#ifdef CONFIG_RISCV
#include <asm/asm.h>
asm (
" .pushsection .text, \"ax\", @progbits\n"
" .type my_tramp, @function\n"
" .globl my_tramp\n"
" my_tramp:\n"
" addi sp,sp,-5*"SZREG"\n"
" "REG_S" a0,0*"SZREG"(sp)\n"
" "REG_S" a1,1*"SZREG"(sp)\n"
" "REG_S" a2,2*"SZREG"(sp)\n"
" "REG_S" t0,3*"SZREG"(sp)\n"
" "REG_S" ra,4*"SZREG"(sp)\n"
" call my_direct_func\n"
" "REG_L" a0,0*"SZREG"(sp)\n"
" "REG_L" a1,1*"SZREG"(sp)\n"
" "REG_L" a2,2*"SZREG"(sp)\n"
" "REG_L" t0,3*"SZREG"(sp)\n"
" "REG_L" ra,4*"SZREG"(sp)\n"
" addi sp,sp,5*"SZREG"\n"
" jr t0\n"
" .size my_tramp, .-my_tramp\n"
" .popsection\n"
);
#endif /* CONFIG_RISCV */
#ifdef CONFIG_X86_64
#include <asm/ibt.h>
#include <asm/nospec-branch.h>
asm (
" .pushsection .text, \"ax\", @progbits\n"
" .type my_tramp, @function\n"
" .globl my_tramp\n"
" my_tramp:"
ASM_ENDBR
" pushq %rbp\n"
" movq %rsp, %rbp\n"
CALL_DEPTH_ACCOUNT
" pushq %rdi\n"
" pushq %rsi\n"
" pushq %rdx\n"
" pushq %rcx\n"
" call my_direct_func\n"
" popq %rcx\n"
" popq %rdx\n"
" popq %rsi\n"
" popq %rdi\n"
" leave\n"
ASM_RET
" .size my_tramp, .-my_tramp\n"
" .popsection\n"
);
#endif /* CONFIG_X86_64 */
#ifdef CONFIG_S390
asm (
" .pushsection .text, \"ax\", @progbits\n"
" .type my_tramp, @function\n"
" .globl my_tramp\n"
" my_tramp:"
" lgr %r1,%r15\n"
" stmg %r0,%r5,"__stringify(__SF_GPRS)"(%r15)\n"
" stg %r14,"__stringify(__SF_GPRS+8*8)"(%r15)\n"
" aghi %r15,"__stringify(-STACK_FRAME_OVERHEAD)"\n"
" stg %r1,"__stringify(__SF_BACKCHAIN)"(%r15)\n"
" brasl %r14,my_direct_func\n"
Annotation
- Immediate include surface: `linux/module.h`, `linux/mm.h`, `linux/ftrace.h`, `asm/asm-offsets.h`, `asm/asm.h`, `asm/ibt.h`, `asm/nospec-branch.h`, `asm/ppc_asm.h`.
- Detected declarations: `function my_direct_func`, `function ftrace_direct_init`, `function ftrace_direct_exit`, `module init ftrace_direct_init`.
- Atlas domain: Support Tooling And Documentation / samples.
- Implementation status: integration 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.