a question about "pvclock_get_nsec_offset()"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a question about the function of pvclock_get_nsec_offset(). 

static u64 pvclock_get_nsec_offset(struct pvclock_shadow_time *shadow)
{
	u64 delta = native_read_tsc() - shadow->tsc_timestamp;
	return pvclock_scale_delta(delta, shadow->tsc_to_nsec_mul,
				   shadow->tsc_shift);
}

Basically I understand the purpose of this function, that is, to compute a nsec delta based on the difference between the "now" timestamp and the last_update timestamp visible by the guest OS. But what I am confused of is, why do we use the "native_read_tsc" function to obtain the timestamp for the host OS since host boot. In my intuition, we may need to use "guest_read_tsc()" to obtain the timestamp for the guest OS, which takes tsc_offset into account. My equation is:

shadow->tsc_timestamp = TSC of last update + tsc_offset
the return value of guest_read_tsc() = TSC of now + tsc_offset
then, delta = guest_read_tsc() - shadow->tsc_timestamp = TSC of now - TSC of last update

I think it is highly possible that I miss somethings important or have some misunderstandings. Would you please point out my mistakes? 

Thanks,

Lei


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux