2015-04-03 01:42:38

by Steven Rostedt

[permalink] [raw]
Subject: [PATCH 15/18 v3] SUNRPC: Export enums in tracepoints to user space

From: "Steven Rostedt (Red Hat)" <[email protected]>

The enums used in the tracepoints for __print_symbolic() have their
names shown in the tracepoint format files. User space tools do not know
how to convert those names into their values to be able to convert the
binary data.

Use TRACE_DEFINE_ENUM() to export the enum names to their values for
userspace to do the parsing correctly.

Cc: Trond Myklebust <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
include/trace/events/sunrpc.h | 62 ++++++++++++++++++++++++++++++-------------
1 file changed, 44 insertions(+), 18 deletions(-)

diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
index b9c1dc6c825a..fd1a02cb3c82 100644
--- a/include/trace/events/sunrpc.h
+++ b/include/trace/events/sunrpc.h
@@ -179,27 +179,53 @@ DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,

);

+/*
+ * 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" )
+
#define rpc_show_socket_state(state) \
- __print_symbolic(state, \
- { SS_FREE, "FREE" }, \
- { SS_UNCONNECTED, "UNCONNECTED" }, \
- { SS_CONNECTING, "CONNECTING," }, \
- { SS_CONNECTED, "CONNECTED," }, \
- { SS_DISCONNECTING, "DISCONNECTING" })
+ __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" )

#define rpc_show_sock_state(state) \
- __print_symbolic(state, \
- { TCP_ESTABLISHED, "ESTABLISHED" }, \
- { TCP_SYN_SENT, "SYN_SENT" }, \
- { TCP_SYN_RECV, "SYN_RECV" }, \
- { TCP_FIN_WAIT1, "FIN_WAIT1" }, \
- { TCP_FIN_WAIT2, "FIN_WAIT2" }, \
- { TCP_TIME_WAIT, "TIME_WAIT" }, \
- { TCP_CLOSE, "CLOSE" }, \
- { TCP_CLOSE_WAIT, "CLOSE_WAIT" }, \
- { TCP_LAST_ACK, "LAST_ACK" }, \
- { TCP_LISTEN, "LISTEN" }, \
- { TCP_CLOSING, "CLOSING" })
+ __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}

DECLARE_EVENT_CLASS(xs_socket_event,

--
2.1.4


2015-04-07 16:40:42

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 15/18 v3] SUNRPC: Export enums in tracepoints to user space


Trond,

I had your old email that I Cc'd this patch to. I updated this in my
git repo for your current email (if this is your current email).

-- Steve


On Thu, 02 Apr 2015 21:38:17 -0400
Steven Rostedt <[email protected]> wrote:

> From: "Steven Rostedt (Red Hat)" <[email protected]>
>
> The enums used in the tracepoints for __print_symbolic() have their
> names shown in the tracepoint format files. User space tools do not know
> how to convert those names into their values to be able to convert the
> binary data.
>
> Use TRACE_DEFINE_ENUM() to export the enum names to their values for
> userspace to do the parsing correctly.
>
> Cc: Trond Myklebust <[email protected]>
> Signed-off-by: Steven Rostedt <[email protected]>
> ---
> include/trace/events/sunrpc.h | 62 ++++++++++++++++++++++++++++++-------------
> 1 file changed, 44 insertions(+), 18 deletions(-)
>
> diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
> index b9c1dc6c825a..fd1a02cb3c82 100644
> --- a/include/trace/events/sunrpc.h
> +++ b/include/trace/events/sunrpc.h
> @@ -179,27 +179,53 @@ DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,
>
> );
>
> +/*
> + * 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" )
> +
> #define rpc_show_socket_state(state) \
> - __print_symbolic(state, \
> - { SS_FREE, "FREE" }, \
> - { SS_UNCONNECTED, "UNCONNECTED" }, \
> - { SS_CONNECTING, "CONNECTING," }, \
> - { SS_CONNECTED, "CONNECTED," }, \
> - { SS_DISCONNECTING, "DISCONNECTING" })
> + __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" )
>
> #define rpc_show_sock_state(state) \
> - __print_symbolic(state, \
> - { TCP_ESTABLISHED, "ESTABLISHED" }, \
> - { TCP_SYN_SENT, "SYN_SENT" }, \
> - { TCP_SYN_RECV, "SYN_RECV" }, \
> - { TCP_FIN_WAIT1, "FIN_WAIT1" }, \
> - { TCP_FIN_WAIT2, "FIN_WAIT2" }, \
> - { TCP_TIME_WAIT, "TIME_WAIT" }, \
> - { TCP_CLOSE, "CLOSE" }, \
> - { TCP_CLOSE_WAIT, "CLOSE_WAIT" }, \
> - { TCP_LAST_ACK, "LAST_ACK" }, \
> - { TCP_LISTEN, "LISTEN" }, \
> - { TCP_CLOSING, "CLOSING" })
> + __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}
>
> DECLARE_EVENT_CLASS(xs_socket_event,
>

2015-04-07 16:58:49

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH 15/18 v3] SUNRPC: Export enums in tracepoints to user space

Hi Steve,

On Tue, Apr 7, 2015 at 12:40 PM, Steven Rostedt <[email protected]> wrote:
>
> Trond,
>
> I had your old email that I Cc'd this patch to. I updated this in my
> git repo for your current email (if this is your current email).

Thanks! Yes the [email protected] address is the correct one.

> -- Steve
>
>
> On Thu, 02 Apr 2015 21:38:17 -0400
> Steven Rostedt <[email protected]> wrote:
>
>> From: "Steven Rostedt (Red Hat)" <[email protected]>
>>
>> The enums used in the tracepoints for __print_symbolic() have their
>> names shown in the tracepoint format files. User space tools do not know
>> how to convert those names into their values to be able to convert the
>> binary data.
>>
>> Use TRACE_DEFINE_ENUM() to export the enum names to their values for
>> userspace to do the parsing correctly.
>>
>> Cc: Trond Myklebust <[email protected]>
>> Signed-off-by: Steven Rostedt <[email protected]>

Acked-by: Trond Myklebust <[email protected]>

>> ---
>> include/trace/events/sunrpc.h | 62 ++++++++++++++++++++++++++++++-------------
>> 1 file changed, 44 insertions(+), 18 deletions(-)
>>
>> diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
>> index b9c1dc6c825a..fd1a02cb3c82 100644
>> --- a/include/trace/events/sunrpc.h
>> +++ b/include/trace/events/sunrpc.h
>> @@ -179,27 +179,53 @@ DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,
>>
>> );
>>
>> +/*
>> + * 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" )
>> +
>> #define rpc_show_socket_state(state) \
>> - __print_symbolic(state, \
>> - { SS_FREE, "FREE" }, \
>> - { SS_UNCONNECTED, "UNCONNECTED" }, \
>> - { SS_CONNECTING, "CONNECTING," }, \
>> - { SS_CONNECTED, "CONNECTED," }, \
>> - { SS_DISCONNECTING, "DISCONNECTING" })
>> + __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" )
>>
>> #define rpc_show_sock_state(state) \
>> - __print_symbolic(state, \
>> - { TCP_ESTABLISHED, "ESTABLISHED" }, \
>> - { TCP_SYN_SENT, "SYN_SENT" }, \
>> - { TCP_SYN_RECV, "SYN_RECV" }, \
>> - { TCP_FIN_WAIT1, "FIN_WAIT1" }, \
>> - { TCP_FIN_WAIT2, "FIN_WAIT2" }, \
>> - { TCP_TIME_WAIT, "TIME_WAIT" }, \
>> - { TCP_CLOSE, "CLOSE" }, \
>> - { TCP_CLOSE_WAIT, "CLOSE_WAIT" }, \
>> - { TCP_LAST_ACK, "LAST_ACK" }, \
>> - { TCP_LISTEN, "LISTEN" }, \
>> - { TCP_CLOSING, "CLOSING" })
>> + __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}
>>
>> DECLARE_EVENT_CLASS(xs_socket_event,
>>
>