LKML Archive on
help / color / mirror / Atom feed
* sched_clock() on i386
@ 2006-12-22 10:43 Stephane Eranian
  2006-12-22 12:19 ` [patch] sched: improve sched_clock() on i686 Ingo Molnar
  2006-12-23 15:53 ` sched_clock() on i386 Daniel Walker
  0 siblings, 2 replies; 6+ messages in thread
From: Stephane Eranian @ 2006-12-22 10:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: venkatesh.pallipadi, suresh.b.siddha, kenneth.w.chen, tony.luck,
	Stephane Eranian


The perfmon subsystems needs to compute per-CPU duration. It is using
sched_clock() to provide this information. However, it seems they are
big variations in the way sched_clock() is implemented for each architectures,
especially in the accuracy of the returned value (going from TSC to jiffies).

Looking at the i386 implementation, it is not so clear to me what the
actual goal of the function is. I was under the impression that this
function was meant to compute per-CPU time deltas. This is how the
scheduler seems to use it. 

The x86-64 and i386 implementations are quite different. The i386 comment
about NUMA seems to contradict the initial goal of the function.
Why is that?

Does this come from the fact that sched_lock() is used for the time-stamping
printk(). But in this case, like on IA-64, couldn't we define a specific
timing function for printk?

Excerpt from arch/i386/kernel/tsc.c:

unsigned long long sched_clock(void)
        unsigned long long this_offset;

         * in the NUMA case we dont use the TSC as they are not
         * synchronized across all CPUs.
        if (!cpu_khz || check_tsc_unstable())
                /* no locking but a rare wrong value is not a big deal */
                return (jiffies_64 - INITIAL_JIFFIES) * (1000000000 / HZ);

        /* read the Time Stamp Counter: */

        /* return the value in ns */
        return cycles_2_ns(this_offset);


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-01-17 11:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-22 10:43 sched_clock() on i386 Stephane Eranian
2006-12-22 12:19 ` [patch] sched: improve sched_clock() on i686 Ingo Molnar
2006-12-23 10:27   ` Ingo Molnar
2007-01-17 11:05   ` Stephane Eranian
2006-12-23 15:53 ` sched_clock() on i386 Daniel Walker
2007-01-03 14:36   ` Stephane Eranian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).