Commit f2cf3160 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ia32 jiffy wrapping fixes

From: john stultz <johnstul@us.ibm.com>

Converts all uses of jiffies to jiffies_64 in x86 time sources to avoid
jiffies overflow problems.

(Contributions from Tim Schmielau <tim@physik3.uni-rostock.de>)
parent ea114bac
...@@ -71,7 +71,7 @@ static void mark_offset_cyclone(void) ...@@ -71,7 +71,7 @@ static void mark_offset_cyclone(void)
lost = delta/(1000000/HZ); lost = delta/(1000000/HZ);
delay = delta%(1000000/HZ); delay = delta%(1000000/HZ);
if (lost >= 2) if (lost >= 2)
jiffies += lost-1; jiffies_64 += lost-1;
/* update the monotonic base value */ /* update the monotonic base value */
this_offset = ((unsigned long long)last_cyclone_high<<32)|last_cyclone_low; this_offset = ((unsigned long long)last_cyclone_high<<32)|last_cyclone_low;
...@@ -88,7 +88,7 @@ static void mark_offset_cyclone(void) ...@@ -88,7 +88,7 @@ static void mark_offset_cyclone(void)
* usec delta is > 90% # of usecs/tick) * usec delta is > 90% # of usecs/tick)
*/ */
if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ)) if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ))
jiffies++; jiffies_64++;
} }
static unsigned long get_offset_cyclone(void) static unsigned long get_offset_cyclone(void)
......
...@@ -108,7 +108,7 @@ static void mark_offset_hpet(void) ...@@ -108,7 +108,7 @@ static void mark_offset_hpet(void)
offset = hpet_readl(HPET_T0_CMP) - hpet_tick; offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) { if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) {
int lost_ticks = (offset - hpet_last) / hpet_tick; int lost_ticks = (offset - hpet_last) / hpet_tick;
jiffies += lost_ticks; jiffies_64 += lost_ticks;
} }
hpet_last = offset; hpet_last = offset;
......
...@@ -30,7 +30,6 @@ struct timer_opts timer_tsc; ...@@ -30,7 +30,6 @@ struct timer_opts timer_tsc;
int tsc_disable __initdata = 0; int tsc_disable __initdata = 0;
extern spinlock_t i8253_lock; extern spinlock_t i8253_lock;
extern volatile unsigned long jiffies;
static int use_tsc; static int use_tsc;
/* Number of usecs that the last interrupt was delayed */ /* Number of usecs that the last interrupt was delayed */
...@@ -141,7 +140,7 @@ unsigned long long sched_clock(void) ...@@ -141,7 +140,7 @@ unsigned long long sched_clock(void)
#ifndef CONFIG_NUMA #ifndef CONFIG_NUMA
if (!use_tsc) if (!use_tsc)
#endif #endif
return (unsigned long long)jiffies * (1000000000 / HZ); return (unsigned long long)get_jiffies_64() * (1000000000 / HZ);
/* Read the Time Stamp Counter */ /* Read the Time Stamp Counter */
rdtscll(this_offset); rdtscll(this_offset);
...@@ -215,7 +214,7 @@ static void mark_offset_tsc(void) ...@@ -215,7 +214,7 @@ static void mark_offset_tsc(void)
lost = delta/(1000000/HZ); lost = delta/(1000000/HZ);
delay = delta%(1000000/HZ); delay = delta%(1000000/HZ);
if (lost >= 2) { if (lost >= 2) {
jiffies += lost-1; jiffies_64 += lost-1;
/* sanity check to ensure we're not always losing ticks */ /* sanity check to ensure we're not always losing ticks */
if (lost_count++ > 100) { if (lost_count++ > 100) {
...@@ -241,7 +240,7 @@ static void mark_offset_tsc(void) ...@@ -241,7 +240,7 @@ static void mark_offset_tsc(void)
* usec delta is > 90% # of usecs/tick) * usec delta is > 90% # of usecs/tick)
*/ */
if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ)) if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ))
jiffies++; jiffies_64++;
} }
static void delay_tsc(unsigned long loops) static void delay_tsc(unsigned long loops)
...@@ -283,7 +282,7 @@ static void mark_offset_tsc_hpet(void) ...@@ -283,7 +282,7 @@ static void mark_offset_tsc_hpet(void)
offset = hpet_readl(HPET_T0_CMP) - hpet_tick; offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) { if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) {
int lost_ticks = (offset - hpet_last) / hpet_tick; int lost_ticks = (offset - hpet_last) / hpet_tick;
jiffies += lost_ticks; jiffies_64 += lost_ticks;
} }
hpet_last = hpet_current; hpet_last = hpet_current;
......
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