Skip to content

Commit

Permalink
[PATCH] kill wall_jiffies
Browse files Browse the repository at this point in the history
With 2.6.18-rc4-mm2, now wall_jiffies will always be the same as jiffies.
So we can kill wall_jiffies completely.

This is just a cleanup and logically should not change any real behavior
except for one thing: RTC updating code in (old) ppc and xtensa use a
condition "jiffies - wall_jiffies == 1".  This condition is never met so I
suppose it is just a bug.  I just remove that condition only instead of
kill the whole "if" block.

[[email protected]: s390 build fix and cleanup]
Signed-off-by: Atsushi Nemoto <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Russell King <[email protected]>
Cc: Ian Molton <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: David Howells <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Kyle McMartin <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Kazumoto Kojima <[email protected]>
Cc: Richard Curnow <[email protected]>
Cc: William Lee Irwin III <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Paolo 'Blaisorblade' Giarrusso <[email protected]>
Cc: Miles Bader <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: "Luck, Tony" <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Roman Zippel <[email protected]>
Signed-off-by: Heiko Carstens <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
atsushi-nemoto authored and Linus Torvalds committed Oct 1, 2006
1 parent 70bc42f commit 8ef3860
Show file tree
Hide file tree
Showing 26 changed files with 35 additions and 190 deletions.
15 changes: 5 additions & 10 deletions arch/alpha/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
#include "proto.h"
#include "irq_impl.h"

extern unsigned long wall_jiffies; /* kernel/timer.c */

static int set_rtc_mmss(unsigned long);

DEFINE_SPINLOCK(rtc_lock);
Expand Down Expand Up @@ -413,7 +411,7 @@ void
do_gettimeofday(struct timeval *tv)
{
unsigned long flags;
unsigned long sec, usec, lost, seq;
unsigned long sec, usec, seq;
unsigned long delta_cycles, delta_usec, partial_tick;

do {
Expand All @@ -423,14 +421,13 @@ do_gettimeofday(struct timeval *tv)
sec = xtime.tv_sec;
usec = (xtime.tv_nsec / 1000);
partial_tick = state.partial_tick;
lost = jiffies - wall_jiffies;

} while (read_seqretry_irqrestore(&xtime_lock, seq, flags));

#ifdef CONFIG_SMP
/* Until and unless we figure out how to get cpu cycle counters
in sync and keep them there, we can't use the rpcc tricks. */
delta_usec = lost * (1000000 / HZ);
delta_usec = 0;
#else
/*
* usec = cycles * ticks_per_cycle * 2**48 * 1e6 / (2**48 * ticks)
Expand All @@ -446,8 +443,7 @@ do_gettimeofday(struct timeval *tv)
*/

delta_usec = (delta_cycles * state.scaled_ticks_per_cycle
+ partial_tick
+ (lost << FIX_SHIFT)) * 15625;
+ partial_tick) * 15625;
delta_usec = ((delta_usec / ((1UL << (FIX_SHIFT-6-1)) * HZ)) + 1) / 2;
#endif

Expand Down Expand Up @@ -480,12 +476,11 @@ do_settimeofday(struct timespec *tv)
time. Without this, a full-tick error is possible. */

#ifdef CONFIG_SMP
delta_nsec = (jiffies - wall_jiffies) * (NSEC_PER_SEC / HZ);
delta_nsec = 0;
#else
delta_nsec = rpcc() - state.last_time;
delta_nsec = (delta_nsec * state.scaled_ticks_per_cycle
+ state.partial_tick
+ ((jiffies - wall_jiffies) << FIX_SHIFT)) * 15625;
+ state.partial_tick) * 15625;
delta_nsec = ((delta_nsec / ((1UL << (FIX_SHIFT-6-1)) * HZ)) + 1) / 2;
delta_nsec *= 1000;
#endif
Expand Down
10 changes: 1 addition & 9 deletions arch/arm/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
*/
struct sys_timer *system_timer;

extern unsigned long wall_jiffies;

/* this needs a better home */
DEFINE_SPINLOCK(rtc_lock);

Expand Down Expand Up @@ -237,16 +235,11 @@ void do_gettimeofday(struct timeval *tv)
{
unsigned long flags;
unsigned long seq;
unsigned long usec, sec, lost;
unsigned long usec, sec;

do {
seq = read_seqbegin_irqsave(&xtime_lock, flags);
usec = system_timer->offset();

lost = jiffies - wall_jiffies;
if (lost)
usec += lost * USECS_PER_JIFFY;

sec = xtime.tv_sec;
usec += xtime.tv_nsec / 1000;
} while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
Expand Down Expand Up @@ -279,7 +272,6 @@ int do_settimeofday(struct timespec *tv)
* done, and then undo it!
*/
nsec -= system_timer->offset() * NSEC_PER_USEC;
nsec -= (jiffies - wall_jiffies) * TICK_NSEC;

wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
Expand Down
12 changes: 2 additions & 10 deletions arch/arm26/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include <asm/irq.h>
#include <asm/ioc.h>

extern unsigned long wall_jiffies;

/* this needs a better home */
DEFINE_SPINLOCK(rtc_lock);

Expand Down Expand Up @@ -136,16 +134,11 @@ void do_gettimeofday(struct timeval *tv)
{
unsigned long flags;
unsigned long seq;
unsigned long usec, sec, lost;
unsigned long usec, sec;

do {
seq = read_seqbegin_irqsave(&xtime_lock, flags);
usec = gettimeoffset();

lost = jiffies - wall_jiffies;
if (lost)
usec += lost * USECS_PER_JIFFY;

sec = xtime.tv_sec;
usec += xtime.tv_nsec / 1000;
} while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
Expand Down Expand Up @@ -174,8 +167,7 @@ int do_settimeofday(struct timespec *tv)
* wall time. Discover what correction gettimeofday() would have
* done, and then undo it!
*/
tv->tv_nsec -= 1000 * (gettimeoffset() +
(jiffies - wall_jiffies) * USECS_PER_JIFFY);
tv->tv_nsec -= 1000 * gettimeoffset();

while (tv->tv_nsec < 0) {
tv->tv_nsec += NSEC_PER_SEC;
Expand Down
7 changes: 0 additions & 7 deletions arch/cris/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ int have_rtc; /* used to remember if we have an RTC or not */;

#define TICK_SIZE tick

extern unsigned long wall_jiffies;
extern unsigned long loops_per_jiffy; /* init/main.c */
unsigned long loops_per_usec;

Expand All @@ -58,11 +57,6 @@ void do_gettimeofday(struct timeval *tv)
local_irq_save(flags);
local_irq_disable();
usec = do_gettimeoffset();
{
unsigned long lost = jiffies - wall_jiffies;
if (lost)
usec += lost * (1000000 / HZ);
}

/*
* If time_adjust is negative then NTP is slowing the clock
Expand Down Expand Up @@ -103,7 +97,6 @@ int do_settimeofday(struct timespec *tv)
* made, and then undo it!
*/
nsec -= do_gettimeoffset() * NSEC_PER_USEC;
nsec -= (jiffies - wall_jiffies) * TICK_NSEC;

wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
Expand Down
3 changes: 0 additions & 3 deletions arch/i386/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ int pit_latch_buggy; /* extern */
unsigned int cpu_khz; /* Detected as we calibrate the TSC */
EXPORT_SYMBOL(cpu_khz);

extern unsigned long wall_jiffies;

DEFINE_SPINLOCK(rtc_lock);
EXPORT_SYMBOL(rtc_lock);

Expand Down Expand Up @@ -329,7 +327,6 @@ static int timer_resume(struct sys_device *dev)
do_settimeofday(&ts);
write_seqlock_irqsave(&xtime_lock, flags);
jiffies_64 += sleep_length;
wall_jiffies += sleep_length;
write_sequnlock_irqrestore(&xtime_lock, flags);
touch_softlockup_watchdog();
return 0;
Expand Down
2 changes: 0 additions & 2 deletions arch/ia64/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#include <asm/sections.h>
#include <asm/system.h>

extern unsigned long wall_jiffies;

volatile int time_keeper_id = 0; /* smp_processor_id() of time-keeper */

#ifdef CONFIG_IA64_DEBUG_IRQ
Expand Down
11 changes: 1 addition & 10 deletions arch/m32r/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ extern void send_IPI_allbutself(int, int);
extern void smp_local_timer_interrupt(struct pt_regs *);
#endif

extern unsigned long wall_jiffies;
#define TICK_SIZE (tick_nsec / 1000)

/*
Expand Down Expand Up @@ -108,24 +107,17 @@ void do_gettimeofday(struct timeval *tv)
unsigned long max_ntp_tick = tick_usec - tickadj;

do {
unsigned long lost;

seq = read_seqbegin(&xtime_lock);

usec = do_gettimeoffset();
lost = jiffies - wall_jiffies;

/*
* If time_adjust is negative then NTP is slowing the clock
* so make sure not to go into next possible interval.
* Better to lose some accuracy than have time go backwards..
*/
if (unlikely(time_adjust < 0)) {
if (unlikely(time_adjust < 0))
usec = min(usec, max_ntp_tick);
if (lost)
usec += lost * max_ntp_tick;
} else if (unlikely(lost))
usec += lost * tick_usec;

sec = xtime.tv_sec;
usec += (xtime.tv_nsec / 1000);
Expand Down Expand Up @@ -158,7 +150,6 @@ int do_settimeofday(struct timespec *tv)
* made, and then undo it!
*/
nsec -= do_gettimeoffset() * NSEC_PER_USEC;
nsec -= (jiffies - wall_jiffies) * TICK_NSEC;

wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
Expand Down
16 changes: 3 additions & 13 deletions arch/m68k/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,23 @@ void time_init(void)
void do_gettimeofday(struct timeval *tv)
{
unsigned long flags;
extern unsigned long wall_jiffies;
unsigned long seq;
unsigned long usec, sec, lost;
unsigned long usec, sec;
unsigned long max_ntp_tick = tick_usec - tickadj;

do {
seq = read_seqbegin_irqsave(&xtime_lock, flags);

usec = mach_gettimeoffset();
lost = jiffies - wall_jiffies;

/*
* If time_adjust is negative then NTP is slowing the clock
* so make sure not to go into next possible interval.
* Better to lose some accuracy than have time go backwards..
*/
if (unlikely(time_adjust < 0)) {
if (unlikely(time_adjust < 0))
usec = min(usec, max_ntp_tick);

if (lost)
usec += lost * max_ntp_tick;
}
else if (unlikely(lost))
usec += lost * tick_usec;

sec = xtime.tv_sec;
usec += xtime.tv_nsec/1000;
} while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
Expand All @@ -141,7 +133,6 @@ int do_settimeofday(struct timespec *tv)
{
time_t wtm_sec, sec = tv->tv_sec;
long wtm_nsec, nsec = tv->tv_nsec;
extern unsigned long wall_jiffies;

if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
return -EINVAL;
Expand All @@ -153,8 +144,7 @@ int do_settimeofday(struct timespec *tv)
* Discover what correction gettimeofday
* would have done, and then undo it!
*/
nsec -= 1000 * (mach_gettimeoffset() +
(jiffies - wall_jiffies) * (1000000 / HZ));
nsec -= 1000 * mach_gettimeoffset();

wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
Expand Down
7 changes: 1 addition & 6 deletions arch/m68knommu/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

#define TICK_SIZE (tick_nsec / 1000)

extern unsigned long wall_jiffies;


static inline int set_rtc_mmss(unsigned long nowtime)
{
Expand Down Expand Up @@ -124,15 +122,12 @@ void time_init(void)
void do_gettimeofday(struct timeval *tv)
{
unsigned long flags;
unsigned long lost, seq;
unsigned long seq;
unsigned long usec, sec;

do {
seq = read_seqbegin_irqsave(&xtime_lock, flags);
usec = mach_gettimeoffset ? mach_gettimeoffset() : 0;
lost = jiffies - wall_jiffies;
if (lost)
usec += lost * (1000000 / HZ);
sec = xtime.tv_sec;
usec += (xtime.tv_nsec / 1000);
} while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
Expand Down
12 changes: 1 addition & 11 deletions arch/mips/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
/*
* forward reference
*/
extern volatile unsigned long wall_jiffies;

DEFINE_SPINLOCK(rtc_lock);

/*
Expand Down Expand Up @@ -159,7 +157,6 @@ void (*mips_hpt_init)(unsigned int);
void do_gettimeofday(struct timeval *tv)
{
unsigned long seq;
unsigned long lost;
unsigned long usec, sec;
unsigned long max_ntp_tick;

Expand All @@ -168,8 +165,6 @@ void do_gettimeofday(struct timeval *tv)

usec = do_gettimeoffset();

lost = jiffies - wall_jiffies;

/*
* If time_adjust is negative then NTP is slowing the clock
* so make sure not to go into next possible interval.
Expand All @@ -178,11 +173,7 @@ void do_gettimeofday(struct timeval *tv)
if (unlikely(time_adjust < 0)) {
max_ntp_tick = (USEC_PER_SEC / HZ) - tickadj;
usec = min(usec, max_ntp_tick);

if (lost)
usec += lost * max_ntp_tick;
} else if (unlikely(lost))
usec += lost * (USEC_PER_SEC / HZ);
}

sec = xtime.tv_sec;
usec += (xtime.tv_nsec / 1000);
Expand Down Expand Up @@ -217,7 +208,6 @@ int do_settimeofday(struct timespec *tv)
* made, and then undo it!
*/
nsec -= do_gettimeoffset() * NSEC_PER_USEC;
nsec -= (jiffies - wall_jiffies) * tick_nsec;

wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
Expand Down
2 changes: 0 additions & 2 deletions arch/mips/sgi-ip27/ip27-timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
static unsigned long ct_cur[NR_CPUS]; /* What counter should be at next timer irq */
static long last_rtc_update; /* Last time the rtc clock got updated */

extern volatile unsigned long wall_jiffies;

#if 0
static int set_rtc_mmss(unsigned long nowtime)
{
Expand Down
5 changes: 1 addition & 4 deletions arch/parisc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@

#include <linux/timex.h>

/* xtime and wall_jiffies keep wall-clock time */
extern unsigned long wall_jiffies;

static long clocktick __read_mostly; /* timer cycles per tick */
static long halftick __read_mostly;

Expand Down Expand Up @@ -112,7 +109,7 @@ EXPORT_SYMBOL(profile_pc);
/*** converted from ia64 ***/
/*
* Return the number of micro-seconds that elapsed since the last
* update to wall time (aka xtime aka wall_jiffies). The xtime_lock
* update to wall time (aka xtime). The xtime_lock
* must be at least read-locked when calling this routine.
*/
static inline unsigned long
Expand Down
Loading

0 comments on commit 8ef3860

Please sign in to comment.