Re: [PATCH RFC 1/2] KVM: don't check for PF_VCPU when yielding

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

 



Am 25.11.2014 um 17:04 schrieb David Hildenbrand:
> As some architectures (e.g. s390) can't disable preemption while
> entering/leaving the guest, they won't receive the yield in all situations.
> 
> kvm_enter_guest() has to be called with preemption_disabled and will set
> PF_VCPU. After that point e.g. s390 reenables preemption and starts to execute the
> guest. The thread might therefore be scheduled out between kvm_enter_guest() and
> kvm_exit_guest(), resulting in PF_VCPU being set but not being run.
> 
> Please note that preemption has to stay enabled in order to correctly process
> page faults on s390.
> 
> Current code takes PF_VCPU as a hint that the VCPU thread is running and
> therefore needs no yield. yield_to() checks whether the target thread is running,
> so let's use the inbuilt functionality to make it independent of PF_VCPU and
> preemption.

This change is a trade-off.
PRO: This patch would improve the case of preemption on s390. This is probably a corner case as most distros have preemption off anyway.
CON: The downside is that kvm_vcpu_yield_to is called also from kvm_vcpu_on_spin. Here we want to avoid the scheduler overhead for a wrong decision. 

So I think this patch is probably not what we want in most cases.

> 
> Signed-off-by: David Hildenbrand <dahi@xxxxxxxxxxxxxxxxxx>
> ---
>  virt/kvm/kvm_main.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 5b45330..184f52e 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1782,10 +1782,6 @@ int kvm_vcpu_yield_to(struct kvm_vcpu *target)
>  	rcu_read_unlock();
>  	if (!task)
>  		return ret;
> -	if (task->flags & PF_VCPU) {
> -		put_task_struct(task);
> -		return ret;
> -	}
>  	ret = yield_to(task, 1);
>  	put_task_struct(task);
> 

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