Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] Consolidate default sched_clock()

Use attribute(weak).

Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
b035b6de 5e07e1cc

+10 -137
-11
arch/alpha/kernel/time.c
··· 91 91 } 92 92 93 93 /* 94 - * Scheduler clock - returns current time in nanosec units. 95 - * 96 - * Copied from ARM code for expediency... ;-} 97 - */ 98 - unsigned long long sched_clock(void) 99 - { 100 - return (unsigned long long)jiffies * (1000000000 / HZ); 101 - } 102 - 103 - 104 - /* 105 94 * timer_interrupt() needs to keep up the real-time clock, 106 95 * as well as call the "do_timer()" routine every clocktick 107 96 */
-10
arch/arm/kernel/time.c
··· 78 78 #endif 79 79 80 80 /* 81 - * Scheduler clock - returns current time in nanosec units. 82 - * This is the default implementation. Sub-architecture 83 - * implementations can override this. 84 - */ 85 - unsigned long long __attribute__((weak)) sched_clock(void) 86 - { 87 - return (unsigned long long)jiffies * (1000000000 / HZ); 88 - } 89 - 90 - /* 91 81 * An implementation of printk_clock() independent from 92 82 * sched_clock(). This avoids non-bootable kernels when 93 83 * printk_clock is enabled.
-8
arch/arm26/kernel/time.c
··· 89 89 return (offset + LATCH/2) / LATCH; 90 90 } 91 91 92 - /* 93 - * Scheduler clock - returns current time in nanosec units. 94 - */ 95 - unsigned long long sched_clock(void) 96 - { 97 - return (unsigned long long)jiffies * (1000000000 / HZ); 98 - } 99 - 100 92 static unsigned long next_rtc_update; 101 93 102 94 /*
-9
arch/avr32/kernel/time.c
··· 110 110 } 111 111 112 112 /* 113 - * Scheduler clock - returns current time in nanosec units. 114 - */ 115 - unsigned long long sched_clock(void) 116 - { 117 - /* There must be better ways...? */ 118 - return (unsigned long long)jiffies * (1000000000 / HZ); 119 - } 120 - 121 - /* 122 113 * local_timer_interrupt() does profiling and process accounting on a 123 114 * per-CPU basis. 124 115 *
-8
arch/cris/kernel/time.c
··· 216 216 #endif 217 217 } 218 218 219 - /* 220 - * Scheduler clock - returns current time in nanosec units. 221 - */ 222 - unsigned long long sched_clock(void) 223 - { 224 - return (unsigned long long)jiffies * (1000000000 / HZ); 225 - } 226 - 227 219 static int 228 220 __init init_udelay(void) 229 221 {
-6
arch/h8300/kernel/time.c
··· 118 118 } 119 119 120 120 EXPORT_SYMBOL(do_settimeofday); 121 - 122 - unsigned long long sched_clock(void) 123 - { 124 - return (unsigned long long)jiffies * (1000000000 / HZ); 125 - 126 - }
-8
arch/m32r/kernel/time.c
··· 286 286 #error no chip configuration 287 287 #endif 288 288 } 289 - 290 - /* 291 - * Scheduler clock - returns current time in nanosec units. 292 - */ 293 - unsigned long long sched_clock(void) 294 - { 295 - return (unsigned long long)jiffies * (1000000000 / HZ); 296 - }
-9
arch/m68k/kernel/time.c
··· 159 159 } 160 160 161 161 EXPORT_SYMBOL(do_settimeofday); 162 - 163 - /* 164 - * Scheduler clock - returns current time in ns units. 165 - */ 166 - unsigned long long sched_clock(void) 167 - { 168 - return (unsigned long long)jiffies*(1000000000/HZ); 169 - } 170 -
-9
arch/m68knommu/kernel/time.c
··· 174 174 clock_was_set(); 175 175 return 0; 176 176 } 177 - 178 - /* 179 - * Scheduler clock - returns current time in nanosec units. 180 - */ 181 - unsigned long long sched_clock(void) 182 - { 183 - return (unsigned long long)jiffies * (1000000000 / HZ); 184 - } 185 - 186 177 EXPORT_SYMBOL(do_settimeofday);
-5
arch/mips/kernel/time.c
··· 455 455 EXPORT_SYMBOL(to_tm); 456 456 EXPORT_SYMBOL(rtc_mips_set_time); 457 457 EXPORT_SYMBOL(rtc_mips_get_time); 458 - 459 - unsigned long long sched_clock(void) 460 - { 461 - return (unsigned long long)jiffies*(1000000000/HZ); 462 - }
-11
arch/parisc/kernel/time.c
··· 288 288 } 289 289 EXPORT_SYMBOL(do_settimeofday); 290 290 291 - /* 292 - * XXX: We can do better than this. 293 - * Returns nanoseconds 294 - */ 295 - 296 - unsigned long long sched_clock(void) 297 - { 298 - return (unsigned long long)jiffies * (1000000000 / HZ); 299 - } 300 - 301 - 302 291 void __init start_cpu_itimer(void) 303 292 { 304 293 unsigned int cpu = smp_processor_id();
-8
arch/sh/kernel/time.c
··· 41 41 void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time; 42 42 int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time; 43 43 44 - /* 45 - * Scheduler clock - returns current time in nanosec units. 46 - */ 47 - unsigned long long __attribute__ ((weak)) sched_clock(void) 48 - { 49 - return (unsigned long long)jiffies * (1000000000 / HZ); 50 - } 51 - 52 44 #ifndef CONFIG_GENERIC_TIME 53 45 void do_gettimeofday(struct timeval *tv) 54 46 {
-9
arch/sh64/kernel/time.c
··· 579 579 asm __volatile__ ("nop"); 580 580 panic("Unexpected wakeup!\n"); 581 581 } 582 - 583 - /* 584 - * Scheduler clock - returns current time in nanosec units. 585 - */ 586 - unsigned long long sched_clock(void) 587 - { 588 - return (unsigned long long)jiffies * (1000000000 / HZ); 589 - } 590 -
-9
arch/sparc/kernel/time.c
··· 436 436 return (*master_l10_counter >> 10) & 0x1fffff; 437 437 } 438 438 439 - /* 440 - * Returns nanoseconds 441 - * XXX This is a suboptimal implementation. 442 - */ 443 - unsigned long long sched_clock(void) 444 - { 445 - return (unsigned long long)jiffies * (1000000000 / HZ); 446 - } 447 - 448 439 /* Ok, my cute asm atomicity trick doesn't work anymore. 449 440 * There are just too many variables that need to be protected 450 441 * now (both members of xtime, et al.)
-8
arch/v850/kernel/time.c
··· 28 28 #define TICK_SIZE (tick_nsec / 1000) 29 29 30 30 /* 31 - * Scheduler clock - returns current time in nanosec units. 32 - */ 33 - unsigned long long sched_clock(void) 34 - { 35 - return (unsigned long long)jiffies * (1000000000 / HZ); 36 - } 37 - 38 - /* 39 31 * timer_interrupt() needs to keep up the real-time clock, 40 32 * as well as call the "do_timer()" routine every clocktick 41 33 */
-9
arch/xtensa/kernel/time.c
··· 38 38 unsigned int last_ccount_stamp; 39 39 static long last_rtc_update = 0; 40 40 41 - /* 42 - * Scheduler clock - returns current tim in nanosec units. 43 - */ 44 - 45 - unsigned long long sched_clock(void) 46 - { 47 - return (unsigned long long)jiffies * (1000000000 / HZ); 48 - } 49 - 50 41 static irqreturn_t timer_interrupt(int irq, void *dev_id); 51 42 static struct irqaction timer_irqaction = { 52 43 .handler = timer_interrupt,
+10
kernel/sched.c
··· 57 57 #include <asm/unistd.h> 58 58 59 59 /* 60 + * Scheduler clock - returns current time in nanosec units. 61 + * This is default implementation. 62 + * Architectures and sub-architectures can override this. 63 + */ 64 + unsigned long long __attribute__((weak)) sched_clock(void) 65 + { 66 + return (unsigned long long)jiffies * (1000000000 / HZ); 67 + } 68 + 69 + /* 60 70 * Convert user-nice values [ -20 ... 0 ... 19 ] 61 71 * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ], 62 72 * and back.