LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Can Linux kernel handle unsynced TSC?
@ 2008-02-29  8:55 Zhao Forrest
  2008-02-29 10:43 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Zhao Forrest @ 2008-02-29  8:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: kvm-devel

Sorry for reposting it.

For example,
1 rdtsc() is invoked on CPU0
2 process is migrated to CPU1, and rdtsc() is invoked on CPU1
3 if TSC on CPU1 is slower than TSC on CPU0, can kernel guarantee
that the second rdtsc() doesn't return a value smaller than the one
returned by the first rdtsc()?

Thanks,
Forrest

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

* Re: Can Linux kernel handle unsynced TSC?
  2008-02-29  8:55 Can Linux kernel handle unsynced TSC? Zhao Forrest
@ 2008-02-29 10:43 ` Peter Zijlstra
  2008-02-29 14:20   ` Zhao Forrest
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2008-02-29 10:43 UTC (permalink / raw)
  To: Zhao Forrest; +Cc: linux-kernel, kvm-devel


On Fri, 2008-02-29 at 16:55 +0800, Zhao Forrest wrote:
> Sorry for reposting it.
> 
> For example,
> 1 rdtsc() is invoked on CPU0
> 2 process is migrated to CPU1, and rdtsc() is invoked on CPU1
> 3 if TSC on CPU1 is slower than TSC on CPU0, can kernel guarantee
> that the second rdtsc() doesn't return a value smaller than the one
> returned by the first rdtsc()?

No, rdtsc() goes directly to the hardware. You need a (preferably cheap)
clock abstraction layer on top if you need this.


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

* Re: Can Linux kernel handle unsynced TSC?
  2008-02-29 10:43 ` Peter Zijlstra
@ 2008-02-29 14:20   ` Zhao Forrest
  2008-02-29 14:27     ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Zhao Forrest @ 2008-02-29 14:20 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel, kvm-devel

On 2/29/08, Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Fri, 2008-02-29 at 16:55 +0800, Zhao Forrest wrote:
> > Sorry for reposting it.
> >
> > For example,
> > 1 rdtsc() is invoked on CPU0
> > 2 process is migrated to CPU1, and rdtsc() is invoked on CPU1
> > 3 if TSC on CPU1 is slower than TSC on CPU0, can kernel guarantee
> > that the second rdtsc() doesn't return a value smaller than the one
> > returned by the first rdtsc()?
>
> No, rdtsc() goes directly to the hardware. You need a (preferably cheap)
> clock abstraction layer on top if you need this.

Thank you for the clarification. I think gettimeofday() is such kind
of clock abstraction layer, am I right?

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

* Re: Can Linux kernel handle unsynced TSC?
  2008-02-29 14:20   ` Zhao Forrest
@ 2008-02-29 14:27     ` Peter Zijlstra
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2008-02-29 14:27 UTC (permalink / raw)
  To: Zhao Forrest; +Cc: linux-kernel, kvm-devel


On Fri, 2008-02-29 at 22:20 +0800, Zhao Forrest wrote:
> On 2/29/08, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Fri, 2008-02-29 at 16:55 +0800, Zhao Forrest wrote:
> > > Sorry for reposting it.
> > >
> > > For example,
> > > 1 rdtsc() is invoked on CPU0
> > > 2 process is migrated to CPU1, and rdtsc() is invoked on CPU1
> > > 3 if TSC on CPU1 is slower than TSC on CPU0, can kernel guarantee
> > > that the second rdtsc() doesn't return a value smaller than the one
> > > returned by the first rdtsc()?
> >
> > No, rdtsc() goes directly to the hardware. You need a (preferably cheap)
> > clock abstraction layer on top if you need this.
> 
> Thank you for the clarification. I think gettimeofday() is such kind
> of clock abstraction layer, am I right?

Yes, gtod is one such a layer, however it fails the 'cheap' test for
many definitions of cheap.


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

end of thread, other threads:[~2008-02-29 14:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-29  8:55 Can Linux kernel handle unsynced TSC? Zhao Forrest
2008-02-29 10:43 ` Peter Zijlstra
2008-02-29 14:20   ` Zhao Forrest
2008-02-29 14:27     ` Peter Zijlstra

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).