sunrpc.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM sunrpc
  3. #if !defined(_TRACE_SUNRPC_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_SUNRPC_H
  5. #include <linux/sunrpc/sched.h>
  6. #include <linux/sunrpc/clnt.h>
  7. #include <net/tcp_states.h>
  8. #include <linux/net.h>
  9. #include <linux/tracepoint.h>
  10. DECLARE_EVENT_CLASS(rpc_task_status,
  11. TP_PROTO(struct rpc_task *task),
  12. TP_ARGS(task),
  13. TP_STRUCT__entry(
  14. __field(unsigned int, task_id)
  15. __field(unsigned int, client_id)
  16. __field(int, status)
  17. ),
  18. TP_fast_assign(
  19. __entry->task_id = task->tk_pid;
  20. __entry->client_id = task->tk_client->cl_clid;
  21. __entry->status = task->tk_status;
  22. ),
  23. TP_printk("task:%u@%u, status %d",
  24. __entry->task_id, __entry->client_id,
  25. __entry->status)
  26. );
  27. DEFINE_EVENT(rpc_task_status, rpc_call_status,
  28. TP_PROTO(struct rpc_task *task),
  29. TP_ARGS(task)
  30. );
  31. DEFINE_EVENT(rpc_task_status, rpc_bind_status,
  32. TP_PROTO(struct rpc_task *task),
  33. TP_ARGS(task)
  34. );
  35. TRACE_EVENT(rpc_connect_status,
  36. TP_PROTO(struct rpc_task *task, int status),
  37. TP_ARGS(task, status),
  38. TP_STRUCT__entry(
  39. __field(unsigned int, task_id)
  40. __field(unsigned int, client_id)
  41. __field(int, status)
  42. ),
  43. TP_fast_assign(
  44. __entry->task_id = task->tk_pid;
  45. __entry->client_id = task->tk_client->cl_clid;
  46. __entry->status = status;
  47. ),
  48. TP_printk("task:%u@%u, status %d",
  49. __entry->task_id, __entry->client_id,
  50. __entry->status)
  51. );
  52. DECLARE_EVENT_CLASS(rpc_task_running,
  53. TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
  54. TP_ARGS(clnt, task, action),
  55. TP_STRUCT__entry(
  56. __field(unsigned int, task_id)
  57. __field(unsigned int, client_id)
  58. __field(const void *, action)
  59. __field(unsigned long, runstate)
  60. __field(int, status)
  61. __field(unsigned short, flags)
  62. ),
  63. TP_fast_assign(
  64. __entry->client_id = clnt->cl_clid;
  65. __entry->task_id = task->tk_pid;
  66. __entry->action = action;
  67. __entry->runstate = task->tk_runstate;
  68. __entry->status = task->tk_status;
  69. __entry->flags = task->tk_flags;
  70. ),
  71. TP_printk("task:%u@%u flags=%4.4x state=%4.4lx status=%d action=%pf",
  72. __entry->task_id, __entry->client_id,
  73. __entry->flags,
  74. __entry->runstate,
  75. __entry->status,
  76. __entry->action
  77. )
  78. );
  79. DEFINE_EVENT(rpc_task_running, rpc_task_begin,
  80. TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
  81. TP_ARGS(clnt, task, action)
  82. );
  83. DEFINE_EVENT(rpc_task_running, rpc_task_run_action,
  84. TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
  85. TP_ARGS(clnt, task, action)
  86. );
  87. DEFINE_EVENT(rpc_task_running, rpc_task_complete,
  88. TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
  89. TP_ARGS(clnt, task, action)
  90. );
  91. DECLARE_EVENT_CLASS(rpc_task_queued,
  92. TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
  93. TP_ARGS(clnt, task, q),
  94. TP_STRUCT__entry(
  95. __field(unsigned int, task_id)
  96. __field(unsigned int, client_id)
  97. __field(unsigned long, timeout)
  98. __field(unsigned long, runstate)
  99. __field(int, status)
  100. __field(unsigned short, flags)
  101. __string(q_name, rpc_qname(q))
  102. ),
  103. TP_fast_assign(
  104. __entry->client_id = clnt->cl_clid;
  105. __entry->task_id = task->tk_pid;
  106. __entry->timeout = task->tk_timeout;
  107. __entry->runstate = task->tk_runstate;
  108. __entry->status = task->tk_status;
  109. __entry->flags = task->tk_flags;
  110. __assign_str(q_name, rpc_qname(q));
  111. ),
  112. TP_printk("task:%u@%u flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s",
  113. __entry->task_id, __entry->client_id,
  114. __entry->flags,
  115. __entry->runstate,
  116. __entry->status,
  117. __entry->timeout,
  118. __get_str(q_name)
  119. )
  120. );
  121. DEFINE_EVENT(rpc_task_queued, rpc_task_sleep,
  122. TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
  123. TP_ARGS(clnt, task, q)
  124. );
  125. DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,
  126. TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
  127. TP_ARGS(clnt, task, q)
  128. );
  129. #define rpc_show_socket_state(state) \
  130. __print_symbolic(state, \
  131. { SS_FREE, "FREE" }, \
  132. { SS_UNCONNECTED, "UNCONNECTED" }, \
  133. { SS_CONNECTING, "CONNECTING," }, \
  134. { SS_CONNECTED, "CONNECTED," }, \
  135. { SS_DISCONNECTING, "DISCONNECTING" })
  136. #define rpc_show_sock_state(state) \
  137. __print_symbolic(state, \
  138. { TCP_ESTABLISHED, "ESTABLISHED" }, \
  139. { TCP_SYN_SENT, "SYN_SENT" }, \
  140. { TCP_SYN_RECV, "SYN_RECV" }, \
  141. { TCP_FIN_WAIT1, "FIN_WAIT1" }, \
  142. { TCP_FIN_WAIT2, "FIN_WAIT2" }, \
  143. { TCP_TIME_WAIT, "TIME_WAIT" }, \
  144. { TCP_CLOSE, "CLOSE" }, \
  145. { TCP_CLOSE_WAIT, "CLOSE_WAIT" }, \
  146. { TCP_LAST_ACK, "LAST_ACK" }, \
  147. { TCP_LISTEN, "LISTEN" }, \
  148. { TCP_CLOSING, "CLOSING" })
  149. DECLARE_EVENT_CLASS(xs_socket_event,
  150. TP_PROTO(
  151. struct rpc_xprt *xprt,
  152. struct socket *socket
  153. ),
  154. TP_ARGS(xprt, socket),
  155. TP_STRUCT__entry(
  156. __field(unsigned int, socket_state)
  157. __field(unsigned int, sock_state)
  158. __field(unsigned long long, ino)
  159. __string(dstaddr,
  160. xprt->address_strings[RPC_DISPLAY_ADDR])
  161. __string(dstport,
  162. xprt->address_strings[RPC_DISPLAY_PORT])
  163. ),
  164. TP_fast_assign(
  165. struct inode *inode = SOCK_INODE(socket);
  166. __entry->socket_state = socket->state;
  167. __entry->sock_state = socket->sk->sk_state;
  168. __entry->ino = (unsigned long long)inode->i_ino;
  169. __assign_str(dstaddr,
  170. xprt->address_strings[RPC_DISPLAY_ADDR]);
  171. __assign_str(dstport,
  172. xprt->address_strings[RPC_DISPLAY_PORT]);
  173. ),
  174. TP_printk(
  175. "socket:[%llu] dstaddr=%s/%s "
  176. "state=%u (%s) sk_state=%u (%s)",
  177. __entry->ino, __get_str(dstaddr), __get_str(dstport),
  178. __entry->socket_state,
  179. rpc_show_socket_state(__entry->socket_state),
  180. __entry->sock_state,
  181. rpc_show_sock_state(__entry->sock_state)
  182. )
  183. );
  184. #define DEFINE_RPC_SOCKET_EVENT(name) \
  185. DEFINE_EVENT(xs_socket_event, name, \
  186. TP_PROTO( \
  187. struct rpc_xprt *xprt, \
  188. struct socket *socket \
  189. ), \
  190. TP_ARGS(xprt, socket))
  191. DECLARE_EVENT_CLASS(xs_socket_event_done,
  192. TP_PROTO(
  193. struct rpc_xprt *xprt,
  194. struct socket *socket,
  195. int error
  196. ),
  197. TP_ARGS(xprt, socket, error),
  198. TP_STRUCT__entry(
  199. __field(int, error)
  200. __field(unsigned int, socket_state)
  201. __field(unsigned int, sock_state)
  202. __field(unsigned long long, ino)
  203. __string(dstaddr,
  204. xprt->address_strings[RPC_DISPLAY_ADDR])
  205. __string(dstport,
  206. xprt->address_strings[RPC_DISPLAY_PORT])
  207. ),
  208. TP_fast_assign(
  209. struct inode *inode = SOCK_INODE(socket);
  210. __entry->socket_state = socket->state;
  211. __entry->sock_state = socket->sk->sk_state;
  212. __entry->ino = (unsigned long long)inode->i_ino;
  213. __entry->error = error;
  214. __assign_str(dstaddr,
  215. xprt->address_strings[RPC_DISPLAY_ADDR]);
  216. __assign_str(dstport,
  217. xprt->address_strings[RPC_DISPLAY_PORT]);
  218. ),
  219. TP_printk(
  220. "error=%d socket:[%llu] dstaddr=%s/%s "
  221. "state=%u (%s) sk_state=%u (%s)",
  222. __entry->error,
  223. __entry->ino, __get_str(dstaddr), __get_str(dstport),
  224. __entry->socket_state,
  225. rpc_show_socket_state(__entry->socket_state),
  226. __entry->sock_state,
  227. rpc_show_sock_state(__entry->sock_state)
  228. )
  229. );
  230. #define DEFINE_RPC_SOCKET_EVENT_DONE(name) \
  231. DEFINE_EVENT(xs_socket_event_done, name, \
  232. TP_PROTO( \
  233. struct rpc_xprt *xprt, \
  234. struct socket *socket, \
  235. int error \
  236. ), \
  237. TP_ARGS(xprt, socket, error))
  238. DEFINE_RPC_SOCKET_EVENT(rpc_socket_state_change);
  239. DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_connect);
  240. DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_reset_connection);
  241. DEFINE_RPC_SOCKET_EVENT(rpc_socket_close);
  242. DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown);
  243. #endif /* _TRACE_SUNRPC_H */
  244. #include <trace/define_trace.h>