From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH 2/2] kvmtool: assume dead vcpus are paused too Date: Thu, 5 Nov 2015 11:02:04 -0500 Message-ID: <563B7D7C.2020200@oracle.com> References: <1445265650-25616-1-git-send-email-sasha.levin@oracle.com> <1445265650-25616-2-git-send-email-sasha.levin@oracle.com> <20151027160802.GD20208@arm.com> <56302E2C.2010207@oracle.com> <20151028122745.GC29512@arm.com> <5630C6D7.2020608@oracle.com> <20151028133425.GB18966@arm.com> <20151104115112.GE5405@arm.com> <563A99F0.10100@oracle.com> <20151105144116.GE26684@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: andre.przywara@arm.com, josh@joshtriplett.org, penberg@kernel.org, asias.hejun@gmail.com, kvm@vger.kernel.org To: Will Deacon Return-path: Received: from aserp1040.oracle.com ([141.146.126.69]:42075 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033337AbbKEQCg (ORCPT ); Thu, 5 Nov 2015 11:02:36 -0500 In-Reply-To: <20151105144116.GE26684@arm.com> Sender: kvm-owner@vger.kernel.org List-ID: On 11/05/2015 09:41 AM, Will Deacon wrote: > On Wed, Nov 04, 2015 at 06:51:12PM -0500, Sasha Levin wrote: >> > On 11/04/2015 06:51 AM, Will Deacon wrote: >>> > > + mutex_lock(&pause_lock); >>> > > + >>> > > + /* The kvm->cpus array contains a null pointer in the last location */ >>> > > + for (i = 0; ; i++) { >>> > > + if (kvm->cpus[i]) >>> > > + pthread_kill(kvm->cpus[i]->thread, SIGKVMEXIT); >>> > > + else >>> > > + break; >>> > > + } >>> > > + >>> > > + kvm__continue(kvm); >> > >> > In this scenario: if we grabbed pause_lock, signaled vcpu0 to exit, and it did >> > before we called kvm__continue(), we won't end up releasing pause_lock, which >> > might cause a lockup later, no? > Hmm, yeah, maybe that should be an explicit mutex_unlock rather than a > call to kvm__continue. Yeah, that should do the trick. Thanks, Sasha