printk_time: prepare stub for using other than cpu_clock
PATCH 1/1 printk_time: prepare stub for using other than cpu_clock
--- include/linux/kernel.h | 5 +++++ init/main.c | 1 + kernel/printk.c | 14 +++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-)
include/linux/kernel.h +5 -0
@@ -190,7 +190,10 @@ extern int kernel_text_address(unsignedstruct 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 ; }
init/main.c +1 -0
@@ -671,6 +671,7 @@ asmlinkage void __init start_kernel(voidif (late_time_init)late_time_init ();calibrate_delay (); +set_printk_time_clock (cpu_clock);pidmap_init ();pgtable_cache_init ();prio_tree_init ();
kernel/printk.c +13 -1
@@ -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,
PATCH 1/1 x86: printk_time to use tsc before cpu_clock is ready
so can get tsc value on printk at first.
for debug delay with big system with a lot of memory.
need to apply after
[PATCH] printk_time: prepare stub for using other than cpu_clock
--- arch/x86/kernel/cpu/common.c | 11 +++++++++++ arch/x86/kernel/cpu/common_64.c | 12 ++++++++++++ 2 files changed, 23 insertions(+)
arch/x86/kernel/cpu/common.c +11 -0
@@ -647,6 +647,15 @@ __setup("clearcpuid=", setup_disablecpuicpumask_t cpu_initialized__cpuinitdata =CPU_MASK_NONE ; +static unsigned long long tsc_clock (int cpu) +{ +unsigned long long t; + +rdtscll (t); + +return t; +} +void __init early_cpu_init (void ) {struct cpu_vendor_dev *cvdev;
@@ -657,6 +666,8 @@ void __init early_cpu_init(void) cpu_devs[cvdev->vendor] = cvdev->cpu_dev;early_cpu_detect (); +if (cpu_has_tsc) +set_printk_time_clock (tsc_clock);validate_pat_support (&boot_cpu_data); }
arch/x86/kernel/cpu/common_64.c +12 -0
@@ -249,6 +249,15 @@ static void __cpuinit detect_nopl(struct } } +static unsigned long long tsc_clock (int cpu) +{ +unsigned long long t; + +rdtscll (t); + +return t; +} +static void __cpuinit early_identify_cpu (struct cpuinfo_x86 *c);void __init early_cpu_init (void )
@@ -261,6 +270,9 @@ void __init early_cpu_init(void) cpu_devs[cvdev->vendor] = cvdev->cpu_dev;early_cpu_support_print ();early_identify_cpu (&boot_cpu_data); + +if (cpu_has_tsc) +set_printk_time_clock (tsc_clock); }/* Do some early cpuid on the boot CPU to get some parameter that are
Re: [PATCH] x86: printk_time to use tsc before cpu_clock is ready
arch/x86/kernel/cpu/common.c __setup("clearcpuid=", setup_disablecpui · line 657
Quoted 8 lines · Yinghai Lu
arch/x86/kernel/cpu/common.c +8
-0+static unsigned long long tsc_clock (int cpu) +{ +unsigned long long t; + +rdtscll (t); + +return t; +}
hm, i'm not sure i like the whole direction - this reintroduces printk_clock in essence.
how about initializing cpu_clock() sooner, so that printk timestamps start ticking as soon as possible?
Ingo
Re: [PATCH] x86: printk_time to use tsc before cpu_clock is ready
Quoted 14 lines · Ingo Molnar
arch/x86/kernel/cpu/common.c __setup("clearcpuid=", setup_disablecpui · line 657
Quoted 8 lines · Yinghai Lu
arch/x86/kernel/cpu/common.c +8
-0+static unsigned long long tsc_clock (int cpu) +{ +unsigned long long t; + +rdtscll (t); + +return t; +}hm, i'm not sure i like the whole direction - this reintroduces
printk_clockin essence.
Quoted 2 lines
how about initializing
cpu_clock()sooner, so that printk timestamps start ticking as soon as possible?
which will make some archs quite unhappy iirc, see those arm and ia64 bugs I caused the other day.
Re: [PATCH] x86: printk_time to use tsc before cpu_clock is ready
Quoted 15 lines · Peter Zijlstra
Quoted 14 lines · Ingo Molnar
arch/x86/kernel/cpu/common.c __setup("clearcpuid=", setup_disablecpui · line 657
Quoted 8 lines · Yinghai Lu
arch/x86/kernel/cpu/common.c +8
-0+static unsigned long long tsc_clock (int cpu) +{ +unsigned long long t; + +rdtscll (t); + +return t; +}hm, i'm not sure i like the whole direction - this reintroduces
printk_clockin essence.
Quoted 5 lines
Quoted 2 lines
how about initializing
cpu_clock()sooner, so that printk timestamps start ticking as soon as possible?which will make some archs quite unhappy iirc, see those arm and ia64 bugs I caused the other day.
that's OK - that still allows arches to start their clocks whenever they want to. But also add the possibility for architectures to initialize things even sooner.
Ingo