From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Date: Sun, 23 Nov 2014 00:41:36 +0000 Subject: Re: [PATCH 5/5] KVM: PPC: Book3S HV: Check wait conditions before sleeping in kvmppc_vcore_blocked Message-Id: <54712D40.7060903@suse.de> List-Id: References: <1414990320-6378-1-git-send-email-paulus@samba.org> <1414990320-6378-6-git-send-email-paulus@samba.org> <546E26A8.1080904@suse.de> <546E418C.1080105@linux.vnet.ibm.com> In-Reply-To: <546E418C.1080105@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: "Suresh E. Warrier" , Paul Mackerras , kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org On 20.11.14 20:31, Suresh E. Warrier wrote: > > > On 11/20/2014 11:36 AM, Alexander Graf wrote: >> >> >> On 03.11.14 05:52, Paul Mackerras wrote: >>> From: "Suresh E. Warrier" >>> >>> The kvmppc_vcore_blocked() code does not check for the wait condition >>> after putting the process on the wait queue. This means that it is >>> possible for an external interrupt to become pending, but the vcpu to >>> remain asleep until the next decrementer interrupt. The fix is to >>> make one last check for pending exceptions and ceded state before >>> calling schedule(). >>> >>> Signed-off-by: Suresh Warrier >>> Signed-off-by: Paul Mackerras >> >> I don't understand the race you're fixing here. Can you please explain it? >> > > When a virtual interrupt needs to be delivered to the guest, and the > virtual ICS state for the interrupt and virtual ICP state for the VCPU > allow for the VCPU to be immediately interrupted, we > 1. Set the BOOK3S_INTERRUPT_EXTERNAL_LEVEL bit in pending_exceptions. > 2. Call kvmppc_fast_vcpu_kick_hv(), which checks the wait queue at vcpu->wq > to wake the VCPU up. > > The caller of kvmppc_vcore_blocked() does the check for pending exceptions, but > there is a race condition here and we do need to check again after the VCPU > is put on the wait queue. I see. Thanks, applied to kvm-ppc-queue. Alex From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Subject: Re: [PATCH 5/5] KVM: PPC: Book3S HV: Check wait conditions before sleeping in kvmppc_vcore_blocked Date: Sun, 23 Nov 2014 01:41:36 +0100 Message-ID: <54712D40.7060903@suse.de> References: <1414990320-6378-1-git-send-email-paulus@samba.org> <1414990320-6378-6-git-send-email-paulus@samba.org> <546E26A8.1080904@suse.de> <546E418C.1080105@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: "Suresh E. Warrier" , Paul Mackerras , kvm-ppc@vger.kernel.org Return-path: In-Reply-To: <546E418C.1080105@linux.vnet.ibm.com> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 20.11.14 20:31, Suresh E. Warrier wrote: > > > On 11/20/2014 11:36 AM, Alexander Graf wrote: >> >> >> On 03.11.14 05:52, Paul Mackerras wrote: >>> From: "Suresh E. Warrier" >>> >>> The kvmppc_vcore_blocked() code does not check for the wait condition >>> after putting the process on the wait queue. This means that it is >>> possible for an external interrupt to become pending, but the vcpu to >>> remain asleep until the next decrementer interrupt. The fix is to >>> make one last check for pending exceptions and ceded state before >>> calling schedule(). >>> >>> Signed-off-by: Suresh Warrier >>> Signed-off-by: Paul Mackerras >> >> I don't understand the race you're fixing here. Can you please explain it? >> > > When a virtual interrupt needs to be delivered to the guest, and the > virtual ICS state for the interrupt and virtual ICP state for the VCPU > allow for the VCPU to be immediately interrupted, we > 1. Set the BOOK3S_INTERRUPT_EXTERNAL_LEVEL bit in pending_exceptions. > 2. Call kvmppc_fast_vcpu_kick_hv(), which checks the wait queue at vcpu->wq > to wake the VCPU up. > > The caller of kvmppc_vcore_blocked() does the check for pending exceptions, but > there is a race condition here and we do need to check again after the VCPU > is put on the wait queue. I see. Thanks, applied to kvm-ppc-queue. Alex