sunrpc: introduce lttng_get_clid helper
[lttng-modules.git] / instrumentation / events / lttng-module / rpc.h
index 1f47d6e4a5bb9496574b4f3a524bc7c2c23ff2a4..ceaf9dbf4089f6b00c1ebf3ace7b5eedd374330f 100644 (file)
@@ -9,7 +9,55 @@
 #include <linux/sunrpc/sched.h>
 #include <linux/sunrpc/clnt.h>
 
+#ifndef ONCE_LTTNG_RPC_H
+#define ONCE_LTTNG_RPC_H
+
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
+static inline
+int lttng_get_clid(const struct rpc_task *task)
+{
+       struct rpc_clnt *tk_client;
+
+       tk_client = task->tk_client;
+       if (!tk_client)
+               return -1;
+       /*
+        * The cl_clid field is always initialized to positive signed
+        * integers. Negative signed integer values are treated as
+        * errors.
+        */
+       return (int) tk_client->cl_clid;
+}
+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
+
+#endif /* ONCE_LTTNG_RPC_H */
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))
+LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
+
+       TP_PROTO(const struct rpc_task *task),
+
+       TP_ARGS(task),
+
+       TP_FIELDS(
+               ctf_integer(unsigned int, task_id, task->tk_pid)
+               ctf_integer(int, client_id, lttng_get_clid(task))
+               ctf_integer(int, status, task->tk_status)
+       )
+)
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status,
+       TP_PROTO(const struct rpc_task *task),
+
+       TP_ARGS(task)
+)
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status,
+       TP_PROTO(const struct rpc_task *task),
+
+       TP_ARGS(task)
+)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
 
        TP_PROTO(struct rpc_task *task),
@@ -18,10 +66,22 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
 
        TP_FIELDS(
                ctf_integer(unsigned int, task_id, task->tk_pid)
-               ctf_integer(unsigned int, client_id, task->tk_client->cl_clid)
+               ctf_integer(int, client_id, lttng_get_clid(task))
                ctf_integer(int, status, task->tk_status)
        )
 )
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status,
+       TP_PROTO(struct rpc_task *task),
+
+       TP_ARGS(task)
+)
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status,
+       TP_PROTO(struct rpc_task *task),
+
+       TP_ARGS(task)
+)
 #else
 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
 
@@ -35,7 +95,6 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
                ctf_integer(int, status, task->tk_status)
        )
 )
-#endif
 
 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status,
        TP_PROTO(struct rpc_task *task),
@@ -48,8 +107,15 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status,
 
        TP_ARGS(task)
 )
+#endif
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))
+LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_connect_status,
+       TP_PROTO(const struct rpc_task *task),
+
+       TP_ARGS(task)
+)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0))
 LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
        TP_PROTO(const struct rpc_task *task),
 
@@ -57,11 +123,37 @@ LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
 
        TP_FIELDS(
                ctf_integer(unsigned int, task_id, task->tk_pid)
-               ctf_integer(unsigned int, client_id, task->tk_client->cl_clid)
+               ctf_integer(int, client_id, lttng_get_clid(task))
                ctf_integer(int, status, task->tk_status)
        )
 )
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
+LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
+       TP_PROTO(struct rpc_task *task, int status),
+
+       TP_ARGS(task, status),
+
+       TP_FIELDS(
+               ctf_integer(unsigned int, task_id, task->tk_pid)
+               ctf_integer(int, client_id, lttng_get_clid(task))
+               ctf_integer(int, status, status)
+       )
+)
+#else
+LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
+       TP_PROTO(struct rpc_task *task, int status),
 
+       TP_ARGS(task, status),
+
+       TP_FIELDS(
+               ctf_integer_hex(const struct rpc_task *, task, task)
+               ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client)
+               ctf_integer(int, status, status)
+       )
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0))
 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
 
        TP_PROTO(const struct rpc_task *task, const void *action),
@@ -70,7 +162,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
 
        TP_FIELDS(
                ctf_integer(unsigned int, task_id, task->tk_pid)
-               ctf_integer(unsigned int, client_id, task->tk_client->cl_clid)
+               ctf_integer(int, client_id, lttng_get_clid(task))
                ctf_integer_hex(const void *, action, action)
                ctf_integer(unsigned long, runstate, task->tk_runstate)
                ctf_integer(int, status, task->tk_status)
@@ -107,7 +199,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued,
 
        TP_FIELDS(
                ctf_integer(unsigned int, task_id, task->tk_pid)
-               ctf_integer(unsigned int, client_id, task->tk_client->cl_clid)
+               ctf_integer(int, client_id, lttng_get_clid(task))
                ctf_integer(unsigned long, timeout, task->tk_timeout)
                ctf_integer(unsigned long, runstate, task->tk_runstate)
                ctf_integer(int, status, task->tk_status)
@@ -131,18 +223,6 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup,
 )
 
 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
-LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
-       TP_PROTO(struct rpc_task *task, int status),
-
-       TP_ARGS(task, status),
-
-       TP_FIELDS(
-               ctf_integer(unsigned int, task_id, task->tk_pid)
-               ctf_integer(unsigned int, client_id, task->tk_client->cl_clid)
-               ctf_integer(int, status, status)
-       )
-)
-
 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
 
        TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
@@ -151,7 +231,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
 
        TP_FIELDS(
                ctf_integer(unsigned int, task_id, task->tk_pid)
-               ctf_integer(unsigned int, client_id, task->tk_client->cl_clid)
+               ctf_integer(int, client_id, lttng_get_clid(task))
                ctf_integer_hex(const void *, action, action)
                ctf_integer(unsigned long, runstate, task->tk_runstate)
                ctf_integer(int, status, task->tk_status)
@@ -188,7 +268,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued,
 
        TP_FIELDS(
                ctf_integer(unsigned int, task_id, task->tk_pid)
-               ctf_integer(unsigned int, client_id, task->tk_client->cl_clid)
+               ctf_integer(int, client_id, lttng_get_clid(task))
                ctf_integer(unsigned long, timeout, task->tk_timeout)
                ctf_integer(unsigned long, runstate, task->tk_runstate)
                ctf_integer(int, status, task->tk_status)
@@ -212,18 +292,6 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup,
 )
 
 #else
-LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
-       TP_PROTO(struct rpc_task *task, int status),
-
-       TP_ARGS(task, status),
-
-       TP_FIELDS(
-               ctf_integer_hex(const struct rpc_task *, task, task)
-               ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client)
-               ctf_integer(int, status, status)
-       )
-)
-
 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
 
        TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
This page took 0.025307 seconds and 4 git commands to generate.