From: Mathieu Desnoyers Date: Thu, 4 Jul 2013 19:46:20 +0000 (-0400) Subject: Fix printk instrumentation X-Git-Tag: v2.2.1~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=abc0cb0becbacba12ae7f5bf89230af1998cacdd;p=lttng-modules.git Fix printk instrumentation - 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 --- diff --git a/instrumentation/events/lttng-module/printk.h b/instrumentation/events/lttng-module/printk.h index 4c744f99..9ac55c72 100644 --- a/instrumentation/events/lttng-module/printk.h +++ b/instrumentation/events/lttng-module/printk.h @@ -7,7 +7,25 @@ #include #include -#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 */