[patch] Re: [PATCH] fix #endif misplacement

From: Tim Schmielau
Date: Fri Nov 28 2003 - 12:30:49 EST


> On Fri, 28 Nov 2003, Ricardo Nabinger Sanchez wrote:
>
> > This patch fixes an #endif misplacement, which leads to dead code in
> > sched_clock() in arch/i386/kernel/timers/timer_tsc.c, due to a return
> > outside the ifdef/endif.
>
> No, this is exactly what is intended: don't use the TSC on NUMA, use
> jiffies instead.
> Look at the comment just above those lines.

HOWEVER, we seem to have some jiffies wrap bugs in this file.

Tim


--- linux-2.6.0-test11/arch/i386/kernel/timers/timer_tsc.c.orig 2003-11-28 17:50:49.000000000 +0100
+++ linux-2.6.0-test11/arch/i386/kernel/timers/timer_tsc.c 2003-11-28 18:18:44.000000000 +0100
@@ -30,7 +30,6 @@
int tsc_disable __initdata = 0;

extern spinlock_t i8253_lock;
-extern volatile unsigned long jiffies;

static int use_tsc;
/* Number of usecs that the last interrupt was delayed */
@@ -141,7 +140,7 @@
#ifndef CONFIG_NUMA
if (!use_tsc)
#endif
- return (unsigned long long)jiffies * (1000000000 / HZ);
+ return (unsigned long long)get_jiffies_64() * (1000000000 / HZ);

/* Read the Time Stamp Counter */
rdtscll(this_offset);
@@ -215,7 +214,8 @@
lost = delta/(1000000/HZ);
delay = delta%(1000000/HZ);
if (lost >= 2) {
- jiffies += lost-1;
+ /* only called under xtime_lock */
+ jiffies_64 += lost-1;

/* sanity check to ensure we're not always losing ticks */
if (lost_count++ > 100) {
@@ -241,7 +241,7 @@
* usec delta is > 90% # of usecs/tick)
*/
if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ))
- jiffies++;
+ jiffies_64++;
}

static void delay_tsc(unsigned long loops)
@@ -283,7 +283,8 @@
offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) {
int lost_ticks = (offset - hpet_last) / hpet_tick;
- jiffies += lost_ticks;
+ /* only called under xtime_lock */
+ jiffies_64 += lost_ticks;
}
hpet_last = hpet_current;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/