public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing/ftrace: add the printk-msg-only option
@ 2008-12-13 19:18 Frederic Weisbecker
  2008-12-14 17:04 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Frederic Weisbecker @ 2008-12-13 19:18 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, Linux Kernel

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

Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8fd3c5a..cd4dbf2 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -287,6 +287,7 @@ static const char *trace_options[] = {
 	"annotate",
 	"userstacktrace",
 	"sym-userobj",
+	"printk-msg-only",
 	NULL
 };
 
@@ -2265,6 +2266,25 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
 	return TRACE_TYPE_HANDLED;
 }
 
+static enum print_line_t print_printk_msg_only(struct trace_iterator *iter)
+{
+	struct trace_seq *s = &iter->seq;
+	struct trace_entry *entry = iter->ent;
+	struct print_entry *field;
+	int ret;
+
+	trace_assign_type(field, entry);
+
+	ret = trace_seq_printf(s, field->buf);
+	if (!ret)
+		return TRACE_TYPE_PARTIAL_LINE;
+
+	if (entry->flags & TRACE_FLAG_CONT)
+		trace_seq_print_cont(s, iter);
+
+	return TRACE_TYPE_HANDLED;
+}
+
 static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
 {
 	struct trace_seq *s = &iter->seq;
@@ -2345,6 +2365,11 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
 			return ret;
 	}
 
+	if (iter->ent->type == TRACE_PRINT &&
+			trace_flags & TRACE_ITER_PRINTK &&
+			trace_flags & TRACE_ITER_PRINTK_MSGONLY)
+		return print_printk_msg_only(iter);
+
 	if (trace_flags & TRACE_ITER_BIN)
 		return print_bin_fmt(iter);
 
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index f07c246..fc75dce 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -578,7 +578,8 @@ enum trace_iterator_flags {
 	TRACE_ITER_BRANCH		= 0x1000,
 	TRACE_ITER_ANNOTATE		= 0x2000,
 	TRACE_ITER_USERSTACKTRACE       = 0x4000,
-	TRACE_ITER_SYM_USEROBJ          = 0x8000
+	TRACE_ITER_SYM_USEROBJ          = 0x8000,
+	TRACE_ITER_PRINTK_MSGONLY	= 0x10000
 };
 
 /*
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tracing/ftrace: add the printk-msg-only option
  2008-12-13 19:18 [PATCH] tracing/ftrace: add the printk-msg-only option Frederic Weisbecker
@ 2008-12-14 17:04 ` Steven Rostedt
  2008-12-14 17:52   ` Frédéric Weisbecker
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2008-12-14 17:04 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: Ingo Molnar, Linux Kernel


On Sat, 13 Dec 2008, Frederic Weisbecker wrote:

> 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
> 
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> ---
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 8fd3c5a..cd4dbf2 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -287,6 +287,7 @@ static const char *trace_options[] = {
>  	"annotate",
>  	"userstacktrace",
>  	"sym-userobj",
> +	"printk-msg-only",

Hmm, I'm a bit apprehensive about this approach. We are adding a lot of 
options that I'm not sure will be used. Is this needed because you added a 
ftrace printk that you want to not have the header, or because there are 
ftrace printks that exist that you want to turn on and off. Or perhaps, 
you want to see the header sometimes and sometimes you do not?

If it is the later two, then sure we could have this option. But if it is 
the former, then we probably should have another type of ftrace_printk 
that takes an option to make another event type to tell the output not to 
print?

Oh well, I have patches in mind to clean up the output code anyway.

-- Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tracing/ftrace: add the printk-msg-only option
  2008-12-14 17:04 ` Steven Rostedt
@ 2008-12-14 17:52   ` Frédéric Weisbecker
  0 siblings, 0 replies; 3+ messages in thread
From: Frédéric Weisbecker @ 2008-12-14 17:52 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, Linux Kernel

2008/12/14 Steven Rostedt <rostedt@goodmis.org>:
>
> On Sat, 13 Dec 2008, Frederic Weisbecker wrote:
>
>> 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
>>
>> Cc: Steven Rostedt <rostedt@goodmis.org>
>> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
>> ---
>> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
>> index 8fd3c5a..cd4dbf2 100644
>> --- a/kernel/trace/trace.c
>> +++ b/kernel/trace/trace.c
>> @@ -287,6 +287,7 @@ static const char *trace_options[] = {
>>       "annotate",
>>       "userstacktrace",
>>       "sym-userobj",
>> +     "printk-msg-only",
>
> Hmm, I'm a bit apprehensive about this approach. We are adding a lot of
> options that I'm not sure will be used. Is this needed because you added a
> ftrace printk that you want to not have the header, or because there are
> ftrace printks that exist that you want to turn on and off. Or perhaps,
> you want to see the header sometimes and sometimes you do not?
>
> If it is the later two, then sure we could have this option. But if it is
> the former, then we probably should have another type of ftrace_printk
> that takes an option to make another event type to tell the output not to
> print?
>
> Oh well, I have patches in mind to clean up the output code anyway.
>
> -- Steve
>

Actually, it's not for my needs but Ingo requested it to have only the
message output without
the headers while debugging with ftrace_printk.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-14 17:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-13 19:18 [PATCH] tracing/ftrace: add the printk-msg-only option Frederic Weisbecker
2008-12-14 17:04 ` Steven Rostedt
2008-12-14 17:52   ` Frédéric Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox