sunrpc.h 20.1 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
2 3 4 5 6 7 8 9
#undef TRACE_SYSTEM
#define TRACE_SYSTEM sunrpc

#if !defined(_TRACE_SUNRPC_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_SUNRPC_H

#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/clnt.h>
10
#include <linux/sunrpc/svc.h>
11
#include <linux/sunrpc/xprtsock.h>
12
#include <linux/sunrpc/svc_xprt.h>
13 14
#include <net/tcp_states.h>
#include <linux/net.h>
15 16
#include <linux/tracepoint.h>

17 18 19 20 21 22 23
DECLARE_EVENT_CLASS(rpc_task_status,

	TP_PROTO(struct rpc_task *task),

	TP_ARGS(task),

	TP_STRUCT__entry(
24 25
		__field(unsigned int, task_id)
		__field(unsigned int, client_id)
26 27 28 29
		__field(int, status)
	),

	TP_fast_assign(
30 31
		__entry->task_id = task->tk_pid;
		__entry->client_id = task->tk_client->cl_clid;
32 33 34
		__entry->status = task->tk_status;
	),

35
	TP_printk("task:%u@%u status=%d",
36 37
		__entry->task_id, __entry->client_id,
		__entry->status)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
);

DEFINE_EVENT(rpc_task_status, rpc_call_status,
	TP_PROTO(struct rpc_task *task),

	TP_ARGS(task)
);

DEFINE_EVENT(rpc_task_status, rpc_bind_status,
	TP_PROTO(struct rpc_task *task),

	TP_ARGS(task)
);

TRACE_EVENT(rpc_connect_status,
53
	TP_PROTO(const struct rpc_task *task),
54

55
	TP_ARGS(task),
56 57

	TP_STRUCT__entry(
58 59
		__field(unsigned int, task_id)
		__field(unsigned int, client_id)
60 61 62 63
		__field(int, status)
	),

	TP_fast_assign(
64 65
		__entry->task_id = task->tk_pid;
		__entry->client_id = task->tk_client->cl_clid;
66
		__entry->status = task->tk_status;
67 68
	),

69
	TP_printk("task:%u@%u status=%d",
70 71
		__entry->task_id, __entry->client_id,
		__entry->status)
72 73
);

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
TRACE_EVENT(rpc_request,
	TP_PROTO(const struct rpc_task *task),

	TP_ARGS(task),

	TP_STRUCT__entry(
		__field(unsigned int, task_id)
		__field(unsigned int, client_id)
		__field(int, version)
		__field(bool, async)
		__string(progname, task->tk_client->cl_program->name)
		__string(procname, rpc_proc_name(task))
	),

	TP_fast_assign(
		__entry->task_id = task->tk_pid;
		__entry->client_id = task->tk_client->cl_clid;
		__entry->version = task->tk_client->cl_vers;
		__entry->async = RPC_IS_ASYNC(task);
		__assign_str(progname, task->tk_client->cl_program->name)
		__assign_str(procname, rpc_proc_name(task))
	),

	TP_printk("task:%u@%u %sv%d %s (%ssync)",
		__entry->task_id, __entry->client_id,
		__get_str(progname), __entry->version,
		__get_str(procname), __entry->async ? "a": ""
		)
);

104 105
DECLARE_EVENT_CLASS(rpc_task_running,

106
	TP_PROTO(const struct rpc_task *task, const void *action),
107

108
	TP_ARGS(task, action),
109 110

	TP_STRUCT__entry(
111 112
		__field(unsigned int, task_id)
		__field(unsigned int, client_id)
113 114 115 116 117 118 119
		__field(const void *, action)
		__field(unsigned long, runstate)
		__field(int, status)
		__field(unsigned short, flags)
		),

	TP_fast_assign(
120 121
		__entry->client_id = task->tk_client ?
				     task->tk_client->cl_clid : -1;
122
		__entry->task_id = task->tk_pid;
123 124 125 126 127 128
		__entry->action = action;
		__entry->runstate = task->tk_runstate;
		__entry->status = task->tk_status;
		__entry->flags = task->tk_flags;
		),

129
	TP_printk("task:%u@%d flags=%4.4x state=%4.4lx status=%d action=%pf",
130
		__entry->task_id, __entry->client_id,
131 132 133 134 135 136 137 138 139
		__entry->flags,
		__entry->runstate,
		__entry->status,
		__entry->action
		)
);

DEFINE_EVENT(rpc_task_running, rpc_task_begin,

140
	TP_PROTO(const struct rpc_task *task, const void *action),
141

142
	TP_ARGS(task, action)
143 144 145 146 147

);

DEFINE_EVENT(rpc_task_running, rpc_task_run_action,

148
	TP_PROTO(const struct rpc_task *task, const void *action),
149

150
	TP_ARGS(task, action)
151 152 153 154 155

);

DEFINE_EVENT(rpc_task_running, rpc_task_complete,

156
	TP_PROTO(const struct rpc_task *task, const void *action),
157

158
	TP_ARGS(task, action)
159 160 161 162 163

);

DECLARE_EVENT_CLASS(rpc_task_queued,

164
	TP_PROTO(const struct rpc_task *task, const struct rpc_wait_queue *q),
165

166
	TP_ARGS(task, q),
167 168

	TP_STRUCT__entry(
169 170
		__field(unsigned int, task_id)
		__field(unsigned int, client_id)
171 172 173 174
		__field(unsigned long, timeout)
		__field(unsigned long, runstate)
		__field(int, status)
		__field(unsigned short, flags)
175
		__string(q_name, rpc_qname(q))
176 177 178
		),

	TP_fast_assign(
179 180
		__entry->client_id = task->tk_client ?
				     task->tk_client->cl_clid : -1;
181
		__entry->task_id = task->tk_pid;
182 183 184 185
		__entry->timeout = task->tk_timeout;
		__entry->runstate = task->tk_runstate;
		__entry->status = task->tk_status;
		__entry->flags = task->tk_flags;
186
		__assign_str(q_name, rpc_qname(q));
187 188
		),

189
	TP_printk("task:%u@%d flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s",
190
		__entry->task_id, __entry->client_id,
191 192 193 194
		__entry->flags,
		__entry->runstate,
		__entry->status,
		__entry->timeout,
195
		__get_str(q_name)
196 197 198 199 200
		)
);

DEFINE_EVENT(rpc_task_queued, rpc_task_sleep,

201
	TP_PROTO(const struct rpc_task *task, const struct rpc_wait_queue *q),
202

203
	TP_ARGS(task, q)
204 205 206 207 208

);

DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,

209
	TP_PROTO(const struct rpc_task *task, const struct rpc_wait_queue *q),
210

211
	TP_ARGS(task, q)
212 213 214

);

215 216 217 218 219 220 221 222 223 224 225 226
TRACE_EVENT(rpc_stats_latency,

	TP_PROTO(
		const struct rpc_task *task,
		ktime_t backlog,
		ktime_t rtt,
		ktime_t execute
	),

	TP_ARGS(task, backlog, rtt, execute),

	TP_STRUCT__entry(
227 228
		__field(unsigned int, task_id)
		__field(unsigned int, client_id)
229 230 231 232 233 234 235 236 237 238
		__field(u32, xid)
		__field(int, version)
		__string(progname, task->tk_client->cl_program->name)
		__string(procname, rpc_proc_name(task))
		__field(unsigned long, backlog)
		__field(unsigned long, rtt)
		__field(unsigned long, execute)
	),

	TP_fast_assign(
239 240
		__entry->client_id = task->tk_client->cl_clid;
		__entry->task_id = task->tk_pid;
241 242 243 244 245 246 247 248 249
		__entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid);
		__entry->version = task->tk_client->cl_vers;
		__assign_str(progname, task->tk_client->cl_program->name)
		__assign_str(procname, rpc_proc_name(task))
		__entry->backlog = ktime_to_us(backlog);
		__entry->rtt = ktime_to_us(rtt);
		__entry->execute = ktime_to_us(execute);
	),

250 251
	TP_printk("task:%u@%d xid=0x%08x %sv%d %s backlog=%lu rtt=%lu execute=%lu",
		__entry->task_id, __entry->client_id, __entry->xid,
252 253 254 255
		__get_str(progname), __entry->version, __get_str(procname),
		__entry->backlog, __entry->rtt, __entry->execute)
);

256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
/*
 * First define the enums in the below macros to be exported to userspace
 * via TRACE_DEFINE_ENUM().
 */
#undef EM
#undef EMe
#define EM(a, b)	TRACE_DEFINE_ENUM(a);
#define EMe(a, b)	TRACE_DEFINE_ENUM(a);

#define RPC_SHOW_SOCKET				\
	EM( SS_FREE, "FREE" )			\
	EM( SS_UNCONNECTED, "UNCONNECTED" )	\
	EM( SS_CONNECTING, "CONNECTING," )	\
	EM( SS_CONNECTED, "CONNECTED," )	\
	EMe(SS_DISCONNECTING, "DISCONNECTING" )

272
#define rpc_show_socket_state(state) \
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
	__print_symbolic(state, RPC_SHOW_SOCKET)

RPC_SHOW_SOCKET

#define RPC_SHOW_SOCK				\
	EM( TCP_ESTABLISHED, "ESTABLISHED" )	\
	EM( TCP_SYN_SENT, "SYN_SENT" )		\
	EM( TCP_SYN_RECV, "SYN_RECV" )		\
	EM( TCP_FIN_WAIT1, "FIN_WAIT1" )	\
	EM( TCP_FIN_WAIT2, "FIN_WAIT2" )	\
	EM( TCP_TIME_WAIT, "TIME_WAIT" )	\
	EM( TCP_CLOSE, "CLOSE" )		\
	EM( TCP_CLOSE_WAIT, "CLOSE_WAIT" )	\
	EM( TCP_LAST_ACK, "LAST_ACK" )		\
	EM( TCP_LISTEN, "LISTEN" )		\
	EMe( TCP_CLOSING, "CLOSING" )
289 290

#define rpc_show_sock_state(state) \
291 292 293 294 295 296 297 298 299 300 301 302
	__print_symbolic(state, RPC_SHOW_SOCK)

RPC_SHOW_SOCK

/*
 * Now redefine the EM() and EMe() macros to map the enums to the strings
 * that will be printed in the output.
 */
#undef EM
#undef EMe
#define EM(a, b)	{a, b},
#define EMe(a, b)	{a, b}
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406

DECLARE_EVENT_CLASS(xs_socket_event,

		TP_PROTO(
			struct rpc_xprt *xprt,
			struct socket *socket
		),

		TP_ARGS(xprt, socket),

		TP_STRUCT__entry(
			__field(unsigned int, socket_state)
			__field(unsigned int, sock_state)
			__field(unsigned long long, ino)
			__string(dstaddr,
				xprt->address_strings[RPC_DISPLAY_ADDR])
			__string(dstport,
				xprt->address_strings[RPC_DISPLAY_PORT])
		),

		TP_fast_assign(
			struct inode *inode = SOCK_INODE(socket);
			__entry->socket_state = socket->state;
			__entry->sock_state = socket->sk->sk_state;
			__entry->ino = (unsigned long long)inode->i_ino;
			__assign_str(dstaddr,
				xprt->address_strings[RPC_DISPLAY_ADDR]);
			__assign_str(dstport,
				xprt->address_strings[RPC_DISPLAY_PORT]);
		),

		TP_printk(
			"socket:[%llu] dstaddr=%s/%s "
			"state=%u (%s) sk_state=%u (%s)",
			__entry->ino, __get_str(dstaddr), __get_str(dstport),
			__entry->socket_state,
			rpc_show_socket_state(__entry->socket_state),
			__entry->sock_state,
			rpc_show_sock_state(__entry->sock_state)
		)
);
#define DEFINE_RPC_SOCKET_EVENT(name) \
	DEFINE_EVENT(xs_socket_event, name, \
			TP_PROTO( \
				struct rpc_xprt *xprt, \
				struct socket *socket \
			), \
			TP_ARGS(xprt, socket))

DECLARE_EVENT_CLASS(xs_socket_event_done,

		TP_PROTO(
			struct rpc_xprt *xprt,
			struct socket *socket,
			int error
		),

		TP_ARGS(xprt, socket, error),

		TP_STRUCT__entry(
			__field(int, error)
			__field(unsigned int, socket_state)
			__field(unsigned int, sock_state)
			__field(unsigned long long, ino)
			__string(dstaddr,
				xprt->address_strings[RPC_DISPLAY_ADDR])
			__string(dstport,
				xprt->address_strings[RPC_DISPLAY_PORT])
		),

		TP_fast_assign(
			struct inode *inode = SOCK_INODE(socket);
			__entry->socket_state = socket->state;
			__entry->sock_state = socket->sk->sk_state;
			__entry->ino = (unsigned long long)inode->i_ino;
			__entry->error = error;
			__assign_str(dstaddr,
				xprt->address_strings[RPC_DISPLAY_ADDR]);
			__assign_str(dstport,
				xprt->address_strings[RPC_DISPLAY_PORT]);
		),

		TP_printk(
			"error=%d socket:[%llu] dstaddr=%s/%s "
			"state=%u (%s) sk_state=%u (%s)",
			__entry->error,
			__entry->ino, __get_str(dstaddr), __get_str(dstport),
			__entry->socket_state,
			rpc_show_socket_state(__entry->socket_state),
			__entry->sock_state,
			rpc_show_sock_state(__entry->sock_state)
		)
);
#define DEFINE_RPC_SOCKET_EVENT_DONE(name) \
	DEFINE_EVENT(xs_socket_event_done, name, \
			TP_PROTO( \
				struct rpc_xprt *xprt, \
				struct socket *socket, \
				int error \
			), \
			TP_ARGS(xprt, socket, error))

DEFINE_RPC_SOCKET_EVENT(rpc_socket_state_change);
DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_connect);
407
DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_error);
408 409 410 411
DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_reset_connection);
DEFINE_RPC_SOCKET_EVENT(rpc_socket_close);
DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown);

412 413 414 415 416 417
DECLARE_EVENT_CLASS(rpc_xprt_event,
	TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status),

	TP_ARGS(xprt, xid, status),

	TP_STRUCT__entry(
418
		__field(u32, xid)
419 420 421 422 423 424
		__field(int, status)
		__string(addr, xprt->address_strings[RPC_DISPLAY_ADDR])
		__string(port, xprt->address_strings[RPC_DISPLAY_PORT])
	),

	TP_fast_assign(
425
		__entry->xid = be32_to_cpu(xid);
426 427 428 429 430
		__entry->status = status;
		__assign_str(addr, xprt->address_strings[RPC_DISPLAY_ADDR]);
		__assign_str(port, xprt->address_strings[RPC_DISPLAY_PORT]);
	),

431 432
	TP_printk("peer=[%s]:%s xid=0x%08x status=%d", __get_str(addr),
			__get_str(port), __entry->xid,
433 434 435
			__entry->status)
);

C
Chuck Lever 已提交
436 437 438 439
DEFINE_EVENT(rpc_xprt_event, xprt_timer,
	TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status),
	TP_ARGS(xprt, xid, status));

440 441 442 443 444 445 446 447 448 449 450 451
DEFINE_EVENT(rpc_xprt_event, xprt_lookup_rqst,
	TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status),
	TP_ARGS(xprt, xid, status));

DEFINE_EVENT(rpc_xprt_event, xprt_transmit,
	TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status),
	TP_ARGS(xprt, xid, status));

DEFINE_EVENT(rpc_xprt_event, xprt_complete_rqst,
	TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status),
	TP_ARGS(xprt, xid, status));

452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
TRACE_EVENT(xprt_ping,
	TP_PROTO(const struct rpc_xprt *xprt, int status),

	TP_ARGS(xprt, status),

	TP_STRUCT__entry(
		__field(int, status)
		__string(addr, xprt->address_strings[RPC_DISPLAY_ADDR])
		__string(port, xprt->address_strings[RPC_DISPLAY_PORT])
	),

	TP_fast_assign(
		__entry->status = status;
		__assign_str(addr, xprt->address_strings[RPC_DISPLAY_ADDR]);
		__assign_str(port, xprt->address_strings[RPC_DISPLAY_PORT]);
	),

	TP_printk("peer=[%s]:%s status=%d",
			__get_str(addr), __get_str(port), __entry->status)
);

473 474
TRACE_EVENT(xs_stream_read_data,
	TP_PROTO(struct rpc_xprt *xprt, ssize_t err, size_t total),
475 476 477 478

	TP_ARGS(xprt, err, total),

	TP_STRUCT__entry(
479 480
		__field(ssize_t, err)
		__field(size_t, total)
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
		__string(addr, xprt ? xprt->address_strings[RPC_DISPLAY_ADDR] :
				"(null)")
		__string(port, xprt ? xprt->address_strings[RPC_DISPLAY_PORT] :
				"(null)")
	),

	TP_fast_assign(
		__entry->err = err;
		__entry->total = total;
		__assign_str(addr, xprt ?
			xprt->address_strings[RPC_DISPLAY_ADDR] : "(null)");
		__assign_str(port, xprt ?
			xprt->address_strings[RPC_DISPLAY_PORT] : "(null)");
	),

496
	TP_printk("peer=[%s]:%s err=%zd total=%zu", __get_str(addr),
497 498 499
			__get_str(port), __entry->err, __entry->total)
);

500
TRACE_EVENT(xs_stream_read_request,
501 502 503 504 505 506 507
	TP_PROTO(struct sock_xprt *xs),

	TP_ARGS(xs),

	TP_STRUCT__entry(
		__string(addr, xs->xprt.address_strings[RPC_DISPLAY_ADDR])
		__string(port, xs->xprt.address_strings[RPC_DISPLAY_PORT])
508
		__field(u32, xid)
509 510
		__field(unsigned long, copied)
		__field(unsigned int, reclen)
511
		__field(unsigned int, offset)
512 513 514 515 516
	),

	TP_fast_assign(
		__assign_str(addr, xs->xprt.address_strings[RPC_DISPLAY_ADDR]);
		__assign_str(port, xs->xprt.address_strings[RPC_DISPLAY_PORT]);
517 518 519 520
		__entry->xid = be32_to_cpu(xs->recv.xid);
		__entry->copied = xs->recv.copied;
		__entry->reclen = xs->recv.len;
		__entry->offset = xs->recv.offset;
521 522
	),

523
	TP_printk("peer=[%s]:%s xid=0x%08x copied=%lu reclen=%u offset=%u",
524
			__get_str(addr), __get_str(port), __entry->xid,
525 526 527
			__entry->copied, __entry->reclen, __entry->offset)
);

528 529 530 531
#define show_rqstp_flags(flags)						\
	__print_flags(flags, "|",					\
		{ (1UL << RQ_SECURE),		"RQ_SECURE"},		\
		{ (1UL << RQ_LOCAL),		"RQ_LOCAL"},		\
532
		{ (1UL << RQ_USEDEFERRAL),	"RQ_USEDEFERRAL"},	\
533
		{ (1UL << RQ_DROPME),		"RQ_DROPME"},		\
534
		{ (1UL << RQ_SPLICE_OK),	"RQ_SPLICE_OK"},	\
535 536
		{ (1UL << RQ_VICTIM),		"RQ_VICTIM"},		\
		{ (1UL << RQ_BUSY),		"RQ_BUSY"})
537

538
TRACE_EVENT(svc_recv,
C
Chuck Lever 已提交
539
	TP_PROTO(struct svc_rqst *rqst, int len),
540

C
Chuck Lever 已提交
541
	TP_ARGS(rqst, len),
542 543

	TP_STRUCT__entry(
544
		__field(u32, xid)
C
Chuck Lever 已提交
545
		__field(int, len)
546
		__field(unsigned long, flags)
547
		__string(addr, rqst->rq_xprt->xpt_remotebuf)
548 549 550
	),

	TP_fast_assign(
C
Chuck Lever 已提交
551 552
		__entry->xid = be32_to_cpu(rqst->rq_xid);
		__entry->len = len;
553
		__entry->flags = rqst->rq_flags;
554
		__assign_str(addr, rqst->rq_xprt->xpt_remotebuf);
555 556
	),

557 558
	TP_printk("addr=%s xid=0x%08x len=%d flags=%s",
			__get_str(addr), __entry->xid, __entry->len,
559
			show_rqstp_flags(__entry->flags))
560 561
);

562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
TRACE_EVENT(svc_process,
	TP_PROTO(const struct svc_rqst *rqst, const char *name),

	TP_ARGS(rqst, name),

	TP_STRUCT__entry(
		__field(u32, xid)
		__field(u32, vers)
		__field(u32, proc)
		__string(service, name)
		__string(addr, rqst->rq_xprt->xpt_remotebuf)
	),

	TP_fast_assign(
		__entry->xid = be32_to_cpu(rqst->rq_xid);
		__entry->vers = rqst->rq_vers;
		__entry->proc = rqst->rq_proc;
		__assign_str(service, name);
		__assign_str(addr, rqst->rq_xprt->xpt_remotebuf);
	),

	TP_printk("addr=%s xid=0x%08x service=%s vers=%u proc=%u",
			__get_str(addr), __entry->xid,
			__get_str(service), __entry->vers, __entry->proc)
);

588 589 590 591 592 593 594
DECLARE_EVENT_CLASS(svc_rqst_event,

	TP_PROTO(struct svc_rqst *rqst),

	TP_ARGS(rqst),

	TP_STRUCT__entry(
595
		__field(u32, xid)
596
		__field(unsigned long, flags)
597
		__string(addr, rqst->rq_xprt->xpt_remotebuf)
598 599 600
	),

	TP_fast_assign(
601
		__entry->xid = be32_to_cpu(rqst->rq_xid);
602
		__entry->flags = rqst->rq_flags;
603
		__assign_str(addr, rqst->rq_xprt->xpt_remotebuf);
604 605
	),

606 607 608
	TP_printk("addr=%s xid=0x%08x flags=%s",
			__get_str(addr), __entry->xid,
			show_rqstp_flags(__entry->flags))
609 610 611 612 613 614 615 616 617 618
);

DEFINE_EVENT(svc_rqst_event, svc_defer,
	TP_PROTO(struct svc_rqst *rqst),
	TP_ARGS(rqst));

DEFINE_EVENT(svc_rqst_event, svc_drop,
	TP_PROTO(struct svc_rqst *rqst),
	TP_ARGS(rqst));

619 620 621 622 623 624 625
DECLARE_EVENT_CLASS(svc_rqst_status,

	TP_PROTO(struct svc_rqst *rqst, int status),

	TP_ARGS(rqst, status),

	TP_STRUCT__entry(
626
		__field(u32, xid)
627
		__field(int, status)
628
		__field(unsigned long, flags)
629
		__string(addr, rqst->rq_xprt->xpt_remotebuf)
630 631 632
	),

	TP_fast_assign(
633
		__entry->xid = be32_to_cpu(rqst->rq_xid);
634
		__entry->status = status;
635
		__entry->flags = rqst->rq_flags;
636
		__assign_str(addr, rqst->rq_xprt->xpt_remotebuf);
637 638
	),

639 640 641
	TP_printk("addr=%s xid=0x%08x status=%d flags=%s",
		  __get_str(addr), __entry->xid,
		  __entry->status, show_rqstp_flags(__entry->flags))
642 643 644 645 646 647
);

DEFINE_EVENT(svc_rqst_status, svc_send,
	TP_PROTO(struct svc_rqst *rqst, int status),
	TP_ARGS(rqst, status));

648 649 650 651 652 653 654 655 656 657 658 659 660
#define show_svc_xprt_flags(flags)					\
	__print_flags(flags, "|",					\
		{ (1UL << XPT_BUSY),		"XPT_BUSY"},		\
		{ (1UL << XPT_CONN),		"XPT_CONN"},		\
		{ (1UL << XPT_CLOSE),		"XPT_CLOSE"},		\
		{ (1UL << XPT_DATA),		"XPT_DATA"},		\
		{ (1UL << XPT_TEMP),		"XPT_TEMP"},		\
		{ (1UL << XPT_DEAD),		"XPT_DEAD"},		\
		{ (1UL << XPT_CHNGBUF),		"XPT_CHNGBUF"},		\
		{ (1UL << XPT_DEFERRED),	"XPT_DEFERRED"},	\
		{ (1UL << XPT_OLD),		"XPT_OLD"},		\
		{ (1UL << XPT_LISTENER),	"XPT_LISTENER"},	\
		{ (1UL << XPT_CACHE_AUTH),	"XPT_CACHE_AUTH"},	\
661 662 663
		{ (1UL << XPT_LOCAL),		"XPT_LOCAL"},		\
		{ (1UL << XPT_KILL_TEMP),	"XPT_KILL_TEMP"},	\
		{ (1UL << XPT_CONG_CTRL),	"XPT_CONG_CTRL"})
664 665 666 667 668 669 670 671

TRACE_EVENT(svc_xprt_do_enqueue,
	TP_PROTO(struct svc_xprt *xprt, struct svc_rqst *rqst),

	TP_ARGS(xprt, rqst),

	TP_STRUCT__entry(
		__field(struct svc_xprt *, xprt)
672 673
		__field(int, pid)
		__field(unsigned long, flags)
674
		__string(addr, xprt->xpt_remotebuf)
675 676 677 678
	),

	TP_fast_assign(
		__entry->xprt = xprt;
679
		__entry->pid = rqst? rqst->rq_task->pid : 0;
680 681
		__entry->flags = xprt->xpt_flags;
		__assign_str(addr, xprt->xpt_remotebuf);
682 683
	),

684 685 686
	TP_printk("xprt=%p addr=%s pid=%d flags=%s",
			__entry->xprt, __get_str(addr),
			__entry->pid, show_svc_xprt_flags(__entry->flags))
687 688
);

689
DECLARE_EVENT_CLASS(svc_xprt_event,
690 691 692 693 694 695 696
	TP_PROTO(struct svc_xprt *xprt),

	TP_ARGS(xprt),

	TP_STRUCT__entry(
		__field(struct svc_xprt *, xprt)
		__field(unsigned long, flags)
697
		__string(addr, xprt->xpt_remotebuf)
698 699 700
	),

	TP_fast_assign(
701
		__entry->xprt = xprt;
702
		__entry->flags = xprt->xpt_flags;
703
		__assign_str(addr, xprt->xpt_remotebuf);
704 705
	),

706 707 708
	TP_printk("xprt=%p addr=%s flags=%s",
			__entry->xprt, __get_str(addr),
			show_svc_xprt_flags(__entry->flags))
709 710
);

711 712 713 714
DEFINE_EVENT(svc_xprt_event, svc_xprt_no_write_space,
	TP_PROTO(struct svc_xprt *xprt),
	TP_ARGS(xprt));

C
Chuck Lever 已提交
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
TRACE_EVENT(svc_xprt_dequeue,
	TP_PROTO(struct svc_rqst *rqst),

	TP_ARGS(rqst),

	TP_STRUCT__entry(
		__field(struct svc_xprt *, xprt)
		__field(unsigned long, flags)
		__field(unsigned long, wakeup)
		__string(addr, rqst->rq_xprt->xpt_remotebuf)
	),

	TP_fast_assign(
		__entry->xprt = rqst->rq_xprt;
		__entry->flags = rqst->rq_xprt->xpt_flags;
		__entry->wakeup = ktime_to_us(ktime_sub(ktime_get(),
							rqst->rq_qtime));
		__assign_str(addr, rqst->rq_xprt->xpt_remotebuf);
	),

	TP_printk("xprt=%p addr=%s flags=%s wakeup-us=%lu",
			__entry->xprt, __get_str(addr),
			show_svc_xprt_flags(__entry->flags),
			__entry->wakeup)
);

741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764
TRACE_EVENT(svc_wake_up,
	TP_PROTO(int pid),

	TP_ARGS(pid),

	TP_STRUCT__entry(
		__field(int, pid)
	),

	TP_fast_assign(
		__entry->pid = pid;
	),

	TP_printk("pid=%d", __entry->pid)
);

TRACE_EVENT(svc_handle_xprt,
	TP_PROTO(struct svc_xprt *xprt, int len),

	TP_ARGS(xprt, len),

	TP_STRUCT__entry(
		__field(struct svc_xprt *, xprt)
		__field(int, len)
765
		__field(unsigned long, flags)
766
		__string(addr, xprt->xpt_remotebuf)
767 768 769 770 771
	),

	TP_fast_assign(
		__entry->xprt = xprt;
		__entry->len = len;
772 773
		__entry->flags = xprt->xpt_flags;
		__assign_str(addr, xprt->xpt_remotebuf);
774 775
	),

776 777
	TP_printk("xprt=%p addr=%s len=%d flags=%s",
		__entry->xprt, __get_str(addr),
778
		__entry->len, show_svc_xprt_flags(__entry->flags))
779
);
780

781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801
TRACE_EVENT(svc_stats_latency,
	TP_PROTO(const struct svc_rqst *rqst),

	TP_ARGS(rqst),

	TP_STRUCT__entry(
		__field(u32, xid)
		__field(unsigned long, execute)
		__string(addr, rqst->rq_xprt->xpt_remotebuf)
	),

	TP_fast_assign(
		__entry->xid = be32_to_cpu(rqst->rq_xid);
		__entry->execute = ktime_to_us(ktime_sub(ktime_get(),
							 rqst->rq_stime));
		__assign_str(addr, rqst->rq_xprt->xpt_remotebuf);
	),

	TP_printk("addr=%s xid=0x%08x execute-us=%lu",
		__get_str(addr), __entry->xid, __entry->execute)
);
802 803 804 805 806 807 808

DECLARE_EVENT_CLASS(svc_deferred_event,
	TP_PROTO(struct svc_deferred_req *dr),

	TP_ARGS(dr),

	TP_STRUCT__entry(
809
		__field(u32, xid)
810
		__string(addr, dr->xprt->xpt_remotebuf)
811 812 813
	),

	TP_fast_assign(
814 815
		__entry->xid = be32_to_cpu(*(__be32 *)(dr->args +
						       (dr->xprt_hlen>>2)));
816
		__assign_str(addr, dr->xprt->xpt_remotebuf);
817 818
	),

819
	TP_printk("addr=%s xid=0x%08x", __get_str(addr), __entry->xid)
820 821 822 823 824 825 826 827
);

DEFINE_EVENT(svc_deferred_event, svc_drop_deferred,
	TP_PROTO(struct svc_deferred_req *dr),
	TP_ARGS(dr));
DEFINE_EVENT(svc_deferred_event, svc_revisit_deferred,
	TP_PROTO(struct svc_deferred_req *dr),
	TP_ARGS(dr));
828 829 830
#endif /* _TRACE_SUNRPC_H */

#include <trace/define_trace.h>