From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7HSQ-0007tF-Sf for qemu-devel@nongnu.org; Tue, 02 Oct 2018 05:59:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7HSL-00018r-QZ for qemu-devel@nongnu.org; Tue, 02 Oct 2018 05:59:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g7HSL-00018P-F2 for qemu-devel@nongnu.org; Tue, 02 Oct 2018 05:59:05 -0400 References: <87lg7hlend.fsf@linaro.org> <021f3f1e-e767-8d84-0189-fbfa7ca5f143@redhat.com> From: Paolo Bonzini Message-ID: <59e637ee-2a5a-6256-461a-7c8037e81558@redhat.com> Date: Tue, 2 Oct 2018 11:59:01 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] racing between pause_all_vcpus() and qemu_cpu_stop() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: =?UTF-8?Q?Alex_Benn=c3=a9e?= , QEMU Developers , Richard Henderson , "Emilio G. Cota" On 02/10/2018 11:04, Peter Maydell wrote: > On 2 October 2018 at 09:58, Paolo Bonzini wrote: >> >> First, the reset code should indeed use run_on_cpu (it need not be saf= e >> i.e. stop-the-world; just run it in the vCPU thread). It certainly >> doesn't do this right now. >=20 > I don't understand this part. We're resetting the entire world: > surely we need to stop the entire world first ? Most of the world is stopped because it only runs with BQL taken. vCPU isn't, so we ensure it is stopped by: 1) using run_on_cpu to synchronize with the executed TBs (or KVM_RUN) 2) ensuring the execution loop is paused after reset, which is the cpu_can_run part that you snipped. "Safe" CPU work items on the other hand ensure that _no_ vCPU is in the execution loop, which is overkill here. Paolo > (Also, other things use pause_all_vcpus() and hit this race > condition, like VM suspend and shutdown.) >=20 > thanks > -- PMM >=20