This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems with gettimeofday_ns()


On Fri, 22 Feb 2008 22:44:19 +0530, Masami Hiramatsu <mhiramat@redhat.com> wrote:

> Julio M. Merino Vidal wrote:
>> Now I am finding another issue slightly related to this.  I have just
>> added a new marker to the code in an interrupt context, and this
>> interrupt wakes up a specific thread to handle it later on.  The
>> problem is that, if the interrupt is handled on one CPU and the
>> thread, once awaken, is handled by the other one, I can still get the
>> timestamps (cycles) reversed.  Any easy way around this?
>
> Unfortunately, there is no general workaround for this issue, because
> it strongly depends on the processor specification.
> For example, IPF could easily synchronize time because it has a
> system-wide clock source. However, most of i386 variant processors
> don't have this kind of clock source. Moreover, some of it may
> change clock frequency when it changes its cpu-frequency.
>
> If all of your processors have constant-freq clock and same
> frequency, there are constant gaps between each processor's clock.
> So, I think easy way is to estimate the gap from log by hand...

Here's a small module that we used internally to find the clock-skew
between the processors. Hope it is of use to you.

#include <linux/kernel.h>
#include <linux/module.h>
#include <asm/atomic.h>
#include <asm/timex.h>

long long int cpu_cycles[NR_CPUS];

static void worker_function(void)
{
         cpu_cycles[smp_processor_id()] = get_cycles();
}

void printer_function(void)
{
         int i;
         for (i=0; i<NR_CPUS; i++)
                 printk("cpu_cycles[%d] = %lld\n", i, cpu_cycles[i]);
}

static int __init probe_init(void)
{
         printk("Get cycles output Module inserted\n");

         preempt_disable();
         smp_call_function(worker_function, NULL, 0, 1);
         preempt_enable();
         return 0;
}

static void __exit probe_fini(void)
{

         printer_function();
         printk("Get cycles output Module Unloading\n");
}

module_init(probe_init);
module_exit(probe_fini);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]