> On Sat, 13 Mar 1999, Andrea Arcangeli wrote:
>
> >Infact people is starting to report that its machine clock is losing time.
> >I am fixing it right now. I think I have just finised coding but I'll do
>
> It's working now. I tested it with a cli(); mdelay(1000); sti(). While the
> system was losing 1 sec without the patch, it now recovers the losed time
> with the patch applyed.
[...]
> + register unsigned long delta_usec;
> +
> + __asm__("mull %2"
> + :"=a" (delta_cycles), "=d" (delta_usec)
> + :"g" (fast_gettimeoffset_quotient), "0" (delta_cycles));
> + delta_usec -= delay_usec;
> + delta_usec /= 1000000/HZ;
Your delta_usec is in fact a lost_ticks. The name is confusing when
you add microseconds to jiffies. (IMHO)
> +
> + if ((long) delta_usec > 1)
> + {
> + printk(KERN_DEBUG "lost ticks %lu\n", delta_usec - 1);
> +
> + delta_usec -= 1;
> + lost_ticks += delta_usec;
> + jiffies += delta_usec;
> + }
> +}
[...]
> -long tick = (1000000 + HZ/2) / HZ; /* timer interrupt period */
> +long tick = 1000000 / HZ; /* timer interrupt period */
This way the system time will be more behind than before if
"(1000000 % HZ) >= HZ/2". IMHO the line is correct. After all we are
not saying "(1000000 + HZ - 1) / HZ".
>
> /* The current time */
> volatile struct timeval xtime __attribute__ ((aligned (16)));
> @@ -72,7 +72,7 @@
> long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */
> long time_esterror = NTP_PHASE_LIMIT; /* estimated error (us) */
> long time_phase = 0; /* phase offset (scaled us) */
> -long time_freq = ((1000000 + HZ/2) % HZ - HZ/2) << SHIFT_USEC; /* frequency offset (scaled ppm) > +long time_freq = (1000000 % HZ) << SHIFT_USEC; /* frequency offset (scaled ppm) */
Simply removing variables that other people might need isnīt a very
good idea.
> long time_adj = 0; /* tick adjust (scaled 1 / HZ) */
> long time_reftime = 0; /* time at last adjustment (s) */
>
> @@ -1299,15 +1299,13 @@
> static void update_wall_time(unsigned long ticks)
> {
> do {
> - ticks--;
> update_wall_time_one_tick();
> - } while (ticks);
> -
> - if (xtime.tv_usec >= 1000000) {
> - xtime.tv_usec -= 1000000;
> - xtime.tv_sec++;
> - second_overflow();
> - }
> + while (xtime.tv_usec >= 1000000) {
> + xtime.tv_usec -= 1000000;
> + xtime.tv_sec++;
> + second_overflow();
> + }
> + } while (--ticks);
> }
>
> static inline void do_process_times(struct task_struct *p,
>
>
>
> Comments?
I could NOT confirm loosing time; I only saw some jitter.
[...]
Regards,
Ulrich
P.S. Not subscribed in/to linux-kernel...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/