Re: announce (experimental, i386 only): `nanokernel' #2 (PPSkit)

Ulrich Windl (ulrich.windl@rz.uni-regensburg.de)
Tue, 23 Feb 1999 10:16:22 +0100


On 23 Feb 99, at 2:37, Robert B. Hamilton wrote:

>
>
> > I only have one problem left: calibrate_tsc() is currently disabled,
> > because it will casue a divide overflow when trying to calibrate for
> > nanoseconds. Maybe I was to tired when I tried to fix it, but my
> > solution didn't work. Maybe someone can open my eyes...
>
> The suggestion below is almost self-explanatory. Since calibrate_tsc
> now returns 2^28 * (nS/TSC), and you want/need 2^32 * (nS/TSC) ......

The 2^28 was my attempt (after little thinking) to avoid the
overflow, but it still overflowed, so I disabled it. The problem with
the limited number of bits is that you either have high precision or
wide range, bot not both. I tried to find a compromise. I'm not
affected to 2^28 in any way.

>
> I don't have a PPS to test with (and built it without CONFIG_NTP_PPS), but
> I can check the phase fairly accurately against the cmos rtc and getting
> the same results as with normal kernel.
>
> I'm wondering if you can't dispense with the 2^28 normalization (vs 2^32)
> alltogether. What's the rationale for that?

Nothing escpecially clever... Hmmm... viewing your patch I wonder:

You haven't changed the calibrate_tsc routine. Does it mean it works
for you? So maybe my CPU (100MHz Pentium) is too slow. As indicated
in the comment I had thought it should do from 64 MHz on (thus
including a Pentium 75). I don't have the code here now, but have I
missed something obvious (like the direction of the shift)?

[...]

> One other little detail. In kernel/time.c, around line 311, PPS_FAVG is
> used even though it's only defined inside an #ifdef CONFIG_NTP_PPS
> conditional. I just defined it outside the #ifdef for this compile.

That's on my TO-LOOK-AT list already. Thanks any way.

>
> --Robert
>
>
> ========================================================================
> --- linux/arch/i386/kernel/time.c Tue Feb 23 01:05:13 1999
> +++ linux/arch/i386/kernel/time.c Tue Feb 23 02:02:50 1999
> @@ -160,7 +160,7 @@
> "0" (eax));
>
> /* our adjusted time offset in nanoseconds */
> - return nanodelay_at_last_interrupt + (edx >> 4);
> + return nanodelay_at_last_interrupt + (edx << 4);
> }
>
> #endif
> @@ -732,7 +732,7 @@
> dodgy_tsc();
>
> if (boot_cpu_data.x86_capability & X86_FEATURE_TSC) {
> -#if 1
> +#if 0
> printk("TSC calibration is broken, sorry (Fix it if you can)\n");
> #else
> use_tsc = 1;
> @@ -742,8 +742,12 @@
> do_get_exact_timeval = do_gettimeofday;
> do_get_exact_timespec = do_clock_gettime;
> exact_nanotime_quotient = calibrate_tsc();
> + /*
> + * exact_nanotime_quotient is 2^28 * number of ns/TSC
> + * normalize it to 2^32 * nS/TSC and convert to uS
> + */
> exact_microtime_quotient =
> - (exact_nanotime_quotient / 1000) >> 4;
> + (exact_nanotime_quotient / 1000) << 4;
> printk("quotients: micro=%ld, nano =%ld\n",
> exact_microtime_quotient, exact_nanotime_quotient);
>
>

-
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/