Debian Codegraph @

tapset/linux/sysc_readahead.stp

raw
1 # readahead __________________________________________________
2 #
3 # asmlinkage ssize_t
4 # sys_readahead(int fd,
5 # loff_t offset,
6 # size_t count)
7 #
8
9 @define _SYSCALL_READAHEAD_NAME
10 %(
11 name = "readahead"
12 %)
13
14 @define _SYSCALL_READAHEAD_ARGSTR
15 %(
16 argstr = sprintf("%d, %d, %u", fd, offset, count)
17 %)
18
19 @define _SYSCALL_READAHEAD_REGARGS_STORE
20 %(
21 if (@probewrite(fd))
22 set_int_arg(1, fd)
23
24 %( CONFIG_64BIT == "y" %?
25 if (@probewrite(offset))
26 set_longlong_arg(2, offset)
27
28 if (@probewrite(count))
29 set_ulong_arg(3, count)
30 %:
31 if (@probewrite(offset))
32 set_longlong_arg(2, offset)
33
34 if (@probewrite(count))
35 set_ulong_arg(4, count)
36 %)
37 %)
38
39 probe syscall.readahead = dw_syscall.readahead !, nd_syscall.readahead ? {}
40 probe syscall.readahead.return = dw_syscall.readahead.return !,
41 nd_syscall.readahead.return ? {}
42
43 # dw_readahead _____________________________________________________
44
45 probe dw_syscall.readahead = kernel.function("sys_readahead").call
46 {
47 @__syscall_gate_compat_simple
48 @_SYSCALL_READAHEAD_NAME
49 fd = __int32($fd)
50 offset = $offset
51 %( CONFIG_64BIT == "y" %?
52 count = $count
53 %:
54 count = __uint32($count)
55 %)
56 @_SYSCALL_READAHEAD_ARGSTR
57 }
58 probe dw_syscall.readahead.return = kernel.function("sys_readahead").return
59 {
60 @__syscall_gate_compat_simple
61 @_SYSCALL_READAHEAD_NAME
62 @SYSC_RETVALSTR($return)
63 }
64
65 # nd_readahead _____________________________________________________
66
67 probe nd_syscall.readahead = nd1_syscall.readahead!, nd2_syscall.readahead!, tp_syscall.readahead
68 { }
69
70 probe nd1_syscall.readahead = kprobe.function("sys_readahead") ?
71 {
72 @__syscall_gate_compat_simple
73 @_SYSCALL_READAHEAD_NAME
74 asmlinkage()
75 fd = int_arg(1)
76 %( CONFIG_64BIT == "y" %?
77 offset = longlong_arg(2)
78 count = ulong_arg(3)
79 %:
80 %( arch == "arm" %?
81 # arm has some odd rules regarding long long arguments.
82 offset = longlong_arg(3)
83 count = ulong_arg(5)
84 %:
85 # On a 32-bit kernel, 'long long' arguments take the space of
86 # 2 arguments, so we have to adjust the following argument
87 # numbers.
88 offset = longlong_arg(2)
89 count = ulong_arg(4)
90 %)
91 %)
92 @_SYSCALL_READAHEAD_ARGSTR
93 }
94
95 /* kernel 4.17+ */
96 probe nd2_syscall.readahead = kprobe.function(@arch_syscall_prefix "sys_readahead") ?
97 {
98 __set_syscall_pt_regs(pointer_arg(1))
99 @_SYSCALL_READAHEAD_NAME
100 fd = int_arg(1)
101 offset = longlong_arg(2)
102 count = ulong_arg(3)
103 @_SYSCALL_READAHEAD_ARGSTR
104 },
105 {
106 %( @_IS_SREG_KERNEL %? @_SYSCALL_READAHEAD_REGARGS_STORE %)
107 }
108
109 /* kernel 3.5+, but undesirable because it affects all syscalls */
110 probe tp_syscall.readahead = kernel.trace("sys_enter")
111 {
112 __set_syscall_pt_regs($regs)
113 @__syscall_gate(@const("__NR_readahead"))
114 @_SYSCALL_READAHEAD_NAME
115 fd = int_arg(1)
116 offset = longlong_arg(2)
117 count = ulong_arg(3)
118 @_SYSCALL_READAHEAD_ARGSTR
119 },
120 {
121 %( @_IS_SREG_KERNEL %? @_SYSCALL_READAHEAD_REGARGS_STORE %)
122 }
123
124 probe nd_syscall.readahead.return = nd1_syscall.readahead.return!, nd2_syscall.readahead.return!, tp_syscall.readahead.return
125 { }
126
127 probe nd1_syscall.readahead.return = kprobe.function("sys_readahead").return ?
128 {
129 @__syscall_gate_compat_simple
130 @_SYSCALL_READAHEAD_NAME
131 @SYSC_RETVALSTR(returnval())
132 }
133
134 /* kernel 4.17+ */
135 probe nd2_syscall.readahead.return = kprobe.function(@arch_syscall_prefix "sys_readahead").return ?
136 {
137 @_SYSCALL_READAHEAD_NAME
138 @SYSC_RETVALSTR(returnval())
139 }
140
141 /* kernel 3.5+, but undesirable because it affects all syscalls */
142 probe tp_syscall.readahead.return = kernel.trace("sys_exit")
143 {
144 __set_syscall_pt_regs($regs)
145 @__syscall_gate(@const("__NR_readahead"))
146 @_SYSCALL_READAHEAD_NAME
147 @SYSC_RETVALSTR($ret)
148 }