From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Deacon Subject: Re: [PATCH 2/2] kvmtool: assume dead vcpus are paused too Date: Thu, 5 Nov 2015 14:41:16 +0000 Message-ID: <20151105144116.GE26684@arm.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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: andre.przywara@arm.com, josh@joshtriplett.org, penberg@kernel.org, asias.hejun@gmail.com, kvm@vger.kernel.org To: Sasha Levin Return-path: Received: from foss.arm.com ([217.140.101.70]:37391 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161656AbbKEOlQ (ORCPT ); Thu, 5 Nov 2015 09:41:16 -0500 Content-Disposition: inline In-Reply-To: <563A99F0.10100@oracle.com> Sender: kvm-owner@vger.kernel.org List-ID: 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. Will