blob: 6260f5134212312b2252e471ff4520f5c726b754 [file] [log] [blame]
Trond Myklebust82b0a4c2012-01-20 14:52:23 -05001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM sunrpc
3
4#if !defined(_TRACE_SUNRPC_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_SUNRPC_H
6
7#include <linux/sunrpc/sched.h>
8#include <linux/sunrpc/clnt.h>
Jeff Layton860a0d92014-10-28 14:24:12 -04009#include <linux/sunrpc/svc.h>
Trond Myklebust40b5ea02013-09-04 12:16:23 -040010#include <net/tcp_states.h>
11#include <linux/net.h>
Trond Myklebust82b0a4c2012-01-20 14:52:23 -050012#include <linux/tracepoint.h>
13
Steve Dickson5753cba2012-02-06 10:08:08 -050014DECLARE_EVENT_CLASS(rpc_task_status,
15
16 TP_PROTO(struct rpc_task *task),
17
18 TP_ARGS(task),
19
20 TP_STRUCT__entry(
Trond Myklebust92cb6c52013-09-04 22:09:50 -040021 __field(unsigned int, task_id)
22 __field(unsigned int, client_id)
Steve Dickson5753cba2012-02-06 10:08:08 -050023 __field(int, status)
24 ),
25
26 TP_fast_assign(
Trond Myklebust92cb6c52013-09-04 22:09:50 -040027 __entry->task_id = task->tk_pid;
28 __entry->client_id = task->tk_client->cl_clid;
Steve Dickson5753cba2012-02-06 10:08:08 -050029 __entry->status = task->tk_status;
30 ),
31
Trond Myklebust92cb6c52013-09-04 22:09:50 -040032 TP_printk("task:%u@%u, status %d",
33 __entry->task_id, __entry->client_id,
34 __entry->status)
Steve Dickson5753cba2012-02-06 10:08:08 -050035);
36
37DEFINE_EVENT(rpc_task_status, rpc_call_status,
38 TP_PROTO(struct rpc_task *task),
39
40 TP_ARGS(task)
41);
42
43DEFINE_EVENT(rpc_task_status, rpc_bind_status,
44 TP_PROTO(struct rpc_task *task),
45
46 TP_ARGS(task)
47);
48
49TRACE_EVENT(rpc_connect_status,
50 TP_PROTO(struct rpc_task *task, int status),
51
52 TP_ARGS(task, status),
53
54 TP_STRUCT__entry(
Trond Myklebust92cb6c52013-09-04 22:09:50 -040055 __field(unsigned int, task_id)
56 __field(unsigned int, client_id)
Steve Dickson5753cba2012-02-06 10:08:08 -050057 __field(int, status)
58 ),
59
60 TP_fast_assign(
Trond Myklebust92cb6c52013-09-04 22:09:50 -040061 __entry->task_id = task->tk_pid;
62 __entry->client_id = task->tk_client->cl_clid;
Steve Dickson5753cba2012-02-06 10:08:08 -050063 __entry->status = status;
64 ),
65
Trond Myklebust92cb6c52013-09-04 22:09:50 -040066 TP_printk("task:%u@%u, status %d",
67 __entry->task_id, __entry->client_id,
68 __entry->status)
Steve Dickson5753cba2012-02-06 10:08:08 -050069);
70
Trond Myklebust82b0a4c2012-01-20 14:52:23 -050071DECLARE_EVENT_CLASS(rpc_task_running,
72
73 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
74
75 TP_ARGS(clnt, task, action),
76
77 TP_STRUCT__entry(
Trond Myklebust92cb6c52013-09-04 22:09:50 -040078 __field(unsigned int, task_id)
79 __field(unsigned int, client_id)
Trond Myklebust82b0a4c2012-01-20 14:52:23 -050080 __field(const void *, action)
81 __field(unsigned long, runstate)
82 __field(int, status)
83 __field(unsigned short, flags)
84 ),
85
86 TP_fast_assign(
Ditang Chen2ca310f2014-03-07 13:27:57 +080087 __entry->client_id = clnt ? clnt->cl_clid : -1;
Trond Myklebust92cb6c52013-09-04 22:09:50 -040088 __entry->task_id = task->tk_pid;
Trond Myklebust82b0a4c2012-01-20 14:52:23 -050089 __entry->action = action;
90 __entry->runstate = task->tk_runstate;
91 __entry->status = task->tk_status;
92 __entry->flags = task->tk_flags;
93 ),
94
Ditang Chen2ca310f2014-03-07 13:27:57 +080095 TP_printk("task:%u@%d flags=%4.4x state=%4.4lx status=%d action=%pf",
Trond Myklebust92cb6c52013-09-04 22:09:50 -040096 __entry->task_id, __entry->client_id,
Trond Myklebust82b0a4c2012-01-20 14:52:23 -050097 __entry->flags,
98 __entry->runstate,
99 __entry->status,
100 __entry->action
101 )
102);
103
104DEFINE_EVENT(rpc_task_running, rpc_task_begin,
105
106 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
107
108 TP_ARGS(clnt, task, action)
109
110);
111
112DEFINE_EVENT(rpc_task_running, rpc_task_run_action,
113
114 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
115
116 TP_ARGS(clnt, task, action)
117
118);
119
120DEFINE_EVENT(rpc_task_running, rpc_task_complete,
121
122 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
123
124 TP_ARGS(clnt, task, action)
125
126);
127
128DECLARE_EVENT_CLASS(rpc_task_queued,
129
130 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
131
132 TP_ARGS(clnt, task, q),
133
134 TP_STRUCT__entry(
Trond Myklebust92cb6c52013-09-04 22:09:50 -0400135 __field(unsigned int, task_id)
136 __field(unsigned int, client_id)
Trond Myklebust82b0a4c2012-01-20 14:52:23 -0500137 __field(unsigned long, timeout)
138 __field(unsigned long, runstate)
139 __field(int, status)
140 __field(unsigned short, flags)
Trond Myklebust85c0d242012-02-06 10:31:35 -0500141 __string(q_name, rpc_qname(q))
Trond Myklebust82b0a4c2012-01-20 14:52:23 -0500142 ),
143
144 TP_fast_assign(
Trond Myklebust92cb6c52013-09-04 22:09:50 -0400145 __entry->client_id = clnt->cl_clid;
146 __entry->task_id = task->tk_pid;
Trond Myklebust82b0a4c2012-01-20 14:52:23 -0500147 __entry->timeout = task->tk_timeout;
148 __entry->runstate = task->tk_runstate;
149 __entry->status = task->tk_status;
150 __entry->flags = task->tk_flags;
Trond Myklebust85c0d242012-02-06 10:31:35 -0500151 __assign_str(q_name, rpc_qname(q));
Trond Myklebust82b0a4c2012-01-20 14:52:23 -0500152 ),
153
Trond Myklebust92cb6c52013-09-04 22:09:50 -0400154 TP_printk("task:%u@%u flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s",
155 __entry->task_id, __entry->client_id,
Trond Myklebust82b0a4c2012-01-20 14:52:23 -0500156 __entry->flags,
157 __entry->runstate,
158 __entry->status,
159 __entry->timeout,
Trond Myklebust85c0d242012-02-06 10:31:35 -0500160 __get_str(q_name)
Trond Myklebust82b0a4c2012-01-20 14:52:23 -0500161 )
162);
163
164DEFINE_EVENT(rpc_task_queued, rpc_task_sleep,
165
166 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
167
168 TP_ARGS(clnt, task, q)
169
170);
171
172DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,
173
174 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
175
176 TP_ARGS(clnt, task, q)
177
178);
179
Trond Myklebust40b5ea02013-09-04 12:16:23 -0400180#define rpc_show_socket_state(state) \
181 __print_symbolic(state, \
182 { SS_FREE, "FREE" }, \
183 { SS_UNCONNECTED, "UNCONNECTED" }, \
184 { SS_CONNECTING, "CONNECTING," }, \
185 { SS_CONNECTED, "CONNECTED," }, \
186 { SS_DISCONNECTING, "DISCONNECTING" })
187
188#define rpc_show_sock_state(state) \
189 __print_symbolic(state, \
190 { TCP_ESTABLISHED, "ESTABLISHED" }, \
191 { TCP_SYN_SENT, "SYN_SENT" }, \
192 { TCP_SYN_RECV, "SYN_RECV" }, \
193 { TCP_FIN_WAIT1, "FIN_WAIT1" }, \
194 { TCP_FIN_WAIT2, "FIN_WAIT2" }, \
195 { TCP_TIME_WAIT, "TIME_WAIT" }, \
196 { TCP_CLOSE, "CLOSE" }, \
197 { TCP_CLOSE_WAIT, "CLOSE_WAIT" }, \
198 { TCP_LAST_ACK, "LAST_ACK" }, \
199 { TCP_LISTEN, "LISTEN" }, \
200 { TCP_CLOSING, "CLOSING" })
201
202DECLARE_EVENT_CLASS(xs_socket_event,
203
204 TP_PROTO(
205 struct rpc_xprt *xprt,
206 struct socket *socket
207 ),
208
209 TP_ARGS(xprt, socket),
210
211 TP_STRUCT__entry(
212 __field(unsigned int, socket_state)
213 __field(unsigned int, sock_state)
214 __field(unsigned long long, ino)
215 __string(dstaddr,
216 xprt->address_strings[RPC_DISPLAY_ADDR])
217 __string(dstport,
218 xprt->address_strings[RPC_DISPLAY_PORT])
219 ),
220
221 TP_fast_assign(
222 struct inode *inode = SOCK_INODE(socket);
223 __entry->socket_state = socket->state;
224 __entry->sock_state = socket->sk->sk_state;
225 __entry->ino = (unsigned long long)inode->i_ino;
226 __assign_str(dstaddr,
227 xprt->address_strings[RPC_DISPLAY_ADDR]);
228 __assign_str(dstport,
229 xprt->address_strings[RPC_DISPLAY_PORT]);
230 ),
231
232 TP_printk(
233 "socket:[%llu] dstaddr=%s/%s "
234 "state=%u (%s) sk_state=%u (%s)",
235 __entry->ino, __get_str(dstaddr), __get_str(dstport),
236 __entry->socket_state,
237 rpc_show_socket_state(__entry->socket_state),
238 __entry->sock_state,
239 rpc_show_sock_state(__entry->sock_state)
240 )
241);
242#define DEFINE_RPC_SOCKET_EVENT(name) \
243 DEFINE_EVENT(xs_socket_event, name, \
244 TP_PROTO( \
245 struct rpc_xprt *xprt, \
246 struct socket *socket \
247 ), \
248 TP_ARGS(xprt, socket))
249
250DECLARE_EVENT_CLASS(xs_socket_event_done,
251
252 TP_PROTO(
253 struct rpc_xprt *xprt,
254 struct socket *socket,
255 int error
256 ),
257
258 TP_ARGS(xprt, socket, error),
259
260 TP_STRUCT__entry(
261 __field(int, error)
262 __field(unsigned int, socket_state)
263 __field(unsigned int, sock_state)
264 __field(unsigned long long, ino)
265 __string(dstaddr,
266 xprt->address_strings[RPC_DISPLAY_ADDR])
267 __string(dstport,
268 xprt->address_strings[RPC_DISPLAY_PORT])
269 ),
270
271 TP_fast_assign(
272 struct inode *inode = SOCK_INODE(socket);
273 __entry->socket_state = socket->state;
274 __entry->sock_state = socket->sk->sk_state;
275 __entry->ino = (unsigned long long)inode->i_ino;
276 __entry->error = error;
277 __assign_str(dstaddr,
278 xprt->address_strings[RPC_DISPLAY_ADDR]);
279 __assign_str(dstport,
280 xprt->address_strings[RPC_DISPLAY_PORT]);
281 ),
282
283 TP_printk(
284 "error=%d socket:[%llu] dstaddr=%s/%s "
285 "state=%u (%s) sk_state=%u (%s)",
286 __entry->error,
287 __entry->ino, __get_str(dstaddr), __get_str(dstport),
288 __entry->socket_state,
289 rpc_show_socket_state(__entry->socket_state),
290 __entry->sock_state,
291 rpc_show_sock_state(__entry->sock_state)
292 )
293);
294#define DEFINE_RPC_SOCKET_EVENT_DONE(name) \
295 DEFINE_EVENT(xs_socket_event_done, name, \
296 TP_PROTO( \
297 struct rpc_xprt *xprt, \
298 struct socket *socket, \
299 int error \
300 ), \
301 TP_ARGS(xprt, socket, error))
302
303DEFINE_RPC_SOCKET_EVENT(rpc_socket_state_change);
304DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_connect);
Trond Myklebuste8353c762013-12-31 13:39:22 -0500305DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_error);
Trond Myklebust40b5ea02013-09-04 12:16:23 -0400306DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_reset_connection);
307DEFINE_RPC_SOCKET_EVENT(rpc_socket_close);
308DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown);
309
Jeff Layton860a0d92014-10-28 14:24:12 -0400310TRACE_EVENT(svc_recv,
311 TP_PROTO(struct svc_rqst *rqst, int status),
312
313 TP_ARGS(rqst, status),
314
315 TP_STRUCT__entry(
316 __field(struct sockaddr *, addr)
317 __field(__be32, xid)
318 __field(int, status)
319 ),
320
321 TP_fast_assign(
322 __entry->addr = (struct sockaddr *)&rqst->rq_addr;
323 __entry->xid = status > 0 ? rqst->rq_xid : 0;
324 __entry->status = status;
325 ),
326
327 TP_printk("addr=%pIScp xid=0x%x status=%d", __entry->addr,
328 be32_to_cpu(__entry->xid), __entry->status)
329);
330
331DECLARE_EVENT_CLASS(svc_rqst_status,
332
333 TP_PROTO(struct svc_rqst *rqst, int status),
334
335 TP_ARGS(rqst, status),
336
337 TP_STRUCT__entry(
338 __field(struct sockaddr *, addr)
339 __field(__be32, xid)
340 __field(int, dropme)
341 __field(int, status)
342 ),
343
344 TP_fast_assign(
345 __entry->addr = (struct sockaddr *)&rqst->rq_addr;
346 __entry->xid = rqst->rq_xid;
347 __entry->dropme = (int)rqst->rq_dropme;
348 __entry->status = status;
349 ),
350
351 TP_printk("addr=%pIScp rq_xid=0x%x dropme=%d status=%d",
352 __entry->addr, be32_to_cpu(__entry->xid), __entry->dropme,
353 __entry->status)
354);
355
356DEFINE_EVENT(svc_rqst_status, svc_process,
357 TP_PROTO(struct svc_rqst *rqst, int status),
358 TP_ARGS(rqst, status));
359
360DEFINE_EVENT(svc_rqst_status, svc_send,
361 TP_PROTO(struct svc_rqst *rqst, int status),
362 TP_ARGS(rqst, status));
363
Trond Myklebust82b0a4c2012-01-20 14:52:23 -0500364#endif /* _TRACE_SUNRPC_H */
365
366#include <trace/define_trace.h>