Skip to content

Commit 66896a8

Browse files
fweisbecIngo Molnar
authored andcommitted
tracing/ftrace: add the printk-msg-only option
Impact: display ftrace_printk messages "as is" By default, ftrace_printk() messages find their output with some other informations like pid, caller, ... Sometimes a developer just want to have the ftrace_printk left "as is", without other information. This is done by providing a default-off option called printk-msg-only. To enable it, just do `echo printk-msg-only > /debugfs/tracing/trace_options` Before the patch: <...>-2739 [000] 145.692153: __might_sleep: I'm an ftrace_printk msg in __might_sleep <...>-2739 [000] 145.692155: __might_sleep: I'm another ftrace_printk msg in __might_sleep After the patch and the printk-msg-only option enabled: I'm an ftrace_printk msg in __might_sleep I'm another ftrace_printk msg in __might_sleep Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 2c2d732 commit 66896a8

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎kernel/trace/trace.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ static const char *trace_options[] = {
287287
"annotate",
288288
"userstacktrace",
289289
"sym-userobj",
290+
"printk-msg-only",
290291
NULL
291292
};
292293

@@ -2265,6 +2266,25 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
22652266
return TRACE_TYPE_HANDLED;
22662267
}
22672268

2269+
static enum print_line_t print_printk_msg_only(struct trace_iterator *iter)
2270+
{
2271+
struct trace_seq *s = &iter->seq;
2272+
struct trace_entry *entry = iter->ent;
2273+
struct print_entry *field;
2274+
int ret;
2275+
2276+
trace_assign_type(field, entry);
2277+
2278+
ret = trace_seq_printf(s, field->buf);
2279+
if (!ret)
2280+
return TRACE_TYPE_PARTIAL_LINE;
2281+
2282+
if (entry->flags & TRACE_FLAG_CONT)
2283+
trace_seq_print_cont(s, iter);
2284+
2285+
return TRACE_TYPE_HANDLED;
2286+
}
2287+
22682288
static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
22692289
{
22702290
struct trace_seq *s = &iter->seq;
@@ -2345,6 +2365,11 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
23452365
return ret;
23462366
}
23472367

2368+
if (iter->ent->type == TRACE_PRINT &&
2369+
trace_flags & TRACE_ITER_PRINTK &&
2370+
trace_flags & TRACE_ITER_PRINTK_MSGONLY)
2371+
return print_printk_msg_only(iter);
2372+
23482373
if (trace_flags & TRACE_ITER_BIN)
23492374
return print_bin_fmt(iter);
23502375

‎kernel/trace/trace.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,8 @@ enum trace_iterator_flags {
578578
TRACE_ITER_BRANCH = 0x1000,
579579
TRACE_ITER_ANNOTATE = 0x2000,
580580
TRACE_ITER_USERSTACKTRACE = 0x4000,
581-
TRACE_ITER_SYM_USEROBJ = 0x8000
581+
TRACE_ITER_SYM_USEROBJ = 0x8000,
582+
TRACE_ITER_PRINTK_MSGONLY = 0x10000
582583
};
583584

584585
/*

0 commit comments

Comments
 (0)