Re: [RFC PATCH V2 4/4] Utilize the vmx preemption timer for tsc deadline timer

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

 



On 25/05/16 23:44, yunhong jiang wrote:
On Wed, 25 May 2016 13:52:56 +0200
Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:

Yes, this should save two VMCS access on the vcpu_run(). Will do this way.


The hardest part is converting guest_tsc to host_tsc.  From

	guest_tsc = (host_tsc * vcpu->arch.tsc_scaling_ratio >>
			kvm_tsc_scaling_ratio_frac_bits) + tsc_offset

you have

	host_tsc = ((unsigned __int128)(guest_tsc - tsc_offset)
			<< kvm_tsc_scaling_ratio_frac_bits)
			/ vcpu->arch.tsc_scaling_ratio;

... except that you need a division with a 128-bit dividend and a
64-bit divisor here, and there is no such thing in Linux.  It's okay
if you restrict this to 64-bit hosts and use the divq assembly
instruction directly.  (You also need to trap the divide overflow
exception; if there is an overflow just disable the preemption
timer).  On 32-bit systems, it's okay to force-disable
set_hv_timer/cancel_hv_timer, i.e. set them to NULL.

I'm scared by this conversion :) Sure will hav a try. Need firstly check
how the scale_tsc works.

aaaaaaaaaaaa

1. Against my interests: have you actually confirmed the VMX preemption timer is affected by guest TSC scaling?

It's not explicit in the SDM. The way it's described for allocating timeslices to the guest, IMO it makes more sense if it is not scaled.

2. Paolo, any chance I could also get away with requiring 64-bit?  I.e.

#ifdef CONFIG_X86_64
#define HAVE_LAPIC_TIMER_ADVANCE 1
#endif

Regards
Alan
--
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