Re: [PATCH] Use of TSC with SMP and different CPU's

From: Borislav Deianov (borislav@lix.polytechnique.fr)
Date: Thu Mar 09 2000 - 14:20:35 EST


In article <38C7D657.D6E2FA0A@home.com> you wrote:
> Perhaps a better solution would be to get tsc's of all cpu's at the
> interrupt.
> But how do I do that, i.e. how to to read tsc of another processor? I
> asked this question many times, but the only answer I got is that I
> don't wanna do it, and I really do.

-8<------------------------

struct cycles_struct {
        int cpu;
        cycles_t cycles;
};

void local_get_cycles(void *ptr)
{
        struct cycles_struct *data = (struct cycles_struct *)ptr;

        if (data->cpu == smp_processor_id())
                data->cycles = get_cycles();
}

static inline cycles_t smp_get_cycles(int cpu)
{
        struct cycles_struct data = { cpu };

        if (cpu == smp_processor_id())
                return get_cycles();

        smp_call_function(&local_get_cycles, &data, 0, 1);

        return data.cycles;
}

-8<------------------------

This takes about 21msec on my dual PIII-550. Note that
smp_call_function is supposed to be portable but currently only exists
on alpha, i386 and ia64.

One question (I haven't looked at your patch): can it deal gracefully
with suspending the machine, turning it off, then resuming? I don't
think that you can do that yet on SMP but I hope that you soon will
(ACPI or the software suspend patch).

Regards,
Borislav

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



This archive was generated by hypermail 2b29 : Wed Mar 15 2000 - 21:00:16 EST