public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* Accessing host TSC from a guest kernel
@ 2010-09-24  2:49 Julien Desfossez
  2010-09-26 10:36 ` Avi Kivity
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Desfossez @ 2010-09-24  2:49 UTC (permalink / raw)
  To: kvm

Hello,

I'd like to access the host TSC from the inside of a guest kernel and I
don't really know if it's possible.

I'm working with kvm_clock and I have been playing with the
pvclock_vcpu_time_info structure, but I'm not sure if I'm in the right
direction.

So could you tell me if there is an efficient way to access to access
the host TSC (or at least the TSC_OFFSET) from a module inside a guest
kernel ?

I did it with an hypercall, but it's for tracing purpose and doing an
hypercall every time I want to record an event, is way too costly.

Thanks,

Julien

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

* Re: Accessing host TSC from a guest kernel
  2010-09-24  2:49 Accessing host TSC from a guest kernel Julien Desfossez
@ 2010-09-26 10:36 ` Avi Kivity
  2010-09-26 11:02   ` Muli Ben-Yehuda
  0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2010-09-26 10:36 UTC (permalink / raw)
  To: Julien Desfossez; +Cc: kvm

  On 09/24/2010 04:49 AM, Julien Desfossez wrote:
> Hello,
>
> I'd like to access the host TSC from the inside of a guest kernel and I
> don't really know if it's possible.
>
> I'm working with kvm_clock and I have been playing with the
> pvclock_vcpu_time_info structure, but I'm not sure if I'm in the right
> direction.
>
> So could you tell me if there is an efficient way to access to access
> the host TSC (or at least the TSC_OFFSET) from a module inside a guest
> kernel ?
>
> I did it with an hypercall, but it's for tracing purpose and doing an
> hypercall every time I want to record an event, is way too costly.
>
>

It isn't possible.  If you need a coherent host/guest timestamp, I 
suggest using ktime_get().

-- 
error compiling committee.c: too many arguments to function


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

* Re: Accessing host TSC from a guest kernel
  2010-09-26 10:36 ` Avi Kivity
@ 2010-09-26 11:02   ` Muli Ben-Yehuda
  0 siblings, 0 replies; 3+ messages in thread
From: Muli Ben-Yehuda @ 2010-09-26 11:02 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Julien Desfossez, kvm

On Sun, Sep 26, 2010 at 12:36:54PM +0200, Avi Kivity wrote:
>  On 09/24/2010 04:49 AM, Julien Desfossez wrote:
> >Hello,
> >
> >I'd like to access the host TSC from the inside of a guest kernel
> >and I don't really know if it's possible.
> >
> >I'm working with kvm_clock and I have been playing with the
> >pvclock_vcpu_time_info structure, but I'm not sure if I'm in the
> >right direction.
> >
> >So could you tell me if there is an efficient way to access to
> >access the host TSC (or at least the TSC_OFFSET) from a module
> >inside a guest kernel ?
> >
> >I did it with an hypercall, but it's for tracing purpose and doing
> >an hypercall every time I want to record an event, is way too
> >costly.
> 
> It isn't possible.  If you need a coherent host/guest timestamp, I
> suggest using ktime_get().

I think Avi meant that it isn't possible with stock KVM. If you hack
KVM to run the guest with 'RDTSC exiting' set to 0 and either disable
'use TSC offseting' or communicate the TSC offset to the guest out of
band, you should have efficient & consistent guest/host timestamps.

Cheers,
Muli

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

end of thread, other threads:[~2010-09-26 11:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-24  2:49 Accessing host TSC from a guest kernel Julien Desfossez
2010-09-26 10:36 ` Avi Kivity
2010-09-26 11:02   ` Muli Ben-Yehuda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox