1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/module.h>
4 #include <linux/sched.h> /* for wake_up_process() */
5 #include <linux/ftrace.h>
7 extern void my_direct_func(struct task_struct *p);
9 void my_direct_func(struct task_struct *p)
11 trace_printk("waking up %s-%d\n", p->comm, p->pid);
14 extern void my_tramp(void *);
17 " .pushsection .text, \"ax\", @progbits\n"
18 " .type my_tramp, @function\n"
24 " call my_direct_func\n"
28 " .size my_tramp, .-my_tramp\n"
33 static int __init ftrace_direct_init(void)
35 return register_ftrace_direct((unsigned long)wake_up_process,
36 (unsigned long)my_tramp);
39 static void __exit ftrace_direct_exit(void)
41 unregister_ftrace_direct((unsigned long)wake_up_process,
42 (unsigned long)my_tramp);
45 module_init(ftrace_direct_init);
46 module_exit(ftrace_direct_exit);
48 MODULE_AUTHOR("Steven Rostedt");
49 MODULE_DESCRIPTION("Example use case of using register_ftrace_direct()");
50 MODULE_LICENSE("GPL");