Re: [RFC PATCH V3 3/5] Utilize the vmx preemption timer

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

 




On 04/06/2016 02:42, Yunhong Jiang wrote:
> +static int vmx_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc)
> +{
> +	u64 tscl = rdtsc(), delta_tsc;
> +
> +	delta_tsc = guest_deadline_tsc - kvm_read_l1_tsc(vcpu, tscl);
> +
> +	/* Convert to host delta tsc if tsc scaling is enabled */
> +	if (vcpu->arch.tsc_scaling_ratio &&
> +			u64_shl_div_u64(delta_tsc,
> +				kvm_tsc_scaling_ratio_frac_bits,
> +				vcpu->arch.tsc_scaling_ratio,
> +				&delta_tsc))
> +		return -1;

Please return -EOVERFLOW or -ERANGE.  It's just aesthetic, but usually
in Linux functions do not return -1.

Thanks,

Paolo

> +	/*
> +	 * If the delta tsc can't be fit in the 32 bit after the multi shift,
> +	 * we can't use the preemption timer.
> +	 * It's possible that it can be fit when vmentry happens late, but
> +	 * checking on every vmentry is costly, so fail earilier.
> +	 */
> +	if (delta_tsc >> (cpu_preemption_timer_multi + 32))
> +		return -1;
> +
> +	vcpu->arch.hv_orig_tsc = tscl;
> +	vcpu->arch.hv_deadline_tsc = tscl + delta_tsc;
> +	vmcs_set_bits(PIN_BASED_VM_EXEC_CONTROL,
> +			PIN_BASED_VMX_PREEMPTION_TIMER);
> +	return 0;
> +}
--
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