On 21/10/2015 00:57, Wanpeng Li wrote:
>> kvm_sched_out and kvm_sched_in are part of KVM's preemption hooks.  The
>> hooks are registered only between vcpu_load and vcpu_put, therefore they
>> know that the mutex is taken.  The sequence will go like this:
>>
>>      vcpu_load
>>      kvm_sched_out
>>      kvm_sched_in
>>      kvm_sched_out
>>      kvm_sched_in
>>      ...
>>      vcpu_put
> 
> If this should be:
> 
> vcpu_load
> kvm_sched_in
> kvm_sched_out
> kvm_sched_in
> kvm_sched_out
> ...
> vcpu_put

No, because vcpu_load is called while the thread is running.  Therefore,
the first preempt notifier call will be a sched_out notification, which
calls kvm_arch_vcpu_put.  Extending the picture above:

      vcpu_load        -> kvm_arch_vcpu_load
      kvm_sched_out    -> kvm_arch_vcpu_put
      kvm_sched_in     -> kvm_arch_vcpu_load
      kvm_sched_out    -> kvm_arch_vcpu_put
      kvm_sched_in     -> kvm_arch_vcpu_load
      ...
      kvm_sched_out    -> kvm_arch_vcpu_put
      kvm_sched_in     -> kvm_arch_vcpu_load
      vcpu_put         -> kvm_arch_vcpu_put

Thanks,

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

Reply via email to