Commit 8542637f authored by Andrew Morton's avatar Andrew Morton Committed by Jeff Garzik

[PATCH] make jiffies wrap 5 min after boot

From Tim Schmielau <tim@physik3.uni-rostock.de>

Force jiffies to start out at five-minutes-before-wrap.  To find
jiffy-wrapping bugs.
parent eaa535e7
......@@ -50,7 +50,7 @@
#include "proto.h"
#include "irq_impl.h"
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
extern unsigned long wall_jiffies; /* kernel/timer.c */
......
......@@ -32,7 +32,7 @@
#include <asm/irq.h>
#include <asm/leds.h>
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
extern unsigned long wall_jiffies;
......
......@@ -45,7 +45,7 @@
#include <asm/svinto.h>
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
static int have_rtc; /* used to remember if we have an RTC or not */
......
......@@ -66,7 +66,7 @@ int pit_latch_buggy; /* extern */
#include "do_timer.h"
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
unsigned long cpu_khz; /* Detected as we calibrate the TSC */
......
......@@ -27,7 +27,7 @@
extern unsigned long wall_jiffies;
extern unsigned long last_time_offset;
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
#ifdef CONFIG_IA64_DEBUG_IRQ
......
......@@ -26,7 +26,7 @@
#include <linux/timex.h>
#include <linux/profile.h>
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
static inline int set_rtc_mmss(unsigned long nowtime)
{
......
......@@ -26,7 +26,7 @@
#define TICK_SIZE (tick_nsec / 1000)
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
static inline int set_rtc_mmss(unsigned long nowtime)
{
......
......@@ -32,7 +32,7 @@
#define USECS_PER_JIFFY (1000000/HZ)
#define USECS_PER_JIFFY_FRAC ((1000000ULL << 32) / HZ & 0xffffffff)
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
/*
* forward reference
......
......@@ -32,7 +32,7 @@
#include <linux/timex.h>
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
/* xtime and wall_jiffies keep wall-clock time */
extern unsigned long wall_jiffies;
......
......@@ -68,7 +68,7 @@
#include <asm/time.h>
/* XXX false sharing with below? */
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
unsigned long disarm_decr[NR_CPUS];
......
......@@ -65,7 +65,7 @@
void smp_local_timer_interrupt(struct pt_regs *);
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
/* keep track of when we need to update the rtc */
time_t last_rtc_update;
......
......@@ -46,7 +46,7 @@
#define TICK_SIZE tick
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
static ext_int_info_t ext_int_info_timer;
static uint64_t xtime_cc;
......
......@@ -45,7 +45,7 @@
#define TICK_SIZE tick
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
static ext_int_info_t ext_int_info_timer;
static uint64_t xtime_cc;
......
......@@ -70,7 +70,7 @@
#endif /* CONFIG_CPU_SUBTYPE_ST40STB1 */
#endif /* __sh3__ or __SH4__ */
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
extern unsigned long wall_jiffies;
#define TICK_SIZE tick
......
......@@ -45,7 +45,7 @@
extern unsigned long wall_jiffies;
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
enum sparc_clock_type sp_clock_typ;
......
......@@ -47,7 +47,7 @@ unsigned long ds1287_regs = 0UL;
extern unsigned long wall_jiffies;
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
static unsigned long mstk48t08_regs = 0UL;
static unsigned long mstk48t59_regs = 0UL;
......
......@@ -25,7 +25,7 @@
#include "mach.h"
u64 jiffies_64;
u64 jiffies_64 = INITIAL_JIFFIES;
#define TICK_SIZE (tick_nsec / 1000)
......
......@@ -358,7 +358,8 @@ int proc_pid_stat(struct task_struct *task, char * buffer)
nice,
0UL /* removed */,
jiffies_to_clock_t(task->it_real_value),
(unsigned long long) jiffies_64_to_clock_t(task->start_time),
(unsigned long long)
jiffies_64_to_clock_t(task->start_time - INITIAL_JIFFIES),
vsize,
mm ? mm->rss : 0, /* you might want to shift this left 3 */
task->rlim[RLIMIT_RSS].rlim_cur,
......
......@@ -104,7 +104,7 @@ static int uptime_read_proc(char *page, char **start, off_t off,
unsigned long uptime_remainder;
int len;
uptime = get_jiffies_64();
uptime = get_jiffies_64() - INITIAL_JIFFIES;
uptime_remainder = (unsigned long) do_div(uptime, HZ);
#if HZ!=100
......@@ -320,7 +320,7 @@ static int kstat_read_proc(char *page, char **start, off_t off,
{
int i, len;
extern unsigned long total_forks;
u64 jif = get_jiffies_64();
u64 jif = get_jiffies_64() - INITIAL_JIFFIES;
unsigned int sum = 0, user = 0, nice = 0, system = 0, idle = 0, iowait = 0;
for (i = 0 ; i < NR_CPUS; i++) {
......
......@@ -27,6 +27,12 @@ struct timezone {
#include <linux/spinlock.h>
#include <linux/seqlock.h>
/*
* Have the 32 bit jiffies value wrap 5 minutes after boot
* so jiffies wrap bugs show up earlier.
*/
#define INITIAL_JIFFIES ((unsigned int) (-300*HZ))
/*
* Change timeval to jiffies, trying to avoid the
* most obvious overflows..
......
......@@ -757,7 +757,7 @@ static inline void calc_load(unsigned long ticks)
}
/* jiffies at the most recent update of wall time */
unsigned long wall_jiffies;
unsigned long wall_jiffies = INITIAL_JIFFIES;
/*
* This read-write spinlock protects us from races in SMP while
......@@ -1104,7 +1104,7 @@ asmlinkage long sys_sysinfo(struct sysinfo *info)
do {
seq = read_seqbegin(&xtime_lock);
uptime = jiffies_64;
uptime = jiffies_64 - INITIAL_JIFFIES;
do_div(uptime, HZ);
val.uptime = (unsigned long) uptime;
......@@ -1180,6 +1180,13 @@ static void __devinit init_timers_cpu(int cpu)
}
for (j = 0; j < TVR_SIZE; j++)
INIT_LIST_HEAD(base->tv1.vec + j);
base->timer_jiffies = INITIAL_JIFFIES;
base->tv1.index = INITIAL_JIFFIES & TVR_MASK;
base->tv2.index = (INITIAL_JIFFIES >> TVR_BITS) & TVN_MASK;
base->tv3.index = (INITIAL_JIFFIES >> (TVR_BITS+TVN_BITS)) & TVN_MASK;
base->tv4.index = (INITIAL_JIFFIES >> (TVR_BITS+2*TVN_BITS)) & TVN_MASK;
base->tv5.index = (INITIAL_JIFFIES >> (TVR_BITS+3*TVN_BITS)) & TVN_MASK;
}
static int __devinit timer_cpu_notify(struct notifier_block *self,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment