2 #define TRACE_SYSTEM sunrpc
4 #if !defined(_TRACE_SUNRPC_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_SUNRPC_H
7 #include <linux/sunrpc/sched.h>
8 #include <linux/sunrpc/clnt.h>
9 #include <linux/sunrpc/svc.h>
10 #include <linux/sunrpc/xprtsock.h>
11 #include <linux/sunrpc/svc_xprt.h>
12 #include <net/tcp_states.h>
13 #include <linux/net.h>
14 #include <linux/tracepoint.h>
16 DECLARE_EVENT_CLASS(rpc_task_status
,
18 TP_PROTO(struct rpc_task
*task
),
23 __field(unsigned int, task_id
)
24 __field(unsigned int, client_id
)
29 __entry
->task_id
= task
->tk_pid
;
30 __entry
->client_id
= task
->tk_client
->cl_clid
;
31 __entry
->status
= task
->tk_status
;
34 TP_printk("task:%u@%u, status %d",
35 __entry
->task_id
, __entry
->client_id
,
39 DEFINE_EVENT(rpc_task_status
, rpc_call_status
,
40 TP_PROTO(struct rpc_task
*task
),
45 DEFINE_EVENT(rpc_task_status
, rpc_bind_status
,
46 TP_PROTO(struct rpc_task
*task
),
51 TRACE_EVENT(rpc_connect_status
,
52 TP_PROTO(struct rpc_task
*task
, int status
),
54 TP_ARGS(task
, status
),
57 __field(unsigned int, task_id
)
58 __field(unsigned int, client_id
)
63 __entry
->task_id
= task
->tk_pid
;
64 __entry
->client_id
= task
->tk_client
->cl_clid
;
65 __entry
->status
= status
;
68 TP_printk("task:%u@%u, status %d",
69 __entry
->task_id
, __entry
->client_id
,
73 DECLARE_EVENT_CLASS(rpc_task_running
,
75 TP_PROTO(const struct rpc_clnt
*clnt
, const struct rpc_task
*task
, const void *action
),
77 TP_ARGS(clnt
, task
, action
),
80 __field(unsigned int, task_id
)
81 __field(unsigned int, client_id
)
82 __field(const void *, action
)
83 __field(unsigned long, runstate
)
85 __field(unsigned short, flags
)
89 __entry
->client_id
= clnt
? clnt
->cl_clid
: -1;
90 __entry
->task_id
= task
->tk_pid
;
91 __entry
->action
= action
;
92 __entry
->runstate
= task
->tk_runstate
;
93 __entry
->status
= task
->tk_status
;
94 __entry
->flags
= task
->tk_flags
;
97 TP_printk("task:%u@%d flags=%4.4x state=%4.4lx status=%d action=%pf",
98 __entry
->task_id
, __entry
->client_id
,
106 DEFINE_EVENT(rpc_task_running
, rpc_task_begin
,
108 TP_PROTO(const struct rpc_clnt
*clnt
, const struct rpc_task
*task
, const void *action
),
110 TP_ARGS(clnt
, task
, action
)
114 DEFINE_EVENT(rpc_task_running
, rpc_task_run_action
,
116 TP_PROTO(const struct rpc_clnt
*clnt
, const struct rpc_task
*task
, const void *action
),
118 TP_ARGS(clnt
, task
, action
)
122 DEFINE_EVENT(rpc_task_running
, rpc_task_complete
,
124 TP_PROTO(const struct rpc_clnt
*clnt
, const struct rpc_task
*task
, const void *action
),
126 TP_ARGS(clnt
, task
, action
)
130 DECLARE_EVENT_CLASS(rpc_task_queued
,
132 TP_PROTO(const struct rpc_clnt
*clnt
, const struct rpc_task
*task
, const struct rpc_wait_queue
*q
),
134 TP_ARGS(clnt
, task
, q
),
137 __field(unsigned int, task_id
)
138 __field(unsigned int, client_id
)
139 __field(unsigned long, timeout
)
140 __field(unsigned long, runstate
)
142 __field(unsigned short, flags
)
143 __string(q_name
, rpc_qname(q
))
147 __entry
->client_id
= clnt
->cl_clid
;
148 __entry
->task_id
= task
->tk_pid
;
149 __entry
->timeout
= task
->tk_timeout
;
150 __entry
->runstate
= task
->tk_runstate
;
151 __entry
->status
= task
->tk_status
;
152 __entry
->flags
= task
->tk_flags
;
153 __assign_str(q_name
, rpc_qname(q
));
156 TP_printk("task:%u@%u flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s",
157 __entry
->task_id
, __entry
->client_id
,
166 DEFINE_EVENT(rpc_task_queued
, rpc_task_sleep
,
168 TP_PROTO(const struct rpc_clnt
*clnt
, const struct rpc_task
*task
, const struct rpc_wait_queue
*q
),
170 TP_ARGS(clnt
, task
, q
)
174 DEFINE_EVENT(rpc_task_queued
, rpc_task_wakeup
,
176 TP_PROTO(const struct rpc_clnt
*clnt
, const struct rpc_task
*task
, const struct rpc_wait_queue
*q
),
178 TP_ARGS(clnt
, task
, q
)
183 * First define the enums in the below macros to be exported to userspace
184 * via TRACE_DEFINE_ENUM().
188 #define EM(a, b) TRACE_DEFINE_ENUM(a);
189 #define EMe(a, b) TRACE_DEFINE_ENUM(a);
191 #define RPC_SHOW_SOCKET \
192 EM( SS_FREE, "FREE" ) \
193 EM( SS_UNCONNECTED, "UNCONNECTED" ) \
194 EM( SS_CONNECTING, "CONNECTING," ) \
195 EM( SS_CONNECTED, "CONNECTED," ) \
196 EMe(SS_DISCONNECTING, "DISCONNECTING" )
198 #define rpc_show_socket_state(state) \
199 __print_symbolic(state, RPC_SHOW_SOCKET)
203 #define RPC_SHOW_SOCK \
204 EM( TCP_ESTABLISHED, "ESTABLISHED" ) \
205 EM( TCP_SYN_SENT, "SYN_SENT" ) \
206 EM( TCP_SYN_RECV, "SYN_RECV" ) \
207 EM( TCP_FIN_WAIT1, "FIN_WAIT1" ) \
208 EM( TCP_FIN_WAIT2, "FIN_WAIT2" ) \
209 EM( TCP_TIME_WAIT, "TIME_WAIT" ) \
210 EM( TCP_CLOSE, "CLOSE" ) \
211 EM( TCP_CLOSE_WAIT, "CLOSE_WAIT" ) \
212 EM( TCP_LAST_ACK, "LAST_ACK" ) \
213 EM( TCP_LISTEN, "LISTEN" ) \
214 EMe( TCP_CLOSING, "CLOSING" )
216 #define rpc_show_sock_state(state) \
217 __print_symbolic(state, RPC_SHOW_SOCK)
222 * Now redefine the EM() and EMe() macros to map the enums to the strings
223 * that will be printed in the output.
227 #define EM(a, b) {a, b},
228 #define EMe(a, b) {a, b}
230 DECLARE_EVENT_CLASS(xs_socket_event
,
233 struct rpc_xprt
*xprt
,
234 struct socket
*socket
237 TP_ARGS(xprt
, socket
),
240 __field(unsigned int, socket_state
)
241 __field(unsigned int, sock_state
)
242 __field(unsigned long long, ino
)
244 xprt
->address_strings
[RPC_DISPLAY_ADDR
])
246 xprt
->address_strings
[RPC_DISPLAY_PORT
])
250 struct inode
*inode
= SOCK_INODE(socket
);
251 __entry
->socket_state
= socket
->state
;
252 __entry
->sock_state
= socket
->sk
->sk_state
;
253 __entry
->ino
= (unsigned long long)inode
->i_ino
;
254 __assign_str(dstaddr
,
255 xprt
->address_strings
[RPC_DISPLAY_ADDR
]);
256 __assign_str(dstport
,
257 xprt
->address_strings
[RPC_DISPLAY_PORT
]);
261 "socket:[%llu] dstaddr=%s/%s "
262 "state=%u (%s) sk_state=%u (%s)",
263 __entry
->ino
, __get_str(dstaddr
), __get_str(dstport
),
264 __entry
->socket_state
,
265 rpc_show_socket_state(__entry
->socket_state
),
267 rpc_show_sock_state(__entry
->sock_state
)
270 #define DEFINE_RPC_SOCKET_EVENT(name) \
271 DEFINE_EVENT(xs_socket_event, name, \
273 struct rpc_xprt *xprt, \
274 struct socket *socket \
276 TP_ARGS(xprt, socket))
278 DECLARE_EVENT_CLASS(xs_socket_event_done
,
281 struct rpc_xprt
*xprt
,
282 struct socket
*socket
,
286 TP_ARGS(xprt
, socket
, error
),
290 __field(unsigned int, socket_state
)
291 __field(unsigned int, sock_state
)
292 __field(unsigned long long, ino
)
294 xprt
->address_strings
[RPC_DISPLAY_ADDR
])
296 xprt
->address_strings
[RPC_DISPLAY_PORT
])
300 struct inode
*inode
= SOCK_INODE(socket
);
301 __entry
->socket_state
= socket
->state
;
302 __entry
->sock_state
= socket
->sk
->sk_state
;
303 __entry
->ino
= (unsigned long long)inode
->i_ino
;
304 __entry
->error
= error
;
305 __assign_str(dstaddr
,
306 xprt
->address_strings
[RPC_DISPLAY_ADDR
]);
307 __assign_str(dstport
,
308 xprt
->address_strings
[RPC_DISPLAY_PORT
]);
312 "error=%d socket:[%llu] dstaddr=%s/%s "
313 "state=%u (%s) sk_state=%u (%s)",
315 __entry
->ino
, __get_str(dstaddr
), __get_str(dstport
),
316 __entry
->socket_state
,
317 rpc_show_socket_state(__entry
->socket_state
),
319 rpc_show_sock_state(__entry
->sock_state
)
322 #define DEFINE_RPC_SOCKET_EVENT_DONE(name) \
323 DEFINE_EVENT(xs_socket_event_done, name, \
325 struct rpc_xprt *xprt, \
326 struct socket *socket, \
329 TP_ARGS(xprt, socket, error))
331 DEFINE_RPC_SOCKET_EVENT(rpc_socket_state_change
);
332 DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_connect
);
333 DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_error
);
334 DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_reset_connection
);
335 DEFINE_RPC_SOCKET_EVENT(rpc_socket_close
);
336 DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown
);
338 DECLARE_EVENT_CLASS(rpc_xprt_event
,
339 TP_PROTO(struct rpc_xprt
*xprt
, __be32 xid
, int status
),
341 TP_ARGS(xprt
, xid
, status
),
346 __string(addr
, xprt
->address_strings
[RPC_DISPLAY_ADDR
])
347 __string(port
, xprt
->address_strings
[RPC_DISPLAY_PORT
])
352 __entry
->status
= status
;
353 __assign_str(addr
, xprt
->address_strings
[RPC_DISPLAY_ADDR
]);
354 __assign_str(port
, xprt
->address_strings
[RPC_DISPLAY_PORT
]);
357 TP_printk("peer=[%s]:%s xid=0x%x status=%d", __get_str(addr
),
358 __get_str(port
), be32_to_cpu(__entry
->xid
),
362 DEFINE_EVENT(rpc_xprt_event
, xprt_lookup_rqst
,
363 TP_PROTO(struct rpc_xprt
*xprt
, __be32 xid
, int status
),
364 TP_ARGS(xprt
, xid
, status
));
366 DEFINE_EVENT(rpc_xprt_event
, xprt_transmit
,
367 TP_PROTO(struct rpc_xprt
*xprt
, __be32 xid
, int status
),
368 TP_ARGS(xprt
, xid
, status
));
370 DEFINE_EVENT(rpc_xprt_event
, xprt_complete_rqst
,
371 TP_PROTO(struct rpc_xprt
*xprt
, __be32 xid
, int status
),
372 TP_ARGS(xprt
, xid
, status
));
374 TRACE_EVENT(xs_tcp_data_ready
,
375 TP_PROTO(struct rpc_xprt
*xprt
, int err
, unsigned int total
),
377 TP_ARGS(xprt
, err
, total
),
381 __field(unsigned int, total
)
382 __string(addr
, xprt
? xprt
->address_strings
[RPC_DISPLAY_ADDR
] :
384 __string(port
, xprt
? xprt
->address_strings
[RPC_DISPLAY_PORT
] :
390 __entry
->total
= total
;
391 __assign_str(addr
, xprt
?
392 xprt
->address_strings
[RPC_DISPLAY_ADDR
] : "(null)");
393 __assign_str(port
, xprt
?
394 xprt
->address_strings
[RPC_DISPLAY_PORT
] : "(null)");
397 TP_printk("peer=[%s]:%s err=%d total=%u", __get_str(addr
),
398 __get_str(port
), __entry
->err
, __entry
->total
)
401 #define rpc_show_sock_xprt_flags(flags) \
402 __print_flags(flags, "|", \
403 { TCP_RCV_LAST_FRAG, "TCP_RCV_LAST_FRAG" }, \
404 { TCP_RCV_COPY_FRAGHDR, "TCP_RCV_COPY_FRAGHDR" }, \
405 { TCP_RCV_COPY_XID, "TCP_RCV_COPY_XID" }, \
406 { TCP_RCV_COPY_DATA, "TCP_RCV_COPY_DATA" }, \
407 { TCP_RCV_READ_CALLDIR, "TCP_RCV_READ_CALLDIR" }, \
408 { TCP_RCV_COPY_CALLDIR, "TCP_RCV_COPY_CALLDIR" }, \
409 { TCP_RPC_REPLY, "TCP_RPC_REPLY" })
411 TRACE_EVENT(xs_tcp_data_recv
,
412 TP_PROTO(struct sock_xprt
*xs
),
417 __string(addr
, xs
->xprt
.address_strings
[RPC_DISPLAY_ADDR
])
418 __string(port
, xs
->xprt
.address_strings
[RPC_DISPLAY_PORT
])
420 __field(unsigned long, flags
)
421 __field(unsigned long, copied
)
422 __field(unsigned int, reclen
)
423 __field(unsigned long, offset
)
427 __assign_str(addr
, xs
->xprt
.address_strings
[RPC_DISPLAY_ADDR
]);
428 __assign_str(port
, xs
->xprt
.address_strings
[RPC_DISPLAY_PORT
]);
429 __entry
->xid
= xs
->tcp_xid
;
430 __entry
->flags
= xs
->tcp_flags
;
431 __entry
->copied
= xs
->tcp_copied
;
432 __entry
->reclen
= xs
->tcp_reclen
;
433 __entry
->offset
= xs
->tcp_offset
;
436 TP_printk("peer=[%s]:%s xid=0x%x flags=%s copied=%lu reclen=%u offset=%lu",
437 __get_str(addr
), __get_str(port
), be32_to_cpu(__entry
->xid
),
438 rpc_show_sock_xprt_flags(__entry
->flags
),
439 __entry
->copied
, __entry
->reclen
, __entry
->offset
)
442 #define show_rqstp_flags(flags) \
443 __print_flags(flags, "|", \
444 { (1UL << RQ_SECURE), "RQ_SECURE"}, \
445 { (1UL << RQ_LOCAL), "RQ_LOCAL"}, \
446 { (1UL << RQ_USEDEFERRAL), "RQ_USEDEFERRAL"}, \
447 { (1UL << RQ_DROPME), "RQ_DROPME"}, \
448 { (1UL << RQ_SPLICE_OK), "RQ_SPLICE_OK"}, \
449 { (1UL << RQ_VICTIM), "RQ_VICTIM"}, \
450 { (1UL << RQ_BUSY), "RQ_BUSY"})
452 TRACE_EVENT(svc_recv
,
453 TP_PROTO(struct svc_rqst
*rqst
, int status
),
455 TP_ARGS(rqst
, status
),
458 __field(struct sockaddr
*, addr
)
461 __field(unsigned long, flags
)
465 __entry
->addr
= (struct sockaddr
*)&rqst
->rq_addr
;
466 __entry
->xid
= status
> 0 ? rqst
->rq_xid
: 0;
467 __entry
->status
= status
;
468 __entry
->flags
= rqst
->rq_flags
;
471 TP_printk("addr=%pIScp xid=0x%x status=%d flags=%s", __entry
->addr
,
472 be32_to_cpu(__entry
->xid
), __entry
->status
,
473 show_rqstp_flags(__entry
->flags
))
476 DECLARE_EVENT_CLASS(svc_rqst_event
,
478 TP_PROTO(struct svc_rqst
*rqst
),
484 __field(unsigned long, flags
)
485 __dynamic_array(unsigned char, addr
, rqst
->rq_addrlen
)
489 __entry
->xid
= rqst
->rq_xid
;
490 __entry
->flags
= rqst
->rq_flags
;
491 memcpy(__get_dynamic_array(addr
),
492 &rqst
->rq_addr
, rqst
->rq_addrlen
);
495 TP_printk("addr=%pIScp rq_xid=0x%x flags=%s",
496 (struct sockaddr
*)__get_dynamic_array(addr
),
497 be32_to_cpu(__entry
->xid
),
498 show_rqstp_flags(__entry
->flags
))
501 DEFINE_EVENT(svc_rqst_event
, svc_defer
,
502 TP_PROTO(struct svc_rqst
*rqst
),
505 DEFINE_EVENT(svc_rqst_event
, svc_drop
,
506 TP_PROTO(struct svc_rqst
*rqst
),
509 DECLARE_EVENT_CLASS(svc_rqst_status
,
511 TP_PROTO(struct svc_rqst
*rqst
, int status
),
513 TP_ARGS(rqst
, status
),
516 __field(struct sockaddr
*, addr
)
520 __field(unsigned long, flags
)
524 __entry
->addr
= (struct sockaddr
*)&rqst
->rq_addr
;
525 __entry
->xid
= rqst
->rq_xid
;
526 __entry
->status
= status
;
527 __entry
->flags
= rqst
->rq_flags
;
530 TP_printk("addr=%pIScp rq_xid=0x%x status=%d flags=%s",
531 __entry
->addr
, be32_to_cpu(__entry
->xid
),
532 __entry
->status
, show_rqstp_flags(__entry
->flags
))
535 DEFINE_EVENT(svc_rqst_status
, svc_process
,
536 TP_PROTO(struct svc_rqst
*rqst
, int status
),
537 TP_ARGS(rqst
, status
));
539 DEFINE_EVENT(svc_rqst_status
, svc_send
,
540 TP_PROTO(struct svc_rqst
*rqst
, int status
),
541 TP_ARGS(rqst
, status
));
543 #define show_svc_xprt_flags(flags) \
544 __print_flags(flags, "|", \
545 { (1UL << XPT_BUSY), "XPT_BUSY"}, \
546 { (1UL << XPT_CONN), "XPT_CONN"}, \
547 { (1UL << XPT_CLOSE), "XPT_CLOSE"}, \
548 { (1UL << XPT_DATA), "XPT_DATA"}, \
549 { (1UL << XPT_TEMP), "XPT_TEMP"}, \
550 { (1UL << XPT_DEAD), "XPT_DEAD"}, \
551 { (1UL << XPT_CHNGBUF), "XPT_CHNGBUF"}, \
552 { (1UL << XPT_DEFERRED), "XPT_DEFERRED"}, \
553 { (1UL << XPT_OLD), "XPT_OLD"}, \
554 { (1UL << XPT_LISTENER), "XPT_LISTENER"}, \
555 { (1UL << XPT_CACHE_AUTH), "XPT_CACHE_AUTH"}, \
556 { (1UL << XPT_LOCAL), "XPT_LOCAL"})
558 TRACE_EVENT(svc_xprt_do_enqueue
,
559 TP_PROTO(struct svc_xprt
*xprt
, struct svc_rqst
*rqst
),
564 __field(struct svc_xprt
*, xprt
)
566 __field(unsigned long, flags
)
567 __dynamic_array(unsigned char, addr
, xprt
!= NULL
?
568 xprt
->xpt_remotelen
: 0)
572 __entry
->xprt
= xprt
;
573 __entry
->pid
= rqst
? rqst
->rq_task
->pid
: 0;
575 memcpy(__get_dynamic_array(addr
),
577 xprt
->xpt_remotelen
);
578 __entry
->flags
= xprt
->xpt_flags
;
583 TP_printk("xprt=0x%p addr=%pIScp pid=%d flags=%s", __entry
->xprt
,
584 __get_dynamic_array_len(addr
) != 0 ?
585 (struct sockaddr
*)__get_dynamic_array(addr
) : NULL
,
586 __entry
->pid
, show_svc_xprt_flags(__entry
->flags
))
589 DECLARE_EVENT_CLASS(svc_xprt_event
,
590 TP_PROTO(struct svc_xprt
*xprt
),
595 __field(struct svc_xprt
*, xprt
)
596 __field(unsigned long, flags
)
597 __dynamic_array(unsigned char, addr
, xprt
!= NULL
?
598 xprt
->xpt_remotelen
: 0)
602 __entry
->xprt
= xprt
;
604 memcpy(__get_dynamic_array(addr
),
606 xprt
->xpt_remotelen
);
607 __entry
->flags
= xprt
->xpt_flags
;
612 TP_printk("xprt=0x%p addr=%pIScp flags=%s", __entry
->xprt
,
613 __get_dynamic_array_len(addr
) != 0 ?
614 (struct sockaddr
*)__get_dynamic_array(addr
) : NULL
,
615 show_svc_xprt_flags(__entry
->flags
))
618 DEFINE_EVENT(svc_xprt_event
, svc_xprt_dequeue
,
619 TP_PROTO(struct svc_xprt
*xprt
),
622 DEFINE_EVENT(svc_xprt_event
, svc_xprt_no_write_space
,
623 TP_PROTO(struct svc_xprt
*xprt
),
626 TRACE_EVENT(svc_wake_up
,
639 TP_printk("pid=%d", __entry
->pid
)
642 TRACE_EVENT(svc_handle_xprt
,
643 TP_PROTO(struct svc_xprt
*xprt
, int len
),
648 __field(struct svc_xprt
*, xprt
)
650 __field(unsigned long, flags
)
651 __dynamic_array(unsigned char, addr
, xprt
!= NULL
?
652 xprt
->xpt_remotelen
: 0)
656 __entry
->xprt
= xprt
;
659 memcpy(__get_dynamic_array(addr
),
661 xprt
->xpt_remotelen
);
662 __entry
->flags
= xprt
->xpt_flags
;
667 TP_printk("xprt=0x%p addr=%pIScp len=%d flags=%s", __entry
->xprt
,
668 __get_dynamic_array_len(addr
) != 0 ?
669 (struct sockaddr
*)__get_dynamic_array(addr
) : NULL
,
670 __entry
->len
, show_svc_xprt_flags(__entry
->flags
))
674 DECLARE_EVENT_CLASS(svc_deferred_event
,
675 TP_PROTO(struct svc_deferred_req
*dr
),
681 __dynamic_array(unsigned char, addr
, dr
->addrlen
)
685 __entry
->xid
= *(__be32
*)(dr
->args
+ (dr
->xprt_hlen
>>2));
686 memcpy(__get_dynamic_array(addr
), &dr
->addr
, dr
->addrlen
);
689 TP_printk("addr=%pIScp xid=0x%x",
690 (struct sockaddr
*)__get_dynamic_array(addr
),
691 be32_to_cpu(__entry
->xid
))
694 DEFINE_EVENT(svc_deferred_event
, svc_drop_deferred
,
695 TP_PROTO(struct svc_deferred_req
*dr
),
697 DEFINE_EVENT(svc_deferred_event
, svc_revisit_deferred
,
698 TP_PROTO(struct svc_deferred_req
*dr
),
700 #endif /* _TRACE_SUNRPC_H */
702 #include <trace/define_trace.h>