]> git.lttng.org Git - lttng-modules.git/commitdiff
Fix printk instrumentation
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 4 Jul 2013 19:46:20 +0000 (15:46 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 4 Jul 2013 19:48:09 +0000 (15:48 -0400)
- Don't require 2kB of stack anymore (requiring so much kernel stack
  space should be considered as a bug in itself),
- Add support for 3.10 kernel printk instrumentation.

This patch uses "Introduce __dynamic_array_enc_ext_2() and
tp_memcpy_dyn_2()".

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/events/lttng-module/printk.h

index 4c744f998f7115fd02813d887918bb558c96f242..9ac55c72fdc3b6f7363842a69dd8490a8ef4f534 100644 (file)
@@ -7,7 +7,25 @@
 #include <linux/tracepoint.h>
 #include <linux/version.h>
 
-#define MSG_TRACE_MAX_LEN      2048
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
+
+TRACE_EVENT(console,
+       TP_PROTO(const char *text, size_t len),
+
+       TP_ARGS(text, len),
+
+       TP_STRUCT__entry(
+               __dynamic_array_text(char, msg, len)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy_dyn(msg, text)
+       ),
+
+       TP_printk("%s", __get_str(msg))
+)
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
 
 TRACE_EVENT_CONDITION(console,
        TP_PROTO(const char *log_buf, unsigned start, unsigned end,
@@ -18,46 +36,47 @@ TRACE_EVENT_CONDITION(console,
        TP_CONDITION(start != end),
 
        TP_STRUCT__entry(
-               __dynamic_array_text(char, msg,
-                       min_t(unsigned, end - start, MSG_TRACE_MAX_LEN) + 1)
+               __dynamic_array_text(char, msg, end - start)
        ),
 
        TP_fast_assign(
-               tp_memcpy_dyn(msg,
-                       ({
-                               char lmsg[MSG_TRACE_MAX_LEN + 1];
-
-                               if ((end - start) > MSG_TRACE_MAX_LEN)
-                                       start = end - MSG_TRACE_MAX_LEN;
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
-                               if ((start & (log_buf_len - 1)) >
-                                       (end & (log_buf_len - 1))) {
-                                       memcpy(lmsg,
-                                               log_buf +
-                                               (start & (log_buf_len - 1)),
-                                               log_buf_len -
-                                               (start & (log_buf_len - 1)));
-                                       memcpy(lmsg + log_buf_len -
-                                               (start & (log_buf_len - 1)),
-                                               log_buf,
-                                               end & (log_buf_len - 1));
-                               } else
-                                       memcpy(lmsg,
-                                               log_buf +
-                                               (start & (log_buf_len - 1)),
-                                               end - start);
-#else
-                               memcpy(lmsg, log_buf + start, end - start);
-#endif
-                               lmsg[end - start] = 0;
-                               lmsg;
-                       })
-               )
+               tp_memcpy_dyn(msg, log_buf + start)
+       ),
+
+       TP_printk("%s", __get_str(msg))
+)
+
+#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */
+
+TRACE_EVENT_CONDITION(console,
+       TP_PROTO(const char *log_buf, unsigned start, unsigned end,
+                unsigned log_buf_len),
+
+       TP_ARGS(log_buf, start, end, log_buf_len),
+
+       TP_CONDITION(start != end),
+
+       TP_STRUCT__entry(
+               __dynamic_array_text_2(char, msg,
+                       (start & (log_buf_len - 1)) > (end & (log_buf_len - 1))
+                               ? log_buf_len - (start & (log_buf_len - 1))
+                               : end - start,
+                       (start & (log_buf_len - 1)) > (end & (log_buf_len - 1))
+                               ? end & (log_buf_len - 1)
+                               : 0)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy_dyn_2(msg,
+                       log_buf + (start & (log_buf_len - 1)),
+                       log_buf)
        ),
 
        TP_printk("%s", __get_str(msg))
 )
+
+#endif
+
 #endif /* _TRACE_PRINTK_H */
 
 /* This part must be outside protection */
This page took 0.031514 seconds and 4 git commands to generate.