From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: Difference between vcpu_load and kvm_sched_in ? Date: Wed, 21 Oct 2015 08:46:23 +0200 Message-ID: <562734BF.2020806@redhat.com> References: <56266175.4030409@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit To: Wanpeng Li , Yacine , kvm@vger.kernel.org Return-path: Received: from mail-wi0-f172.google.com ([209.85.212.172]:36796 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753521AbbJUGq2 (ORCPT ); Wed, 21 Oct 2015 02:46:28 -0400 Received: by wicfx6 with SMTP id fx6so76354278wic.1 for ; Tue, 20 Oct 2015 23:46:26 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: 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