md/core: Combine two sync_page_io() arguments
[linux-block.git] / samples / ftrace / ftrace-direct.c
CommitLineData
b06457c8
SRV
1// SPDX-License-Identifier: GPL-2.0-only
2#include <linux/module.h>
3
4#include <linux/sched.h> /* for wake_up_process() */
5#include <linux/ftrace.h>
1254cfbc 6#include <asm/asm-offsets.h>
b06457c8 7
0daf5cb2
JO
8extern void my_direct_func(struct task_struct *p);
9
b06457c8
SRV
10void my_direct_func(struct task_struct *p)
11{
760f8bc7 12 trace_printk("waking up %s-%d\n", p->comm, p->pid);
b06457c8
SRV
13}
14
15extern void my_tramp(void *);
16
1254cfbc
HC
17#ifdef CONFIG_X86_64
18
0aec21cf
PZ
19#include <asm/ibt.h>
20
b06457c8
SRV
21asm (
22" .pushsection .text, \"ax\", @progbits\n"
9d907f1a 23" .type my_tramp, @function\n"
983df5f2 24" .globl my_tramp\n"
b06457c8 25" my_tramp:"
0aec21cf 26 ASM_ENDBR
b06457c8
SRV
27" pushq %rbp\n"
28" movq %rsp, %rbp\n"
29" pushq %rdi\n"
30" call my_direct_func\n"
31" popq %rdi\n"
32" leave\n"
b17c2baa 33 ASM_RET
9d907f1a 34" .size my_tramp, .-my_tramp\n"
b06457c8
SRV
35" .popsection\n"
36);
37
1254cfbc
HC
38#endif /* CONFIG_X86_64 */
39
40#ifdef CONFIG_S390
41
42asm (
43" .pushsection .text, \"ax\", @progbits\n"
44" .type my_tramp, @function\n"
45" .globl my_tramp\n"
46" my_tramp:"
47" lgr %r1,%r15\n"
48" stmg %r0,%r5,"__stringify(__SF_GPRS)"(%r15)\n"
49" stg %r14,"__stringify(__SF_GPRS+8*8)"(%r15)\n"
50" aghi %r15,"__stringify(-STACK_FRAME_OVERHEAD)"\n"
51" stg %r1,"__stringify(__SF_BACKCHAIN)"(%r15)\n"
52" brasl %r14,my_direct_func\n"
53" aghi %r15,"__stringify(STACK_FRAME_OVERHEAD)"\n"
54" lmg %r0,%r5,"__stringify(__SF_GPRS)"(%r15)\n"
55" lg %r14,"__stringify(__SF_GPRS+8*8)"(%r15)\n"
56" lgr %r1,%r0\n"
57" br %r1\n"
58" .size my_tramp, .-my_tramp\n"
59" .popsection\n"
60);
61
62#endif /* CONFIG_S390 */
b06457c8
SRV
63
64static int __init ftrace_direct_init(void)
65{
66 return register_ftrace_direct((unsigned long)wake_up_process,
67 (unsigned long)my_tramp);
68}
69
70static void __exit ftrace_direct_exit(void)
71{
72 unregister_ftrace_direct((unsigned long)wake_up_process,
73 (unsigned long)my_tramp);
74}
75
76module_init(ftrace_direct_init);
77module_exit(ftrace_direct_exit);
78
79MODULE_AUTHOR("Steven Rostedt");
80MODULE_DESCRIPTION("Example use case of using register_ftrace_direct()");
81MODULE_LICENSE("GPL");