diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/arch/i386/kernel/apic.c linux-2.6.0-test5-hrt/arch/i386/kernel/apic.c --- linux-2.6.0-test5-hrt.orig/arch/i386/kernel/apic.c 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/arch/i386/kernel/apic.c 2003-11-27 21:49:44.000000000 +0100 @@ -1051,7 +1051,7 @@ per_cpu(prof_counter, cpu); } - discipline_timer(cpu); + discipline_timer(cpu); //XXX this argument is very weird, the function expects a number of cycles elapsed! #ifdef CONFIG_SMP update_process_times(user_mode(regs)); diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/arch/i386/kernel/time.c linux-2.6.0-test5-hrt/arch/i386/kernel/time.c --- linux-2.6.0-test5-hrt.orig/arch/i386/kernel/time.c 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/arch/i386/kernel/time.c 2003-12-12 23:23:38.000000000 +0100 @@ -319,7 +319,7 @@ /* * If time is already passed, just return saying so. */ - if (sub_jiff_offset < 0) + if (sub_jiff_offset <= 0) return 1; __last_was_long = arch_cycles_per_jiffy == sub_jiffie_in; @@ -332,7 +332,7 @@ { start_PIT(); } -#endif /* CONFIG__APM */ +#endif /* CONFIG_APM */ #endif /* CONFIG_HIGH_RES_TIMERS */ diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/arch/i386/kernel/timers/hrtimer_pm.c linux-2.6.0-test5-hrt/arch/i386/kernel/timers/hrtimer_pm.c --- linux-2.6.0-test5-hrt.orig/arch/i386/kernel/timers/hrtimer_pm.c 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/arch/i386/kernel/timers/hrtimer_pm.c 2003-12-12 19:41:07.000000000 +0100 @@ -189,7 +189,6 @@ #ifndef CONFIG_SMP cpu_khz = cpufreq_scale(cpu_khz_ref, ref_freq, freq->new); - } #endif } diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/arch/i386/kernel/timers/hrtimer_tsc.c linux-2.6.0-test5-hrt/arch/i386/kernel/timers/hrtimer_tsc.c --- linux-2.6.0-test5-hrt.orig/arch/i386/kernel/timers/hrtimer_tsc.c 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/arch/i386/kernel/timers/hrtimer_tsc.c 2003-12-12 22:20:08.000000000 +0100 @@ -16,7 +16,7 @@ extern int x86_udelay_tsc; extern spinlock_t i8253_lock; - +static int use_tsc; /* Cached *multiplier* to convert TSC counts to microseconds. * (see the equation below). @@ -163,6 +163,7 @@ #ifndef CONFIG_SMP cpu_khz_ref = cpu_khz; #endif + } if((val == CPUFREQ_PRECHANGE && (freq->old < freq->new)) || (val == CPUFREQ_POSTCHANGE && (freq->old > freq->new))){ @@ -195,7 +196,6 @@ ref_freq, freq->new); #endif } - } return 0; } diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/include/asm-i386/hrtime.h linux-2.6.0-test5-hrt/include/asm-i386/hrtime.h --- linux-2.6.0-test5-hrt.orig/include/asm-i386/hrtime.h 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/include/asm-i386/hrtime.h 2003-12-12 23:25:26.000000000 +0100 @@ -32,7 +32,7 @@ #include #include /* scaling math routines */ #include -#include +#include #include /* for LATCH */ #include /* @@ -177,10 +177,6 @@ extern int _schedule_next_int(unsigned long jiffie_f, long sub_jiffie_in); extern int _schedule_jiffies_int(unsigned long jiffie_f); -extern unsigned int volatile latch_reload; - -EXTERN int jiffies_intr; - /* * Now go ahead and include the clock specific file 586/386/acpi @@ -352,7 +348,7 @@ spin_unlock(&i8253_lock); return; } -#endif // ! CONFIG_X86_LOCAL_APIC +#endif // ! USE_APIC_TIMERS /* * Time out for a discussion. Because the PIT and TSC (or the PIT and * pm timer) may drift WRT each other, we need a way to get the jiffie diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/include/asm-i386/hrtime-M586.h linux-2.6.0-test5-hrt/include/asm-i386/hrtime-M586.h --- linux-2.6.0-test5-hrt.orig/include/asm-i386/hrtime-M586.h 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/include/asm-i386/hrtime-M586.h 2003-11-09 11:28:19.000000000 +0100 @@ -38,6 +38,8 @@ }; #endif +extern struct timer_opts hrtimer_tsc; + extern inline unsigned long quick_get_cpuctr(void) { diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/include/asm-i386/hrtime-Macpi.h linux-2.6.0-test5-hrt/include/asm-i386/hrtime-Macpi.h --- linux-2.6.0-test5-hrt.orig/include/asm-i386/hrtime-Macpi.h 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/include/asm-i386/hrtime-Macpi.h 2003-12-08 22:01:19.000000000 +0100 @@ -38,6 +38,7 @@ #define SIZE_MASK 0xffffff extern int acpi_pm_tmr_address; +extern struct timer_opts hrtimer_pm; extern inline unsigned long quick_get_cpuctr(void) diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/include/asm-i386/mach-visws/do_timer.h linux-2.6.0-test5-hrt/include/asm-i386/mach-visws/do_timer.h --- linux-2.6.0-test5-hrt.orig/include/asm-i386/mach-visws/do_timer.h 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/include/asm-i386/mach-visws/do_timer.h 2003-11-09 11:28:18.000000000 +0100 @@ -8,7 +8,7 @@ /* Clear the interrupt */ co_cpu_write(CO_CPU_STAT,co_cpu_read(CO_CPU_STAT) & ~CO_STAT_TIMEINTR); -ifdef CONFIG_HIGH_RES_TIMERS +#ifdef CONFIG_HIGH_RES_TIMERS { long arch_cycles = get_arch_cycles(jiffies); diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/include/linux/posix-timers.h linux-2.6.0-test5-hrt/include/linux/posix-timers.h --- linux-2.6.0-test5-hrt.orig/include/linux/posix-timers.h 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/include/linux/posix-timers.h 2003-12-02 22:27:47.000000000 +0100 @@ -15,6 +15,49 @@ void (*timer_get) (struct k_itimer * timr, struct itimerspec * cur_setting); }; + +#ifdef CONFIG_HIGH_RES_TIMERS +struct now_struct { + unsigned long jiffies; + long sub_jiffie; +}; + +/* + * The following locking assumes that irq off. + */ +static inline void +posix_get_now(struct now_struct *now) +{ + unsigned long seq; + + (now)->jiffies = jiffies; + do { + seq = read_seqbegin(&xtime_lock); + (now)->sub_jiffie = get_arch_cycles((now)->jiffies); + } while (read_seqretry(&xtime_lock, seq)); + + while (unlikely(((now)->sub_jiffie - arch_cycles_per_jiffy) > 0)) { + (now)->sub_jiffie = (now)->sub_jiffie - arch_cycles_per_jiffy; + (now)->jiffies++; + } +} + +#define posix_time_before(timer, now) \ + ( {long diff = (long)(timer)->expires - (long)(now)->jiffies; \ + (diff < 0) || \ + ((diff == 0) && ((timer)->sub_expires < (now)->sub_jiffie)); }) + +#define posix_bump_timer(timr) do { \ + (timr)->it_timer.expires += (timr)->it_incr; \ + (timr)->it_timer.sub_expires += (timr)->it_sub_incr; \ + if (((timr)->it_timer.sub_expires - arch_cycles_per_jiffy) >= 0){ \ + (timr)->it_timer.sub_expires -= arch_cycles_per_jiffy; \ + (timr)->it_timer.expires++; \ + } \ + (timr)->it_overrun++; \ + }while (0) + +#else struct now_struct { unsigned long jiffies; }; @@ -27,4 +70,5 @@ (timr)->it_timer.expires += (timr)->it_incr; \ (timr)->it_overrun++; \ }while (0) +#endif /* CONFIG_HIGH_RES_TIMERS */ #endif diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/include/linux/sc_math.h linux-2.6.0-test5-hrt/include/linux/sc_math.h --- linux-2.6.0-test5-hrt.orig/include/linux/sc_math.h 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/include/linux/sc_math.h 2003-12-13 00:02:10.000000000 +0100 @@ -251,7 +251,7 @@ */ static inline long mpy_sc32(long a, long b) { - return (mpy1 * mpy2) >> 32); + return ((a * b) >> 32); } /* * X = (a/b)<<32 or more precisely x = (a<<32)/b @@ -287,7 +287,7 @@ /* x = (aa * bb) >> N */ -#define mpy_sc_n(N,aa,bb) ((aa) * (bb)) >> N) +#define mpy_sc_n(N,aa,bb) (((aa) * (bb)) >> N) /* x = (aa << N / bb) */ #define div_sc_n(N,aa,bb) (SC_n((N), (aa)) / (bb)) diff -urN -X /home/eric/dontdiff -x '*.dg' linux-2.6.0-test5-hrt.orig/kernel/timer.c linux-2.6.0-test5-hrt/kernel/timer.c --- linux-2.6.0-test5-hrt.orig/kernel/timer.c 2003-10-16 18:01:10.000000000 +0200 +++ linux-2.6.0-test5-hrt/kernel/timer.c 2003-12-12 23:16:25.000000000 +0100 @@ -98,7 +98,7 @@ * must be cli-ed when calling this */ unsigned long expires = timer->expires; - IF_HIGH_RES(int sub_expires = timer->sub_expires;) + IF_HIGH_RES(long sub_expires = timer->sub_expires;) int indx; struct list_head *pos,*list_start; @@ -119,7 +119,7 @@ } indx = expires & NEW_TVEC_MASK; - if ((expires - base->timer_jiffies) <= NEW_TVEC_SIZE) { + if ((expires - base->timer_jiffies) < NEW_TVEC_SIZE) { #ifdef CONFIG_HIGH_RES_TIMERS unsigned long jiffies_f; /* @@ -155,7 +155,8 @@ if ( expires == (jiffies_f = base->timer_jiffies) && list_start->next == &timer->entry && (base->running_timer == NULL)) { - schedule_hr_timer_int(jiffies_f, sub_expires); + if (schedule_hr_timer_int(jiffies_f, sub_expires)) + run_local_timers(); } #else pos = (&base->tv[indx])->next; @@ -433,8 +434,7 @@ #else while ((long)(jiffies - base->timer_jiffies) >= 0) { #endif - - struct list_head *head, *curr; + struct list_head *head; head = base->tv + (base->timer_jiffies & NEW_TVEC_MASK); /* * Note that we never move "head" but continue to @@ -443,13 +443,12 @@ * function call below. */ repeat: - curr = head->next; - if (curr != head) { + if (!list_empty(head)) { void (*fn)(unsigned long); unsigned long data; struct timer_list *timer; - timer = list_entry(curr, struct timer_list, entry); + timer = list_entry(head->next, struct timer_list, entry); #ifdef CONFIG_HIGH_RES_TIMERS /* * This would be simpler if we never got behind @@ -472,7 +471,7 @@ list_del(&timer->entry); timer->base = NULL; timer->entry.next = timer->entry.prev = NULL; - base->running_timer = timer; + set_running_timer(base, timer); spin_unlock_irq(&base->lock); fn(data); spin_lock_irq(&base->lock); @@ -483,7 +482,7 @@ /* * The new timer list is not always emptied * here as it contains: - * a.) entries (list size)^N*jiffies out and + * a.) entries (list size)*N jiffies out and * b.) entries that match in jiffies, but have * sub_expire times further out than now. */ @@ -513,16 +512,15 @@ * This allows zero time inserts as well as sub_jiffie values in * the current jiffie. */ - --base->timer_jiffies; #ifdef CONFIG_HIGH_RES_TIMERS - if (!sub_jiff && schedule_jiffies_int(jiffies_f)) { + --base->timer_jiffies; //XXX needed when not HRT? + if ((sub_jiff == -1) && schedule_jiffies_int(jiffies_f)) { spin_unlock_irq(&base->lock); spin_lock_irq(&base->lock); goto run_timer_list_again; } #endif - base->running_timer = NULL; - + set_running_timer(base, NULL); spin_unlock_irq(&base->lock); }