Skip to content

Commit

Permalink
[PATCH] Consolidate default sched_clock()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexey Dobriyan authored and Linus Torvalds committed Feb 11, 2007
1 parent 5e07e1c commit b035b6d
Show file tree
Hide file tree
Showing 17 changed files with 10 additions and 137 deletions.
11 changes: 0 additions & 11 deletions arch/alpha/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,6 @@ static inline __u32 rpcc(void)
return result;
}

/*
* Scheduler clock - returns current time in nanosec units.
*
* Copied from ARM code for expediency... ;-}
*/
unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}


/*
* timer_interrupt() needs to keep up the real-time clock,
* as well as call the "do_timer()" routine every clocktick
Expand Down
10 changes: 0 additions & 10 deletions arch/arm/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ static unsigned long dummy_gettimeoffset(void)
}
#endif

/*
* Scheduler clock - returns current time in nanosec units.
* This is the default implementation. Sub-architecture
* implementations can override this.
*/
unsigned long long __attribute__((weak)) sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

/*
* An implementation of printk_clock() independent from
* sched_clock(). This avoids non-bootable kernels when
Expand Down
8 changes: 0 additions & 8 deletions arch/arm26/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,6 @@ static unsigned long gettimeoffset(void)
return (offset + LATCH/2) / LATCH;
}

/*
* Scheduler clock - returns current time in nanosec units.
*/
unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

static unsigned long next_rtc_update;

/*
Expand Down
9 changes: 0 additions & 9 deletions arch/avr32/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@ static void avr32_hpt_init(unsigned int count)
sysreg_write(COUNT, count);
}

/*
* Scheduler clock - returns current time in nanosec units.
*/
unsigned long long sched_clock(void)
{
/* There must be better ways...? */
return (unsigned long long)jiffies * (1000000000 / HZ);
}

/*
* local_timer_interrupt() does profiling and process accounting on a
* per-CPU basis.
Expand Down
8 changes: 0 additions & 8 deletions arch/cris/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,6 @@ cris_do_profile(struct pt_regs* regs)
#endif
}

/*
* Scheduler clock - returns current time in nanosec units.
*/
unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

static int
__init init_udelay(void)
{
Expand Down
6 changes: 0 additions & 6 deletions arch/h8300/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,3 @@ int do_settimeofday(struct timespec *tv)
}

EXPORT_SYMBOL(do_settimeofday);

unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);

}
8 changes: 0 additions & 8 deletions arch/m32r/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,3 @@ void __init time_init(void)
#error no chip configuration
#endif
}

/*
* Scheduler clock - returns current time in nanosec units.
*/
unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}
9 changes: 0 additions & 9 deletions arch/m68k/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,3 @@ int do_settimeofday(struct timespec *tv)
}

EXPORT_SYMBOL(do_settimeofday);

/*
* Scheduler clock - returns current time in ns units.
*/
unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies*(1000000000/HZ);
}

9 changes: 0 additions & 9 deletions arch/m68knommu/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,4 @@ int do_settimeofday(struct timespec *tv)
clock_was_set();
return 0;
}

/*
* Scheduler clock - returns current time in nanosec units.
*/
unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

EXPORT_SYMBOL(do_settimeofday);
5 changes: 0 additions & 5 deletions arch/mips/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,3 @@ EXPORT_SYMBOL(rtc_lock);
EXPORT_SYMBOL(to_tm);
EXPORT_SYMBOL(rtc_mips_set_time);
EXPORT_SYMBOL(rtc_mips_get_time);

unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies*(1000000000/HZ);
}
11 changes: 0 additions & 11 deletions arch/parisc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,6 @@ do_settimeofday (struct timespec *tv)
}
EXPORT_SYMBOL(do_settimeofday);

/*
* XXX: We can do better than this.
* Returns nanoseconds
*/

unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}


void __init start_cpu_itimer(void)
{
unsigned int cpu = smp_processor_id();
Expand Down
8 changes: 0 additions & 8 deletions arch/sh/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ static int null_rtc_set_time(const time_t secs)
void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time;
int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time;

/*
* Scheduler clock - returns current time in nanosec units.
*/
unsigned long long __attribute__ ((weak)) sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

#ifndef CONFIG_GENERIC_TIME
void do_gettimeofday(struct timeval *tv)
{
Expand Down
9 changes: 0 additions & 9 deletions arch/sh64/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,3 @@ void enter_deep_standby(void)
asm __volatile__ ("nop");
panic("Unexpected wakeup!\n");
}

/*
* Scheduler clock - returns current time in nanosec units.
*/
unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

9 changes: 0 additions & 9 deletions arch/sparc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,6 @@ static inline unsigned long do_gettimeoffset(void)
return (*master_l10_counter >> 10) & 0x1fffff;
}

/*
* Returns nanoseconds
* XXX This is a suboptimal implementation.
*/
unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

/* Ok, my cute asm atomicity trick doesn't work anymore.
* There are just too many variables that need to be protected
* now (both members of xtime, et al.)
Expand Down
8 changes: 0 additions & 8 deletions arch/v850/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@

#define TICK_SIZE (tick_nsec / 1000)

/*
* Scheduler clock - returns current time in nanosec units.
*/
unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

/*
* timer_interrupt() needs to keep up the real-time clock,
* as well as call the "do_timer()" routine every clocktick
Expand Down
9 changes: 0 additions & 9 deletions arch/xtensa/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ unsigned long ccount_nsec; /* nsec per ccount increment */
unsigned int last_ccount_stamp;
static long last_rtc_update = 0;

/*
* Scheduler clock - returns current tim in nanosec units.
*/

unsigned long long sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

static irqreturn_t timer_interrupt(int irq, void *dev_id);
static struct irqaction timer_irqaction = {
.handler = timer_interrupt,
Expand Down
10 changes: 10 additions & 0 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@

#include <asm/unistd.h>

/*
* Scheduler clock - returns current time in nanosec units.
* This is default implementation.
* Architectures and sub-architectures can override this.
*/
unsigned long long __attribute__((weak)) sched_clock(void)
{
return (unsigned long long)jiffies * (1000000000 / HZ);
}

/*
* Convert user-nice values [ -20 ... 0 ... 19 ]
* to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
Expand Down

0 comments on commit b035b6d

Please sign in to comment.