public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] printk_time: prepare stub for using other than cpu_clock
@ 2008-08-27  7:38 Yinghai Lu
  2008-08-27  7:38 ` [PATCH] x86: printk_time to use tsc before cpu_clock is ready Yinghai Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Yinghai Lu @ 2008-08-27  7:38 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton
  Cc: linux-kernel, Yinghai Lu

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

---
 include/linux/kernel.h |    5 +++++
 init/main.c            |    1 +
 kernel/printk.c        |   14 +++++++++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

Index: linux-2.6/include/linux/kernel.h
===================================================================
--- linux-2.6.orig/include/linux/kernel.h
+++ linux-2.6/include/linux/kernel.h
@@ -190,7 +190,10 @@ extern int kernel_text_address(unsigned
 struct pid;
 extern struct pid *session_of_pgrp(struct pid *pgrp);
 
+typedef unsigned long long (*printk_time_clock_fn)(int cpu);
 #ifdef CONFIG_PRINTK
+extern void set_printk_time_clock(printk_time_clock_fn fn);
+
 asmlinkage int vprintk(const char *fmt, va_list args)
 	__attribute__ ((format (printf, 1, 0)));
 asmlinkage int printk(const char * fmt, ...)
@@ -201,6 +204,8 @@ extern int printk_ratelimit(void);
 extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
 				   unsigned int interval_msec);
 #else
+static inline void set_printk_time_clock(printk_time_clock_fn fn) { }
+
 static inline int vprintk(const char *s, va_list args)
 	__attribute__ ((format (printf, 1, 0)));
 static inline int vprintk(const char *s, va_list args) { return 0; }
Index: linux-2.6/init/main.c
===================================================================
--- linux-2.6.orig/init/main.c
+++ linux-2.6/init/main.c
@@ -671,6 +671,7 @@ asmlinkage void __init start_kernel(void
 	if (late_time_init)
 		late_time_init();
 	calibrate_delay();
+	set_printk_time_clock(cpu_clock);
 	pidmap_init();
 	pgtable_cache_init();
 	prio_tree_init();
Index: linux-2.6/kernel/printk.c
===================================================================
--- linux-2.6.orig/kernel/printk.c
+++ linux-2.6/kernel/printk.c
@@ -659,6 +659,18 @@ static int recursion_bug;
 	static int new_text_line = 1;
 static char printk_buf[1024];
 
+static unsigned long long default_printk_time_clock(int cpu)
+{
+	return 0;
+}
+
+static printk_time_clock_fn printk_time_clock = default_printk_time_clock;
+
+void set_printk_time_clock(printk_time_clock_fn fn)
+{
+	printk_time_clock = fn;
+}
+
 asmlinkage int vprintk(const char *fmt, va_list args)
 {
 	int printed_len = 0;
@@ -734,7 +746,7 @@ asmlinkage int vprintk(const char *fmt,
 				unsigned long long t;
 				unsigned long nanosec_rem;
 
-				t = cpu_clock(printk_cpu);
+				t = printk_time_clock(printk_cpu);
 				nanosec_rem = do_div(t, 1000000000);
 				tlen = sprintf(tbuf, "[%5lu.%06lu] ",
 						(unsigned long) t,

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH] printk_time: prepare stub for using other than cpu_clock
@ 2008-07-29 10:08 Yinghai Lu
  2008-07-29 10:09 ` [PATCH] x86: printk_time to use tsc before cpu_clock is ready Yinghai Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Yinghai Lu @ 2008-07-29 10:08 UTC (permalink / raw)
  To: Andrew Morton, Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel


Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

---
 include/linux/kernel.h |    5 +++++
 init/main.c            |    1 +
 kernel/printk.c        |   14 +++++++++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

Index: linux-2.6/include/linux/kernel.h
===================================================================
--- linux-2.6.orig/include/linux/kernel.h
+++ linux-2.6/include/linux/kernel.h
@@ -184,7 +184,10 @@ extern int kernel_text_address(unsigned
 struct pid;
 extern struct pid *session_of_pgrp(struct pid *pgrp);
 
+typedef unsigned long long (*printk_time_clock_fn)(int cpu);
 #ifdef CONFIG_PRINTK
+extern void set_printk_time_clock(printk_time_clock_fn fn);
+
 asmlinkage int vprintk(const char *fmt, va_list args)
 	__attribute__ ((format (printf, 1, 0)));
 asmlinkage int printk(const char * fmt, ...)
@@ -195,6 +198,8 @@ extern int printk_ratelimit(void);
 extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
 				   unsigned int interval_msec);
 #else
+static inline void set_printk_time_clock(printk_time_clock_fn fn) { }
+
 static inline int vprintk(const char *s, va_list args)
 	__attribute__ ((format (printf, 1, 0)));
 static inline int vprintk(const char *s, va_list args) { return 0; }
Index: linux-2.6/init/main.c
===================================================================
--- linux-2.6.orig/init/main.c
+++ linux-2.6/init/main.c
@@ -663,6 +663,7 @@ asmlinkage void __init start_kernel(void
 	if (late_time_init)
 		late_time_init();
 	calibrate_delay();
+	set_printk_time_clock(cpu_clock);
 	pidmap_init();
 	pgtable_cache_init();
 	prio_tree_init();
Index: linux-2.6/kernel/printk.c
===================================================================
--- linux-2.6.orig/kernel/printk.c
+++ linux-2.6/kernel/printk.c
@@ -662,6 +662,18 @@ static int recursion_bug;
 	static int new_text_line = 1;
 static char printk_buf[1024];
 
+static unsigned long long default_printk_time_clock(int cpu)
+{
+	return 0;
+}
+
+static printk_time_clock_fn printk_time_clock = default_printk_time_clock;
+
+void set_printk_time_clock(printk_time_clock_fn fn)
+{
+	printk_time_clock = fn;
+}
+
 asmlinkage int vprintk(const char *fmt, va_list args)
 {
 	int printed_len = 0;
@@ -737,7 +749,7 @@ asmlinkage int vprintk(const char *fmt,
 				unsigned long long t;
 				unsigned long nanosec_rem;
 
-				t = cpu_clock(printk_cpu);
+				t = printk_time_clock(printk_cpu);
 				nanosec_rem = do_div(t, 1000000000);
 				tlen = sprintf(tbuf, "[%5lu.%06lu] ",
 						(unsigned long) t,

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

end of thread, other threads:[~2008-08-27  8:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-27  7:38 [PATCH] printk_time: prepare stub for using other than cpu_clock Yinghai Lu
2008-08-27  7:38 ` [PATCH] x86: printk_time to use tsc before cpu_clock is ready Yinghai Lu
2008-08-27  7:42   ` Ingo Molnar
2008-08-27  7:47     ` Peter Zijlstra
2008-08-27  8:02       ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2008-07-29 10:08 [PATCH] printk_time: prepare stub for using other than cpu_clock Yinghai Lu
2008-07-29 10:09 ` [PATCH] x86: printk_time to use tsc before cpu_clock is ready Yinghai Lu
2008-07-29 10:13   ` Peter Zijlstra
2008-07-29 10:18     ` Yinghai Lu

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