diff options
author | David Howells <dhowells@redhat.com> | 2017-01-05 05:38:34 -0500 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2017-01-09 04:18:13 -0500 |
commit | 8e8d7f13b6d5a93b3d2cf9a4ceaaf923809fd5ac (patch) | |
tree | 8d5b1fd4da0dfec6cbaea9a846419fb8b7a1ac15 | |
parent | 4289e60cb056ccae4311197d8a4a798aca0f8e55 (diff) |
afs: Add some tracepoints
Add three tracepoints to the AFS filesystem:
(1) The afs_recv_data tracepoint logs data segments that are extracted
from the data received from the peer through afs_extract_data().
(2) The afs_notify_call tracepoint logs notification from AF_RXRPC of data
coming in to an asynchronous call.
(3) The afs_cb_call tracepoint logs incoming calls that have had their
operation ID extracted and mapped into a supported cache manager
service call.
To make (3) work, the name strings in the afs_call_type struct objects have
to be annotated with __tracepoint_string. This is done with the CM_NAME()
macro.
Further, the AFS call state enum needs a name so that it can be used to
declare parameter types.
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | fs/afs/cmservice.c | 22 | ||||
-rw-r--r-- | fs/afs/internal.h | 21 | ||||
-rw-r--r-- | fs/afs/main.c | 1 | ||||
-rw-r--r-- | fs/afs/rxrpc.c | 6 | ||||
-rw-r--r-- | include/trace/events/afs.h | 109 |
5 files changed, 144 insertions, 15 deletions
diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c index d764236072b1..a2e1e02005f6 100644 --- a/fs/afs/cmservice.c +++ b/fs/afs/cmservice.c | |||
@@ -25,11 +25,16 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *); | |||
25 | static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *); | 25 | static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *); |
26 | static void afs_cm_destructor(struct afs_call *); | 26 | static void afs_cm_destructor(struct afs_call *); |
27 | 27 | ||
28 | #define CM_NAME(name) \ | ||
29 | const char afs_SRXCB##name##_name[] __tracepoint_string = \ | ||
30 | "CB." #name | ||
31 | |||
28 | /* | 32 | /* |
29 | * CB.CallBack operation type | 33 | * CB.CallBack operation type |
30 | */ | 34 | */ |
35 | static CM_NAME(CallBack); | ||
31 | static const struct afs_call_type afs_SRXCBCallBack = { | 36 | static const struct afs_call_type afs_SRXCBCallBack = { |
32 | .name = "CB.CallBack", | 37 | .name = afs_SRXCBCallBack_name, |
33 | .deliver = afs_deliver_cb_callback, | 38 | .deliver = afs_deliver_cb_callback, |
34 | .abort_to_error = afs_abort_to_error, | 39 | .abort_to_error = afs_abort_to_error, |
35 | .destructor = afs_cm_destructor, | 40 | .destructor = afs_cm_destructor, |
@@ -38,8 +43,9 @@ static const struct afs_call_type afs_SRXCBCallBack = { | |||
38 | /* | 43 | /* |
39 | * CB.InitCallBackState operation type | 44 | * CB.InitCallBackState operation type |
40 | */ | 45 | */ |
46 | static CM_NAME(InitCallBackState); | ||
41 | static const struct afs_call_type afs_SRXCBInitCallBackState = { | 47 | static const struct afs_call_type afs_SRXCBInitCallBackState = { |
42 | .name = "CB.InitCallBackState", | 48 | .name = afs_SRXCBInitCallBackState_name, |
43 | .deliver = afs_deliver_cb_init_call_back_state, | 49 | .deliver = afs_deliver_cb_init_call_back_state, |
44 | .abort_to_error = afs_abort_to_error, | 50 | .abort_to_error = afs_abort_to_error, |
45 | .destructor = afs_cm_destructor, | 51 | .destructor = afs_cm_destructor, |
@@ -48,8 +54,9 @@ static const struct afs_call_type afs_SRXCBInitCallBackState = { | |||
48 | /* | 54 | /* |
49 | * CB.InitCallBackState3 operation type | 55 | * CB.InitCallBackState3 operation type |
50 | */ | 56 | */ |
57 | static CM_NAME(InitCallBackState3); | ||
51 | static const struct afs_call_type afs_SRXCBInitCallBackState3 = { | 58 | static const struct afs_call_type afs_SRXCBInitCallBackState3 = { |
52 | .name = "CB.InitCallBackState3", | 59 | .name = afs_SRXCBInitCallBackState3_name, |
53 | .deliver = afs_deliver_cb_init_call_back_state3, | 60 | .deliver = afs_deliver_cb_init_call_back_state3, |
54 | .abort_to_error = afs_abort_to_error, | 61 | .abort_to_error = afs_abort_to_error, |
55 | .destructor = afs_cm_destructor, | 62 | .destructor = afs_cm_destructor, |
@@ -58,8 +65,9 @@ static const struct afs_call_type afs_SRXCBInitCallBackState3 = { | |||
58 | /* | 65 | /* |
59 | * CB.Probe operation type | 66 | * CB.Probe operation type |
60 | */ | 67 | */ |
68 | static CM_NAME(Probe); | ||
61 | static const struct afs_call_type afs_SRXCBProbe = { | 69 | static const struct afs_call_type afs_SRXCBProbe = { |
62 | .name = "CB.Probe", | 70 | .name = afs_SRXCBProbe_name, |
63 | .deliver = afs_deliver_cb_probe, | 71 | .deliver = afs_deliver_cb_probe, |
64 | .abort_to_error = afs_abort_to_error, | 72 | .abort_to_error = afs_abort_to_error, |
65 | .destructor = afs_cm_destructor, | 73 | .destructor = afs_cm_destructor, |
@@ -68,8 +76,9 @@ static const struct afs_call_type afs_SRXCBProbe = { | |||
68 | /* | 76 | /* |
69 | * CB.ProbeUuid operation type | 77 | * CB.ProbeUuid operation type |
70 | */ | 78 | */ |
79 | static CM_NAME(ProbeUuid); | ||
71 | static const struct afs_call_type afs_SRXCBProbeUuid = { | 80 | static const struct afs_call_type afs_SRXCBProbeUuid = { |
72 | .name = "CB.ProbeUuid", | 81 | .name = afs_SRXCBProbeUuid_name, |
73 | .deliver = afs_deliver_cb_probe_uuid, | 82 | .deliver = afs_deliver_cb_probe_uuid, |
74 | .abort_to_error = afs_abort_to_error, | 83 | .abort_to_error = afs_abort_to_error, |
75 | .destructor = afs_cm_destructor, | 84 | .destructor = afs_cm_destructor, |
@@ -78,8 +87,9 @@ static const struct afs_call_type afs_SRXCBProbeUuid = { | |||
78 | /* | 87 | /* |
79 | * CB.TellMeAboutYourself operation type | 88 | * CB.TellMeAboutYourself operation type |
80 | */ | 89 | */ |
90 | static CM_NAME(TellMeAboutYourself); | ||
81 | static const struct afs_call_type afs_SRXCBTellMeAboutYourself = { | 91 | static const struct afs_call_type afs_SRXCBTellMeAboutYourself = { |
82 | .name = "CB.TellMeAboutYourself", | 92 | .name = afs_SRXCBTellMeAboutYourself_name, |
83 | .deliver = afs_deliver_cb_tell_me_about_yourself, | 93 | .deliver = afs_deliver_cb_tell_me_about_yourself, |
84 | .abort_to_error = afs_abort_to_error, | 94 | .abort_to_error = afs_abort_to_error, |
85 | .destructor = afs_cm_destructor, | 95 | .destructor = afs_cm_destructor, |
diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 6f7a9638ba1a..f71e58fcc2f2 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h | |||
@@ -68,6 +68,15 @@ struct afs_wait_mode { | |||
68 | extern const struct afs_wait_mode afs_sync_call; | 68 | extern const struct afs_wait_mode afs_sync_call; |
69 | extern const struct afs_wait_mode afs_async_call; | 69 | extern const struct afs_wait_mode afs_async_call; |
70 | 70 | ||
71 | enum afs_call_state { | ||
72 | AFS_CALL_REQUESTING, /* request is being sent for outgoing call */ | ||
73 | AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */ | ||
74 | AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */ | ||
75 | AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */ | ||
76 | AFS_CALL_REPLYING, /* replying to incoming call */ | ||
77 | AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */ | ||
78 | AFS_CALL_COMPLETE, /* Completed or failed */ | ||
79 | }; | ||
71 | /* | 80 | /* |
72 | * a record of an in-progress RxRPC call | 81 | * a record of an in-progress RxRPC call |
73 | */ | 82 | */ |
@@ -91,15 +100,7 @@ struct afs_call { | |||
91 | pgoff_t first; /* first page in mapping to deal with */ | 100 | pgoff_t first; /* first page in mapping to deal with */ |
92 | pgoff_t last; /* last page in mapping to deal with */ | 101 | pgoff_t last; /* last page in mapping to deal with */ |
93 | size_t offset; /* offset into received data store */ | 102 | size_t offset; /* offset into received data store */ |
94 | enum { /* call state */ | 103 | enum afs_call_state state; |
95 | AFS_CALL_REQUESTING, /* request is being sent for outgoing call */ | ||
96 | AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */ | ||
97 | AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */ | ||
98 | AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */ | ||
99 | AFS_CALL_REPLYING, /* replying to incoming call */ | ||
100 | AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */ | ||
101 | AFS_CALL_COMPLETE, /* Completed or failed */ | ||
102 | } state; | ||
103 | int error; /* error code */ | 104 | int error; /* error code */ |
104 | u32 abort_code; /* Remote abort ID or 0 */ | 105 | u32 abort_code; /* Remote abort ID or 0 */ |
105 | unsigned request_size; /* size of request data */ | 106 | unsigned request_size; /* size of request data */ |
@@ -773,6 +774,8 @@ extern int afs_fsync(struct file *, loff_t, loff_t, int); | |||
773 | /* | 774 | /* |
774 | * debug tracing | 775 | * debug tracing |
775 | */ | 776 | */ |
777 | #include <trace/events/afs.h> | ||
778 | |||
776 | extern unsigned afs_debug; | 779 | extern unsigned afs_debug; |
777 | 780 | ||
778 | #define dbgprintk(FMT,...) \ | 781 | #define dbgprintk(FMT,...) \ |
diff --git a/fs/afs/main.c b/fs/afs/main.c index 0b187ef3b5b7..f8188feb03ad 100644 --- a/fs/afs/main.c +++ b/fs/afs/main.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/completion.h> | 15 | #include <linux/completion.h> |
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/random.h> | 17 | #include <linux/random.h> |
18 | #define CREATE_TRACE_POINTS | ||
18 | #include "internal.h" | 19 | #include "internal.h" |
19 | 20 | ||
20 | MODULE_DESCRIPTION("AFS Client File System"); | 21 | MODULE_DESCRIPTION("AFS Client File System"); |
diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c index 25f05a8d21b1..f26344a8c029 100644 --- a/fs/afs/rxrpc.c +++ b/fs/afs/rxrpc.c | |||
@@ -416,6 +416,8 @@ static void afs_deliver_to_call(struct afs_call *call) | |||
416 | ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall, | 416 | ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall, |
417 | NULL, 0, &offset, false, | 417 | NULL, 0, &offset, false, |
418 | &call->abort_code); | 418 | &call->abort_code); |
419 | trace_afs_recv_data(call, 0, offset, false, ret); | ||
420 | |||
419 | if (ret == -EINPROGRESS || ret == -EAGAIN) | 421 | if (ret == -EINPROGRESS || ret == -EAGAIN) |
420 | return; | 422 | return; |
421 | if (ret == 1 || ret < 0) { | 423 | if (ret == 1 || ret < 0) { |
@@ -541,6 +543,7 @@ static void afs_wake_up_async_call(struct sock *sk, struct rxrpc_call *rxcall, | |||
541 | { | 543 | { |
542 | struct afs_call *call = (struct afs_call *)call_user_ID; | 544 | struct afs_call *call = (struct afs_call *)call_user_ID; |
543 | 545 | ||
546 | trace_afs_notify_call(rxcall, call); | ||
544 | call->need_attention = true; | 547 | call->need_attention = true; |
545 | queue_work(afs_async_calls, &call->async_work); | 548 | queue_work(afs_async_calls, &call->async_work); |
546 | } | 549 | } |
@@ -689,6 +692,8 @@ static int afs_deliver_cm_op_id(struct afs_call *call) | |||
689 | if (!afs_cm_incoming_call(call)) | 692 | if (!afs_cm_incoming_call(call)) |
690 | return -ENOTSUPP; | 693 | return -ENOTSUPP; |
691 | 694 | ||
695 | trace_afs_cb_call(call); | ||
696 | |||
692 | /* pass responsibility for the remainer of this message off to the | 697 | /* pass responsibility for the remainer of this message off to the |
693 | * cache manager op */ | 698 | * cache manager op */ |
694 | return call->type->deliver(call); | 699 | return call->type->deliver(call); |
@@ -780,6 +785,7 @@ int afs_extract_data(struct afs_call *call, void *buf, size_t count, | |||
780 | ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall, | 785 | ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall, |
781 | buf, count, &call->offset, | 786 | buf, count, &call->offset, |
782 | want_more, &call->abort_code); | 787 | want_more, &call->abort_code); |
788 | trace_afs_recv_data(call, count, call->offset, want_more, ret); | ||
783 | if (ret == 0 || ret == -EAGAIN) | 789 | if (ret == 0 || ret == -EAGAIN) |
784 | return ret; | 790 | return ret; |
785 | 791 | ||
diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h new file mode 100644 index 000000000000..845907b04ff4 --- /dev/null +++ b/include/trace/events/afs.h | |||
@@ -0,0 +1,109 @@ | |||
1 | /* AFS tracepoints | ||
2 | * | ||
3 | * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public Licence | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the Licence, or (at your option) any later version. | ||
10 | */ | ||
11 | #undef TRACE_SYSTEM | ||
12 | #define TRACE_SYSTEM afs | ||
13 | |||
14 | #if !defined(_TRACE_AFS_H) || defined(TRACE_HEADER_MULTI_READ) | ||
15 | #define _TRACE_AFS_H | ||
16 | |||
17 | #include <linux/tracepoint.h> | ||
18 | |||
19 | TRACE_EVENT(afs_recv_data, | ||
20 | TP_PROTO(struct afs_call *call, unsigned count, unsigned offset, | ||
21 | bool want_more, int ret), | ||
22 | |||
23 | TP_ARGS(call, count, offset, want_more, ret), | ||
24 | |||
25 | TP_STRUCT__entry( | ||
26 | __field(struct rxrpc_call *, rxcall ) | ||
27 | __field(struct afs_call *, call ) | ||
28 | __field(enum afs_call_state, state ) | ||
29 | __field(unsigned int, count ) | ||
30 | __field(unsigned int, offset ) | ||
31 | __field(unsigned short, unmarshall ) | ||
32 | __field(bool, want_more ) | ||
33 | __field(int, ret ) | ||
34 | ), | ||
35 | |||
36 | TP_fast_assign( | ||
37 | __entry->rxcall = call->rxcall; | ||
38 | __entry->call = call; | ||
39 | __entry->state = call->state; | ||
40 | __entry->unmarshall = call->unmarshall; | ||
41 | __entry->count = count; | ||
42 | __entry->offset = offset; | ||
43 | __entry->want_more = want_more; | ||
44 | __entry->ret = ret; | ||
45 | ), | ||
46 | |||
47 | TP_printk("c=%p ac=%p s=%u u=%u %u/%u wm=%u ret=%d", | ||
48 | __entry->rxcall, | ||
49 | __entry->call, | ||
50 | __entry->state, __entry->unmarshall, | ||
51 | __entry->offset, __entry->count, | ||
52 | __entry->want_more, __entry->ret) | ||
53 | ); | ||
54 | |||
55 | TRACE_EVENT(afs_notify_call, | ||
56 | TP_PROTO(struct rxrpc_call *rxcall, struct afs_call *call), | ||
57 | |||
58 | TP_ARGS(rxcall, call), | ||
59 | |||
60 | TP_STRUCT__entry( | ||
61 | __field(struct rxrpc_call *, rxcall ) | ||
62 | __field(struct afs_call *, call ) | ||
63 | __field(enum afs_call_state, state ) | ||
64 | __field(unsigned short, unmarshall ) | ||
65 | ), | ||
66 | |||
67 | TP_fast_assign( | ||
68 | __entry->rxcall = rxcall; | ||
69 | __entry->call = call; | ||
70 | __entry->state = call->state; | ||
71 | __entry->unmarshall = call->unmarshall; | ||
72 | ), | ||
73 | |||
74 | TP_printk("c=%p ac=%p s=%u u=%u", | ||
75 | __entry->rxcall, | ||
76 | __entry->call, | ||
77 | __entry->state, __entry->unmarshall) | ||
78 | ); | ||
79 | |||
80 | TRACE_EVENT(afs_cb_call, | ||
81 | TP_PROTO(struct afs_call *call), | ||
82 | |||
83 | TP_ARGS(call), | ||
84 | |||
85 | TP_STRUCT__entry( | ||
86 | __field(struct rxrpc_call *, rxcall ) | ||
87 | __field(struct afs_call *, call ) | ||
88 | __field(const char *, name ) | ||
89 | __field(u32, op ) | ||
90 | ), | ||
91 | |||
92 | TP_fast_assign( | ||
93 | __entry->rxcall = call->rxcall; | ||
94 | __entry->call = call; | ||
95 | __entry->name = call->type->name; | ||
96 | __entry->op = call->operation_ID; | ||
97 | ), | ||
98 | |||
99 | TP_printk("c=%p ac=%p %s o=%u", | ||
100 | __entry->rxcall, | ||
101 | __entry->call, | ||
102 | __entry->name, | ||
103 | __entry->op) | ||
104 | ); | ||
105 | |||
106 | #endif /* _TRACE_AFS_H */ | ||
107 | |||
108 | /* This part must be outside protection */ | ||
109 | #include <trace/define_trace.h> | ||