Christian Weisgerber <na...@mips.inka.de> wrote:

> On 2020-06-26, George Koehler <kern...@gmail.com> wrote:
> 
> > Here's macppc again.  My macppc isn't using your newest diff but does
> > now need to define TC_TB in <machine/timetc.h>.
> 
> Crucial question: How confident are we that TB is in sync on
> multiprocessor machines?

A few small test programs exposed the problem on alpha for me.

This one identified the problem in a glaring fashion.  The upper
word of the register is per-cpu, and it toggles back and forth
upon each nanosleep call, as we return to a different cpu.  (Quite
obviously the scheduler has zero afinity)

A slightly different test program was able to identify occasions
when returning to the other cpu would return a clock value which was
earlier.  A variation of test_time_skew.c, I don't have it handy.

Maybe this can be quickly convered for macppc, to test?

I don't understand yet how to fix alpha.  It looks like we need a
mechanism to know what cpu# we are on, and a table for the variation.
(The upper word of the alpha clock register assists with profiling
it seems, so I don't think we can put a delta there)

#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>

main()
{
        struct timespec s = {0, 0};
        long times[40];
        volatile unsigned long t;
        int i;

        for (i = 0; i < sizeof times / sizeof times[0]; i++) {
                __asm volatile("rpcc %0" : "=r" (t));
                times[i] = t;
                nanosleep(&s, NULL);
        }
        for (i = 0; i < sizeof times / sizeof times[0]; i++) {
                t = times[i];
                printf("%lx %x\n", (t >> 32) & 0xffffffff, t & 0xffffffff);
        }
}


Reply via email to