From: Martin Peschke This patch makes printk_clock() a generic kernel-wide nsec-resolution timestamp_clock(). It's used both by printk() as well as the statistics infrastructure to provide unified time stamps to users. Signed-off-by: Martin Peschke Signed-off-by: Andrew Morton --- arch/ia64/kernel/setup.c | 4 ++-- arch/ia64/kernel/time.c | 15 ++++++++------- arch/ia64/sn/kernel/setup.c | 4 ++-- include/linux/time.h | 3 +++ kernel/printk.c | 7 +------ kernel/time.c | 5 +++++ 6 files changed, 21 insertions(+), 17 deletions(-) diff -puN arch/ia64/kernel/setup.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution arch/ia64/kernel/setup.c --- a/arch/ia64/kernel/setup.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution +++ a/arch/ia64/kernel/setup.c @@ -71,7 +71,7 @@ unsigned long __per_cpu_offset[NR_CPUS]; EXPORT_SYMBOL(__per_cpu_offset); #endif -extern void ia64_setup_printk_clock(void); +extern void ia64_setup_timestamp_clock(void); DEFINE_PER_CPU(struct cpuinfo_ia64, cpu_info); DEFINE_PER_CPU(unsigned long, local_per_cpu_offset); @@ -473,7 +473,7 @@ setup_arch (char **cmdline_p) /* process SAL system table: */ ia64_sal_init(__va(efi.sal_systab)); - ia64_setup_printk_clock(); + ia64_setup_timestamp_clock(); #ifdef CONFIG_SMP cpu_physical_id(0) = hard_smp_processor_id(); diff -puN arch/ia64/kernel/time.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution arch/ia64/kernel/time.c --- a/arch/ia64/kernel/time.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution +++ a/arch/ia64/kernel/time.c @@ -282,29 +282,30 @@ udelay (unsigned long usecs) } EXPORT_SYMBOL(udelay); -static unsigned long long ia64_itc_printk_clock(void) +static unsigned long long ia64_itc_timestamp_clock(void) { if (ia64_get_kr(IA64_KR_PER_CPU_DATA)) return sched_clock(); return 0; } -static unsigned long long ia64_default_printk_clock(void) +static unsigned long long ia64_default_timestamp_clock(void) { return (unsigned long long)(jiffies_64 - INITIAL_JIFFIES) * (1000000000/HZ); } -unsigned long long (*ia64_printk_clock)(void) = &ia64_default_printk_clock; +unsigned long long (*ia64_timestamp_clock)(void) = + &ia64_default_timestamp_clock; -unsigned long long printk_clock(void) +unsigned long long timestamp_clock(void) { - return ia64_printk_clock(); + return ia64_timestamp_clock(); } void __init -ia64_setup_printk_clock(void) +ia64_setup_timestamp_clock(void) { if (!(sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)) - ia64_printk_clock = ia64_itc_printk_clock; + ia64_timestamp_clock = ia64_itc_timestamp_clock; } diff -puN arch/ia64/sn/kernel/setup.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution arch/ia64/sn/kernel/setup.c --- a/arch/ia64/sn/kernel/setup.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution +++ a/arch/ia64/sn/kernel/setup.c @@ -362,7 +362,7 @@ sn_scan_pcdp(void) static unsigned long sn2_rtc_initial; -static unsigned long long ia64_sn2_printk_clock(void) +static unsigned long long ia64_sn2_timestamp_clock(void) { unsigned long rtc_now = rtc_time(); @@ -467,7 +467,7 @@ void __init sn_setup(char **cmdline_p) platform_intr_list[ACPI_INTERRUPT_CPEI] = IA64_CPE_VECTOR; - ia64_printk_clock = ia64_sn2_printk_clock; + ia64_timestamp_clock = ia64_sn2_timestamp_clock; printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF); diff -puN include/linux/time.h~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution include/linux/time.h --- a/include/linux/time.h~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution +++ a/include/linux/time.h @@ -174,6 +174,9 @@ static inline void timespec_add_ns(struc } a->tv_nsec = ns; } + +extern unsigned long long timestamp_clock(void); + #endif /* __KERNEL__ */ #define NFDBITS __NFDBITS diff -puN kernel/printk.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution kernel/printk.c --- a/kernel/printk.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution +++ a/kernel/printk.c @@ -462,11 +462,6 @@ static int __init printk_time_setup(char __setup("time", printk_time_setup); -__attribute__((weak)) unsigned long long printk_clock(void) -{ - return sched_clock(); -} - /* Check if we have any console registered that can be called early in boot. */ static int have_callable_console(void) { @@ -560,7 +555,7 @@ asmlinkage int vprintk(const char *fmt, if (printk_time) { char tbuf[TIMESTAMP_SIZE], *tp; printed_len += nsec_to_timestamp(tbuf, - printk_clock()); + timestamp_clock()); for (tp = tbuf; *tp; tp++) emit_log_char(*tp); emit_log_char(' '); diff -puN kernel/time.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution kernel/time.c --- a/kernel/time.c~statistics-infrastructure-make-printk_clock-a-generic-kernel-wide-nsec-resolution +++ a/kernel/time.c @@ -470,6 +470,11 @@ struct timeval ns_to_timeval(const s64 n return tv; } +__attribute__((weak)) unsigned long long timestamp_clock(void) +{ + return sched_clock(); +} + #if (BITS_PER_LONG < 64) u64 get_jiffies_64(void) { _