* [PATCH] ftrace: using pr_fmt for better printk output
@ 2012-07-17 1:15 Jovi Zhang
2012-07-17 3:42 ` Joe Perches
0 siblings, 1 reply; 10+ messages in thread
From: Jovi Zhang @ 2012-07-17 1:15 UTC (permalink / raw)
To: rostedt, Frédéric Weisbecker, Ingo Molnar, LKML
>From fe42b2f29e5968482b3129c71f81a58a0559cf04 Mon Sep 17 00:00:00 2001
From: Jovi Zhang <bookjovi@gmail.com>
Date: Tue, 17 Jul 2012 17:10:15 +0800
Subject: [PATCH] ftrace: using pr_fmt for better printk output
There don't have subsystem name output in front ot ftrace related log entry,
so use pr_fmt to enable better printk output, for output subsystem name in
log entry.
Signed-off-by: Jovi Zhang <bookjovi@gmail.com>
---
kernel/trace/blktrace.c | 2 ++
kernel/trace/ftrace.c | 10 ++++++----
kernel/trace/trace.c | 5 ++++-
kernel/trace/trace_events.c | 2 ++
kernel/trace/trace_functions_graph.c | 9 ++++++---
kernel/trace/trace_kprobe.c | 2 ++
kernel/trace/trace_mmiotrace.c | 2 ++
kernel/trace/trace_probe.c | 2 ++
kernel/trace/trace_selftest.c | 6 +++---
kernel/trace/trace_syscalls.c | 9 +++++----
kernel/trace/trace_uprobe.c | 2 ++
11 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index c0bd030..940b5d7 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -15,6 +15,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
+#define pr_fmt(fmt) "blktrace: " fmt
+
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/blktrace_api.h>
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index a008663..c138ad7 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -13,6 +13,8 @@
* Copyright (C) 2004 William Lee Irwin III
*/
+#define pr_fmt(fmt) "ftrace: " fmt
+
#include <linux/stop_machine.h>
#include <linux/clocksource.h>
#include <linux/kallsyms.h>
@@ -2178,7 +2180,7 @@ ftrace_allocate_pages(unsigned long num_to_init)
kfree(pg);
pg = start_pg;
}
- pr_info("ftrace: FAILED to allocate memory for functions\n");
+ pr_info("FAILED to allocate memory for functions\n");
return NULL;
}
@@ -2187,12 +2189,12 @@ static int __init
ftrace_dyn_table_alloc(unsigned long num_to_init)
int cnt;
if (!num_to_init) {
- pr_info("ftrace: No functions to be traced?\n");
+ pr_info("No functions to be traced?\n");
return -1;
}
cnt = num_to_init / ENTRIES_PER_PAGE;
- pr_info("ftrace: allocating %ld entries in %d pages\n",
+ pr_info("allocating %ld entries in %d pages\n",
num_to_init, cnt + 1);
return 0;
@@ -4495,7 +4497,7 @@ static int start_graph_tracing(void)
if (!ret) {
ret = register_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
if (ret)
- pr_info("ftrace_graph: Couldn't activate tracepoint"
+ pr_info("Couldn't activate tracepoint"
" probe to kernel_sched_switch\n");
}
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a7fa070..dc06661 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -11,6 +11,9 @@
* Copyright (C) 2004-2006 Ingo Molnar
* Copyright (C) 2004 William Lee Irwin III
*/
+
+#define pr_fmt(fmt) "trace: " fmt
+
#include <linux/ring_buffer.h>
#include <generated/utsrelease.h>
#include <linux/stacktrace.h>
@@ -1566,7 +1569,7 @@ void trace_printk_init_buffers(void)
if (alloc_percpu_trace_buffer())
return;
- pr_info("ftrace: Allocated trace_printk buffers\n");
+ pr_info("Allocated trace_printk buffers\n");
buffers_allocated = 1;
}
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 29111da..0abdf37 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -8,6 +8,8 @@
*
*/
+#define pr_fmt(fmt) "trace_events: " fmt
+
#include <linux/workqueue.h>
#include <linux/spinlock.h>
#include <linux/kthread.h>
diff --git a/kernel/trace/trace_functions_graph.c
b/kernel/trace/trace_functions_graph.c
index a7d2a4c..97ed861 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -6,6 +6,9 @@
* is Copyright (c) Steven Rostedt <srostedt@redhat.com>
*
*/
+
+#define pr_fmt(fmt) "function graph tracer: " fmt
+
#include <linux/debugfs.h>
#include <linux/uaccess.h>
#include <linux/ftrace.h>
@@ -1401,7 +1404,7 @@ void graph_trace_open(struct trace_iterator *iter)
out_err_free:
kfree(data);
out_err:
- pr_warning("function graph tracer: not enough memory\n");
+ pr_warn("not enough memory\n");
}
void graph_trace_close(struct trace_iterator *iter)
@@ -1459,12 +1462,12 @@ static __init int init_graph_trace(void)
max_bytes_for_cpu = snprintf(NULL, 0, "%d", nr_cpu_ids - 1);
if (!register_ftrace_event(&graph_trace_entry_event)) {
- pr_warning("Warning: could not register graph trace events\n");
+ pr_warn("Warning: could not register graph trace events\n");
return 1;
}
if (!register_ftrace_event(&graph_trace_ret_event)) {
- pr_warning("Warning: could not register graph trace events\n");
+ pr_warn("Warning: could not register graph trace events\n");
return 1;
}
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index b31d3d5..7396848 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define pr_fmt(fmt) "trace_kprobe: " fmt
+
#include <linux/module.h>
#include <linux/uaccess.h>
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index fd3c8aa..56d1a03 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -4,6 +4,8 @@
* Copyright (C) 2008 Pekka Paalanen <pq@iki.fi>
*/
+#define pr_fmt(fmt) "trace_mmiotrace: " fmt
+
#define DEBUG 1
#include <linux/kernel.h>
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index daa9980..0a7ebad 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -22,6 +22,8 @@
* Author: Srikar Dronamraju
*/
+#define pr_fmt(fmt) "trace_probe: " fmt
+
#include "trace_probe.h"
const char *reserved_field_names[] = {
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 288541f..634f5af 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -94,7 +94,7 @@ static int trace_test_buffer(struct trace_array *tr,
unsigned long *count)
static inline void warn_failed_init_tracer(struct tracer *trace, int init_ret)
{
- printk(KERN_WARNING "Failed to init %s tracer, init returned %d\n",
+ pr_warn("Failed to init %s tracer, init returned %d\n",
trace->name, init_ret);
}
#ifdef CONFIG_FUNCTION_TRACER
@@ -236,7 +236,7 @@ static int trace_selftest_ops(int cnt)
/* Add a dynamic probe */
dyn_ops = kzalloc(sizeof(*dyn_ops), GFP_KERNEL);
if (!dyn_ops) {
- printk("MEMORY ERROR ");
+ pr_err("MEMORY ERROR ");
goto out;
}
@@ -471,7 +471,7 @@ static int trace_graph_entry_watchdog(struct
ftrace_graph_ent *trace)
/* This is harmlessly racy, we want to approximately detect a hang */
if (unlikely(++graph_hang_thresh > GRAPH_MAX_FUNC_TEST)) {
ftrace_graph_stop();
- printk(KERN_WARNING "BUG: Function graph tracer hang!\n");
+ pr_warn("BUG: Function graph tracer hang!\n");
if (ftrace_dump_on_oops)
__ftrace_dump(false, DUMP_ALL);
return 0;
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 96fc733..8163e89 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -1,3 +1,6 @@
+
+#define pr_fmt(fmt) "trace_syscalls: " fmt
+
#include <trace/syscall.h>
#include <trace/events/syscalls.h>
#include <linux/slab.h>
@@ -546,8 +549,7 @@ int perf_sysenter_enable(struct ftrace_event_call *call)
if (!sys_perf_refcount_enter)
ret = register_trace_sys_enter(perf_syscall_enter, NULL);
if (ret) {
- pr_info("event trace: Could not activate"
- "syscall entry trace point");
+ pr_info("Could not activate syscall entry trace point");
} else {
set_bit(num, enabled_perf_enter_syscalls);
sys_perf_refcount_enter++;
@@ -622,8 +624,7 @@ int perf_sysexit_enable(struct ftrace_event_call *call)
if (!sys_perf_refcount_exit)
ret = register_trace_sys_exit(perf_syscall_exit, NULL);
if (ret) {
- pr_info("event trace: Could not activate"
- "syscall exit trace point");
+ pr_info("Could not activate syscall exit trace point");
} else {
set_bit(num, enabled_perf_exit_syscalls);
sys_perf_refcount_exit++;
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 2b36ac6..a677f36 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -18,6 +18,8 @@
* Author: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
*/
+#define pr_fmt(fmt) "trace_uprobe: " fmt
+
#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/uprobes.h>
--
1.7.9.7
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] ftrace: using pr_fmt for better printk output
2012-07-17 1:15 [PATCH] ftrace: using pr_fmt for better printk output Jovi Zhang
@ 2012-07-17 3:42 ` Joe Perches
2012-07-17 4:25 ` Steven Rostedt
0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2012-07-17 3:42 UTC (permalink / raw)
To: Jovi Zhang; +Cc: rostedt, Frédéric Weisbecker, Ingo Molnar, LKML
On Tue, 2012-07-17 at 09:15 +0800, Jovi Zhang wrote:
> >From fe42b2f29e5968482b3129c71f81a58a0559cf04 Mon Sep 17 00:00:00 2001
[]
> There don't have subsystem name output in front ot ftrace related log entry,
> so use pr_fmt to enable better printk output, for output subsystem name in
> log entry.
Hi Jovi. A few things:
Your patch has 80 column wrapping issues and doesn't
apply cleanly.
This sort of patch, because it's trivial and not really
important to apply this close to an actual release, should
be done against linux-next not current mainline.
The #define pr_fmt(fmt) should probably use KBUILD_MODNAME.
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Please coalesce formats even though they then may exceed
80 columns and compress multiple lines that fit in 80 too.
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
[]
> @@ -13,6 +13,8 @@
> * Copyright (C) 2004 William Lee Irwin III
> */
>
> +#define pr_fmt(fmt) "ftrace: " fmt
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
[]
> @@ -2187,12 +2189,12 @@ static int __init
> ftrace_dyn_table_alloc(unsigned long num_to_init)
wrapped
> int cnt;
>
> if (!num_to_init) {
> - pr_info("ftrace: No functions to be traced?\n");
> + pr_info("No functions to be traced?\n");
> return -1;
> }
>
> cnt = num_to_init / ENTRIES_PER_PAGE;
> - pr_info("ftrace: allocating %ld entries in %d pages\n",
> + pr_info("allocating %ld entries in %d pages\n",
> num_to_init, cnt + 1);
Single line:
pr_info("allocating %ld entries in %d pages\n", num_to_init, cnt + 1);
> @@ -4495,7 +4497,7 @@ static int start_graph_tracing(void)
> if (!ret) {
> ret = register_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
> if (ret)
> - pr_info("ftrace_graph: Couldn't activate tracepoint"
> + pr_info("Couldn't activate tracepoint"
> " probe to kernel_sched_switch\n");
Coalesce format:
pr_info("Couldn't activate tracepoint probe to kernel_sched_switch\n");
etc...
cheers, Joe
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] ftrace: using pr_fmt for better printk output
2012-07-17 3:42 ` Joe Perches
@ 2012-07-17 4:25 ` Steven Rostedt
2012-07-17 5:07 ` Joe Perches
2012-07-17 5:23 ` Jovi Zhang
0 siblings, 2 replies; 10+ messages in thread
From: Steven Rostedt @ 2012-07-17 4:25 UTC (permalink / raw)
To: Joe Perches; +Cc: Jovi Zhang, Frédéric Weisbecker, Ingo Molnar, LKML
On Mon, 2012-07-16 at 20:42 -0700, Joe Perches wrote:
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> []
> > @@ -13,6 +13,8 @@
> > * Copyright (C) 2004 William Lee Irwin III
> > */
> >
> > +#define pr_fmt(fmt) "ftrace: " fmt
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Wouldn't a nicer patch be to move this into a header file and then
remove all the defines throughout the kernel tree?
Also, what is KBUILD_MODNAME defined as for non-modules? As ftrace is
not a module.
-- Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ftrace: using pr_fmt for better printk output
2012-07-17 4:25 ` Steven Rostedt
@ 2012-07-17 5:07 ` Joe Perches
2012-07-17 5:32 ` Jovi Zhang
2012-07-17 5:23 ` Jovi Zhang
1 sibling, 1 reply; 10+ messages in thread
From: Joe Perches @ 2012-07-17 5:07 UTC (permalink / raw)
To: Steven Rostedt
Cc: Jovi Zhang, Frédéric Weisbecker, Ingo Molnar, LKML
On Tue, 2012-07-17 at 00:25 -0400, Steven Rostedt wrote:
> On Mon, 2012-07-16 at 20:42 -0700, Joe Perches wrote:
>
> > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> > []
> > > @@ -13,6 +13,8 @@
> > > * Copyright (C) 2004 William Lee Irwin III
> > > */
> > >
> > > +#define pr_fmt(fmt) "ftrace: " fmt
> >
> > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> Wouldn't a nicer patch be to move this into a header file and then
> remove all the defines throughout the kernel tree?
Maybe. There are modules that use common header files
like you suggest. It does mean that header must be the
#included before any other #include that might
#include <linux/kernel.h> or printk.h.
Right now, if pr_fmt isn't #defined, printk.h
has a default definition of:
#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif
My goal is to change that to:
#ifndef pr_fmt
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#endif
in 3.8 (maybe 3.7) and remove all of these then
useless, duplicate #defines shortly afterward.
https://lkml.org/lkml/2012/3/27/247
> Also, what is KBUILD_MODNAME defined as for non-modules? As ftrace is
> not a module.
It depends on the Makefile.
scripts/Makefile.lib:# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
scripts/Makefile.lib-# end up in (or would, if it gets compiled in)
scripts/Makefile.lib-# Note: Files that end up in two or more modules are compiled without the
scripts/Makefile.lib:# KBUILD_MODNAME definition. The reason is that any made-up name would
scripts/Makefile.lib-# differ in different configs.
scripts/Makefile.lib-name-fix = $(subst $(comma),_,$(subst -,_,$1))
scripts/Makefile.lib-basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
scripts/Makefile.lib-modname_flags = $(if $(filter 1,$(words $(modname))),\
scripts/Makefile.lib: -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ftrace: using pr_fmt for better printk output
2012-07-17 5:07 ` Joe Perches
@ 2012-07-17 5:32 ` Jovi Zhang
2012-07-17 5:37 ` Joe Perches
0 siblings, 1 reply; 10+ messages in thread
From: Jovi Zhang @ 2012-07-17 5:32 UTC (permalink / raw)
To: Joe Perches
Cc: Steven Rostedt, Frédéric Weisbecker, Ingo Molnar, LKML
On Tue, Jul 17, 2012 at 1:07 PM, Joe Perches <joe@perches.com> wrote:
> On Tue, 2012-07-17 at 00:25 -0400, Steven Rostedt wrote:
>> On Mon, 2012-07-16 at 20:42 -0700, Joe Perches wrote:
>>
>> > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
>> > []
>> > > @@ -13,6 +13,8 @@
>> > > * Copyright (C) 2004 William Lee Irwin III
>> > > */
>> > >
>> > > +#define pr_fmt(fmt) "ftrace: " fmt
>> >
>> > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>>
>> Wouldn't a nicer patch be to move this into a header file and then
>> remove all the defines throughout the kernel tree?
>
> Maybe. There are modules that use common header files
> like you suggest. It does mean that header must be the
> #included before any other #include that might
> #include <linux/kernel.h> or printk.h.
>
> Right now, if pr_fmt isn't #defined, printk.h
> has a default definition of:
>
> #ifndef pr_fmt
> #define pr_fmt(fmt) fmt
> #endif
>
> My goal is to change that to:
>
> #ifndef pr_fmt
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> #endif
>
> in 3.8 (maybe 3.7) and remove all of these then
> useless, duplicate #defines shortly afterward.
>
> https://lkml.org/lkml/2012/3/27/247
>
>> Also, what is KBUILD_MODNAME defined as for non-modules? As ftrace is
>> not a module.
>
> It depends on the Makefile.
>
> scripts/Makefile.lib:# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
> scripts/Makefile.lib-# end up in (or would, if it gets compiled in)
> scripts/Makefile.lib-# Note: Files that end up in two or more modules are compiled without the
> scripts/Makefile.lib:# KBUILD_MODNAME definition. The reason is that any made-up name would
> scripts/Makefile.lib-# differ in different configs.
> scripts/Makefile.lib-name-fix = $(subst $(comma),_,$(subst -,_,$1))
> scripts/Makefile.lib-basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
> scripts/Makefile.lib-modname_flags = $(if $(filter 1,$(words $(modname))),\
> scripts/Makefile.lib: -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
>
Hmm, that would make sense, get subsystem name from Makefile.
Joe, there will delete all this pr_fmt definition in .c file in 3.8(or
3.7) as you metioned, so we can ingnore this patch.
.Jovi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ftrace: using pr_fmt for better printk output
2012-07-17 5:32 ` Jovi Zhang
@ 2012-07-17 5:37 ` Joe Perches
2012-07-17 6:47 ` Jovi Zhang
0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2012-07-17 5:37 UTC (permalink / raw)
To: Jovi Zhang
Cc: Steven Rostedt, Frédéric Weisbecker, Ingo Molnar, LKML
On Tue, 2012-07-17 at 13:32 +0800, Jovi Zhang wrote:
> On Tue, Jul 17, 2012 at 1:07 PM, Joe Perches <joe@perches.com> wrote:
> > On Tue, 2012-07-17 at 00:25 -0400, Steven Rostedt wrote:
[]
> >> Also, what is KBUILD_MODNAME defined as for non-modules? As ftrace is
> >> not a module.
> >
> > It depends on the Makefile.
> >
> > scripts/Makefile.lib:# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
> > scripts/Makefile.lib-# end up in (or would, if it gets compiled in)
> > scripts/Makefile.lib-# Note: Files that end up in two or more modules are compiled without the
> > scripts/Makefile.lib:# KBUILD_MODNAME definition. The reason is that any made-up name would
> > scripts/Makefile.lib-# differ in different configs.
> > scripts/Makefile.lib-name-fix = $(subst $(comma),_,$(subst -,_,$1))
> > scripts/Makefile.lib-basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
> > scripts/Makefile.lib-modname_flags = $(if $(filter 1,$(words $(modname))),\
> > scripts/Makefile.lib: -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
> >
> Hmm, that would make sense, get subsystem name from Makefile.
>
> Joe, there will delete all this pr_fmt definition in .c file in 3.8(or
> 3.7) as you metioned, so we can ingnore this patch.
Not quite. The uses that have embedded prefixes need updating.
You've done that in bits of this patch.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ftrace: using pr_fmt for better printk output
2012-07-17 5:37 ` Joe Perches
@ 2012-07-17 6:47 ` Jovi Zhang
0 siblings, 0 replies; 10+ messages in thread
From: Jovi Zhang @ 2012-07-17 6:47 UTC (permalink / raw)
To: Joe Perches; +Cc: Steven Rostedt, LKML
>From cea5f76c3ad9f42b85a1a71b75035fe96317187a Mon Sep 17 00:00:00 2001
From: Jovi Zhang <bookjovi@gmail.com>
Date: Tue, 17 Jul 2012 22:43:11 +0800
Subject: [PATCH] ftrace: using pr_fmt for better printk output
There don't have subsystem name output in front ot ftrace related log entry,
so use pr_fmt to enable better printk output, for output subsystem name in
log entry.
Signed-off-by: Jovi Zhang <bookjovi@gmail.com>
---
kernel/trace/blktrace.c | 2 ++
kernel/trace/ftrace.c | 11 ++++++-----
kernel/trace/trace.c | 5 ++++-
kernel/trace/trace_events.c | 2 ++
kernel/trace/trace_functions_graph.c | 9 ++++++---
kernel/trace/trace_kprobe.c | 2 ++
kernel/trace/trace_mmiotrace.c | 2 ++
kernel/trace/trace_probe.c | 2 ++
kernel/trace/trace_selftest.c | 6 +++---
kernel/trace/trace_syscalls.c | 8 ++++----
kernel/trace/trace_uprobe.c | 2 ++
11 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index c0bd030..65c521f 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -15,6 +15,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/blktrace_api.h>
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index a008663..1198ebd 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -13,6 +13,8 @@
* Copyright (C) 2004 William Lee Irwin III
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/stop_machine.h>
#include <linux/clocksource.h>
#include <linux/kallsyms.h>
@@ -2178,7 +2180,7 @@ ftrace_allocate_pages(unsigned long num_to_init)
kfree(pg);
pg = start_pg;
}
- pr_info("ftrace: FAILED to allocate memory for functions\n");
+ pr_info("FAILED to allocate memory for functions\n");
return NULL;
}
@@ -2187,12 +2189,12 @@ static int __init
ftrace_dyn_table_alloc(unsigned long num_to_init)
int cnt;
if (!num_to_init) {
- pr_info("ftrace: No functions to be traced?\n");
+ pr_info("No functions to be traced?\n");
return -1;
}
cnt = num_to_init / ENTRIES_PER_PAGE;
- pr_info("ftrace: allocating %ld entries in %d pages\n",
+ pr_info("allocating %ld entries in %d pages\n",
num_to_init, cnt + 1);
return 0;
@@ -4495,8 +4497,7 @@ static int start_graph_tracing(void)
if (!ret) {
ret = register_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
if (ret)
- pr_info("ftrace_graph: Couldn't activate tracepoint"
- " probe to kernel_sched_switch\n");
+ pr_info("Couldn't activate tracepoint probe to kernel_sched_switch\n");
}
kfree(ret_stack_list);
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a7fa070..265f4a5 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -11,6 +11,9 @@
* Copyright (C) 2004-2006 Ingo Molnar
* Copyright (C) 2004 William Lee Irwin III
*/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/ring_buffer.h>
#include <generated/utsrelease.h>
#include <linux/stacktrace.h>
@@ -1566,7 +1569,7 @@ void trace_printk_init_buffers(void)
if (alloc_percpu_trace_buffer())
return;
- pr_info("ftrace: Allocated trace_printk buffers\n");
+ pr_info("Allocated trace_printk buffers\n");
buffers_allocated = 1;
}
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 29111da..11dd55c 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -8,6 +8,8 @@
*
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/workqueue.h>
#include <linux/spinlock.h>
#include <linux/kthread.h>
diff --git a/kernel/trace/trace_functions_graph.c
b/kernel/trace/trace_functions_graph.c
index a7d2a4c..a2be82b 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -6,6 +6,9 @@
* is Copyright (c) Steven Rostedt <srostedt@redhat.com>
*
*/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/debugfs.h>
#include <linux/uaccess.h>
#include <linux/ftrace.h>
@@ -1401,7 +1404,7 @@ void graph_trace_open(struct trace_iterator *iter)
out_err_free:
kfree(data);
out_err:
- pr_warning("function graph tracer: not enough memory\n");
+ pr_warn("not enough memory\n");
}
void graph_trace_close(struct trace_iterator *iter)
@@ -1459,12 +1462,12 @@ static __init int init_graph_trace(void)
max_bytes_for_cpu = snprintf(NULL, 0, "%d", nr_cpu_ids - 1);
if (!register_ftrace_event(&graph_trace_entry_event)) {
- pr_warning("Warning: could not register graph trace events\n");
+ pr_warn("Warning: could not register graph trace events\n");
return 1;
}
if (!register_ftrace_event(&graph_trace_ret_event)) {
- pr_warning("Warning: could not register graph trace events\n");
+ pr_warn("Warning: could not register graph trace events\n");
return 1;
}
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index b31d3d5..381e5f5 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/module.h>
#include <linux/uaccess.h>
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index fd3c8aa..f23312e 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -4,6 +4,8 @@
* Copyright (C) 2008 Pekka Paalanen <pq@iki.fi>
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#define DEBUG 1
#include <linux/kernel.h>
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index daa9980..5587fe8 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -22,6 +22,8 @@
* Author: Srikar Dronamraju
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include "trace_probe.h"
const char *reserved_field_names[] = {
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 288541f..634f5af 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -94,7 +94,7 @@ static int trace_test_buffer(struct trace_array *tr,
unsigned long *count)
static inline void warn_failed_init_tracer(struct tracer *trace, int init_ret)
{
- printk(KERN_WARNING "Failed to init %s tracer, init returned %d\n",
+ pr_warn("Failed to init %s tracer, init returned %d\n",
trace->name, init_ret);
}
#ifdef CONFIG_FUNCTION_TRACER
@@ -236,7 +236,7 @@ static int trace_selftest_ops(int cnt)
/* Add a dynamic probe */
dyn_ops = kzalloc(sizeof(*dyn_ops), GFP_KERNEL);
if (!dyn_ops) {
- printk("MEMORY ERROR ");
+ pr_err("MEMORY ERROR ");
goto out;
}
@@ -471,7 +471,7 @@ static int trace_graph_entry_watchdog(struct
ftrace_graph_ent *trace)
/* This is harmlessly racy, we want to approximately detect a hang */
if (unlikely(++graph_hang_thresh > GRAPH_MAX_FUNC_TEST)) {
ftrace_graph_stop();
- printk(KERN_WARNING "BUG: Function graph tracer hang!\n");
+ pr_warn("BUG: Function graph tracer hang!\n");
if (ftrace_dump_on_oops)
__ftrace_dump(false, DUMP_ALL);
return 0;
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 96fc733..adccbc0 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -1,3 +1,5 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <trace/syscall.h>
#include <trace/events/syscalls.h>
#include <linux/slab.h>
@@ -546,8 +548,7 @@ int perf_sysenter_enable(struct ftrace_event_call *call)
if (!sys_perf_refcount_enter)
ret = register_trace_sys_enter(perf_syscall_enter, NULL);
if (ret) {
- pr_info("event trace: Could not activate"
- "syscall entry trace point");
+ pr_info("Could not activate syscall entry trace point");
} else {
set_bit(num, enabled_perf_enter_syscalls);
sys_perf_refcount_enter++;
@@ -622,8 +623,7 @@ int perf_sysexit_enable(struct ftrace_event_call *call)
if (!sys_perf_refcount_exit)
ret = register_trace_sys_exit(perf_syscall_exit, NULL);
if (ret) {
- pr_info("event trace: Could not activate"
- "syscall exit trace point");
+ pr_info("Could not activate syscall exit trace point");
} else {
set_bit(num, enabled_perf_exit_syscalls);
sys_perf_refcount_exit++;
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 2b36ac6..85158fa 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -18,6 +18,8 @@
* Author: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/uprobes.h>
--
1.7.9.7
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] ftrace: using pr_fmt for better printk output
2012-07-17 4:25 ` Steven Rostedt
2012-07-17 5:07 ` Joe Perches
@ 2012-07-17 5:23 ` Jovi Zhang
2012-07-17 5:27 ` Joe Perches
2012-07-17 5:29 ` Joe Perches
1 sibling, 2 replies; 10+ messages in thread
From: Jovi Zhang @ 2012-07-17 5:23 UTC (permalink / raw)
To: Steven Rostedt
Cc: Joe Perches, Frédéric Weisbecker, Ingo Molnar, LKML
On Tue, Jul 17, 2012 at 12:25 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Mon, 2012-07-16 at 20:42 -0700, Joe Perches wrote:
>
>> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
>> []
>> > @@ -13,6 +13,8 @@
>> > * Copyright (C) 2004 William Lee Irwin III
>> > */
>> >
>> > +#define pr_fmt(fmt) "ftrace: " fmt
>>
>> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> Wouldn't a nicer patch be to move this into a header file and then
> remove all the defines throughout the kernel tree?
Maybe it's hard to achieve that.
subsystem name is unique with each other, it should be visible in source file,
if include into header file, then each .c file might need a own header
file for include pr_fmt
definition, then that header file cannot be reusable(avoid subsystem
name conflicts).
>
> Also, what is KBUILD_MODNAME defined as for non-modules? As ftrace is
> not a module.
Yes, that's why I cannot use KBUILD_MODNAME in patch.
>
> -- Steve
I don't make sure if there have some method or skill to let GCC knows
subsystem name automatically,
use built-in macro __FILE__? but this need condition of subsystem name
is same as file name,
not so easily to guarantee that.
.jovi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ftrace: using pr_fmt for better printk output
2012-07-17 5:23 ` Jovi Zhang
@ 2012-07-17 5:27 ` Joe Perches
2012-07-17 5:29 ` Joe Perches
1 sibling, 0 replies; 10+ messages in thread
From: Joe Perches @ 2012-07-17 5:27 UTC (permalink / raw)
To: Jovi Zhang
Cc: Steven Rostedt, Frédéric Weisbecker, Ingo Molnar, LKML
On Tue, 2012-07-17 at 13:23 +0800, Jovi Zhang wrote:
> On Tue, Jul 17, 2012 at 12:25 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
> > On Mon, 2012-07-16 at 20:42 -0700, Joe Perches wrote:
> >
> >> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> >> []
> >> > @@ -13,6 +13,8 @@
> >> > * Copyright (C) 2004 William Lee Irwin III
> >> > */
> >> >
> >> > +#define pr_fmt(fmt) "ftrace: " fmt
> >>
> >> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> >
> > Wouldn't a nicer patch be to move this into a header file and then
> > remove all the defines throughout the kernel tree?
>
> Maybe it's hard to achieve that.
> subsystem name is unique with each other, it should be visible in source file,
> if include into header file, then each .c file might need a own header
> file for include pr_fmt
> definition, then that header file cannot be reusable(avoid subsystem
> name conflicts).
>
> >
> > Also, what is KBUILD_MODNAME defined as for non-modules? As ftrace is
> > not a module.
> Yes, that's why I cannot use KBUILD_MODNAME in patch.
Incorrect, try it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ftrace: using pr_fmt for better printk output
2012-07-17 5:23 ` Jovi Zhang
2012-07-17 5:27 ` Joe Perches
@ 2012-07-17 5:29 ` Joe Perches
1 sibling, 0 replies; 10+ messages in thread
From: Joe Perches @ 2012-07-17 5:29 UTC (permalink / raw)
To: Jovi Zhang
Cc: Steven Rostedt, Frédéric Weisbecker, Ingo Molnar, LKML
On Tue, 2012-07-17 at 13:23 +0800, Jovi Zhang wrote:
> I don't make sure if there have some method or skill to let GCC knows
> subsystem name automatically,
> use built-in macro __FILE__? but this need condition of subsystem name
> is same as file name,
> not so easily to guarantee that.
You could use KBUILD_BASENAME instead.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-07-17 6:47 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-17 1:15 [PATCH] ftrace: using pr_fmt for better printk output Jovi Zhang
2012-07-17 3:42 ` Joe Perches
2012-07-17 4:25 ` Steven Rostedt
2012-07-17 5:07 ` Joe Perches
2012-07-17 5:32 ` Jovi Zhang
2012-07-17 5:37 ` Joe Perches
2012-07-17 6:47 ` Jovi Zhang
2012-07-17 5:23 ` Jovi Zhang
2012-07-17 5:27 ` Joe Perches
2012-07-17 5:29 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox