[PATCH -tip 2/2] Tracing/fastboot: Get the initcall name before it disappears

Previous thread: [PATCH -tip 1/2] Tracing/fastboot: Change the printing of boot tracer according to bootgraph.pl by Frederic Weisbecker on Thursday, October 2, 2008 - 3:59 am. (2 messages)

Next thread: [PATCH 1/2] MMC: Use timeout values from CSR by Matt Fleming on Thursday, October 2, 2008 - 4:56 am. (1 message)
From: Frederic Weisbecker
Date: Thursday, October 2, 2008 - 4:26 am

After some initcall traces, some initcall names may be inconsistent.
That's because these functions will disappear from the .init section
and also their name from the symbols table.
So we have to copy the name of the function in a buffer large enough
during the trace appending. It is not costly for the ring_buffer because
the number of initcall entries is commonly not really large.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 include/linux/ftrace.h    |    7 ++++---
 init/main.c               |    3 +--
 kernel/trace/trace_boot.c |   14 ++++++++++----
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 4455490..e672e51 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -7,6 +7,7 @@
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/kallsyms.h>
 
 extern int ftrace_enabled;
 extern int
@@ -213,7 +214,7 @@ ftrace_init_module(unsigned long *start, unsigned long *end) { }
 
 struct boot_trace {
 	pid_t			caller;
-	initcall_t		func;
+	char 			func[KSYM_NAME_LEN];
 	int			result;
 	unsigned long long	duration;
 	ktime_t			calltime;
@@ -221,10 +222,10 @@ struct boot_trace {
 };
 
 #ifdef CONFIG_BOOT_TRACER
-extern void trace_boot(struct boot_trace *it);
+extern void trace_boot(struct boot_trace *it, initcall_t fn);
 extern void start_boot_trace(void);
 #else
-static inline void trace_boot(struct boot_trace *it) { }
+static inline void trace_boot(struct boot_trace *it, initcall_t fn) { }
 static inline void start_boot_trace(void) { }
 #endif
 
diff --git a/init/main.c b/init/main.c
index ac3f760..47d621a 100644
--- a/init/main.c
+++ b/init/main.c
@@ -727,7 +727,6 @@ int do_one_initcall(initcall_t fn)
 
 	if (initcall_debug) {
 		it.caller = task_pid_nr(current);
-		it.func = fn;
 		printk("calling  %pF @ %i\n", fn, it.caller);
 		it.calltime = ktime_get();
 	}
@@ -740,7 +739,7 @@ int do_one_initcall(initcall_t fn)
 ...
From: Ingo Molnar
Date: Thursday, October 2, 2008 - 5:02 am

applied to tip/tracing/fastboot, thanks Frederic,

	Ingo
--

From: Frédéric Weisbecker
Date: Thursday, October 2, 2008 - 5:18 am

BTW I forgot to cc Arjan.
Arjan if you have some time to test it, I would be interested by your
feeling about it since
the boot tracer has now an output which is parsable by bootgraph.pl.

Thanks!
--

From: Ingo Molnar
Date: Thursday, October 2, 2008 - 8:47 am

From 7d14307eeaa710427436c09c6f77dde1974621cf Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Thu, 2 Oct 2008 17:45:47 +0200
Subject: [PATCH] tracing/fastboot: build fix

fix:

 In file included from kernel/sysctl.c:52:
 include/linux/ftrace.h:217: error: 'KSYM_NAME_LEN' undeclared here (not in a function)

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/ftrace.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index e672e51..deded11 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -1,14 +1,14 @@
 #ifndef _LINUX_FTRACE_H
 #define _LINUX_FTRACE_H
 
-#ifdef CONFIG_FTRACE
-
 #include <linux/linkage.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/kallsyms.h>
 
+#ifdef CONFIG_FTRACE
+
 extern int ftrace_enabled;
 extern int
 ftrace_enable_sysctl(struct ctl_table *table, int write,
--

Previous thread: [PATCH -tip 1/2] Tracing/fastboot: Change the printing of boot tracer according to bootgraph.pl by Frederic Weisbecker on Thursday, October 2, 2008 - 3:59 am. (2 messages)

Next thread: [PATCH 1/2] MMC: Use timeout values from CSR by Matt Fleming on Thursday, October 2, 2008 - 4:56 am. (1 message)