From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Date: Thu, 03 Sep 2015 05:31:43 +0000 Subject: Re: [PATCH 1/2] KVM: PPC: Book3S HV: Fix race in starting secondary threads Message-Id: <20150903053143.GL6537@voom.redhat.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="S6vg04ofUPzW4qJg" List-Id: References: <20150903052050.GA4377@iris.ozlabs.ibm.com> In-Reply-To: <20150903052050.GA4377@iris.ozlabs.ibm.com> To: Paul Mackerras Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org --S6vg04ofUPzW4qJg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 03, 2015 at 03:20:50PM +1000, Paul Mackerras wrote: > From: "Gautham R. Shenoy" >=20 > The current dynamic micro-threading code has a race due to which a > secondary thread naps when it is supposed to be running a vcpu. As a > side effect of this, on a guest exit, the primary thread in > kvmppc_wait_for_nap() finds that this secondary thread hasn't cleared > its vcore pointer. This results in "CPU X seems to be stuck!" > warnings. >=20 > The race is possible since the primary thread on exiting the guests > only waits for all the secondaries to clear its vcore pointer. It > subsequently expects the secondary threads to enter nap while it > unsplits the core. A secondary thread which hasn't yet entered the nap > will loop in kvm_no_guest until its vcore pointer and the do_nap flag > are unset. Once the core has been unsplit, a new vcpu thread can grab > the core and set the do_nap flag *before* setting the vcore pointers > of the secondary. As a result, the secondary thread will now enter nap > via kvm_unsplit_nap instead of running the guest vcpu. >=20 > Fix this by setting the do_nap flag after setting the vcore pointer in > the PACA of the secondary in kvmppc_run_core. Also, ensure that a > secondary thread doesn't nap in kvm_unsplit_nap when the vcore pointer > in its PACA struct is set. >=20 > Fixes: b4deba5c41e9 > Signed-off-by: Gautham R. Shenoy > Signed-off-by: Paul Mackerras Reviewed-by: David Gibson --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --S6vg04ofUPzW4qJg Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJV59s/AAoJEGw4ysog2bOSdEQQAImRHmd7gBG83eSImjTq9ohe eXqVmKILurb0wzpopcSsPGxBAsOy3ABdj90qNq2Zc9wJXdmbUDqqGoCztNaU6A0t BpLL9PekH9hC1/nMRnrOVqtEGz/ZlLxRoRSTztV1BIw5+807DfJUpEl2p3cKMgyd nTblyxROHq5BlmAy060d26SCdxjVGm7VBOt3A/EJa0dd+rfuDT7PgNCCaMEF/oWN 3x49eLx/CX8i1k6PaF4zhPPfuYpB7GLf0lYTQVdZ3IF8CGWY5+WQp31/8qYXXu21 tqnE9dRIYbGkAeTtyRHlDBw9Kf+xUjU6wsxT1rqbXIVZx213l5+tdOO+hhvWT2Xw ZuED5y9b3JS+mEr7H0QySKnaBobZ2pgHfDHGUHuO8Cipwd8jwiMviYNDPbgGHcrr Et5xc5rQNSUrIF7arAjwoNRmT6fDEZo65Sa5ie9JfZVby/Uf1Gy44Wi2s9hs66KN BZHbTYMgG+wTMKqOCWvsrdyWH/pIzy0X5tG90MttIWwFj2oBOAQ6dfeCOkVWTdKD 37cQrXaPVYn5SYuCMSstiu4xQoDurFlGuXRsOj0GVt66tUVIbC4ntH06ZzTQ7sfy zd1RM+Vl2Y7iX/mvq4c3bXbsiDzK6GsuXlqRA62ocJYhakZVh5reZsINm5edm5Fe wdHU8M7eu8SL7RDgrLyQ =Vq1g -----END PGP SIGNATURE----- --S6vg04ofUPzW4qJg-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Subject: Re: [PATCH 1/2] KVM: PPC: Book3S HV: Fix race in starting secondary threads Date: Thu, 3 Sep 2015 15:31:43 +1000 Message-ID: <20150903053143.GL6537@voom.redhat.com> References: <20150903052050.GA4377@iris.ozlabs.ibm.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="S6vg04ofUPzW4qJg" Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org To: Paul Mackerras Return-path: Received: from ozlabs.org ([103.22.144.67]:53573 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750708AbbICFbk (ORCPT ); Thu, 3 Sep 2015 01:31:40 -0400 Content-Disposition: inline In-Reply-To: <20150903052050.GA4377@iris.ozlabs.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: --S6vg04ofUPzW4qJg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 03, 2015 at 03:20:50PM +1000, Paul Mackerras wrote: > From: "Gautham R. Shenoy" >=20 > The current dynamic micro-threading code has a race due to which a > secondary thread naps when it is supposed to be running a vcpu. As a > side effect of this, on a guest exit, the primary thread in > kvmppc_wait_for_nap() finds that this secondary thread hasn't cleared > its vcore pointer. This results in "CPU X seems to be stuck!" > warnings. >=20 > The race is possible since the primary thread on exiting the guests > only waits for all the secondaries to clear its vcore pointer. It > subsequently expects the secondary threads to enter nap while it > unsplits the core. A secondary thread which hasn't yet entered the nap > will loop in kvm_no_guest until its vcore pointer and the do_nap flag > are unset. Once the core has been unsplit, a new vcpu thread can grab > the core and set the do_nap flag *before* setting the vcore pointers > of the secondary. As a result, the secondary thread will now enter nap > via kvm_unsplit_nap instead of running the guest vcpu. >=20 > Fix this by setting the do_nap flag after setting the vcore pointer in > the PACA of the secondary in kvmppc_run_core. Also, ensure that a > secondary thread doesn't nap in kvm_unsplit_nap when the vcore pointer > in its PACA struct is set. >=20 > Fixes: b4deba5c41e9 > Signed-off-by: Gautham R. Shenoy > Signed-off-by: Paul Mackerras Reviewed-by: David Gibson --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --S6vg04ofUPzW4qJg Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJV59s/AAoJEGw4ysog2bOSdEQQAImRHmd7gBG83eSImjTq9ohe eXqVmKILurb0wzpopcSsPGxBAsOy3ABdj90qNq2Zc9wJXdmbUDqqGoCztNaU6A0t BpLL9PekH9hC1/nMRnrOVqtEGz/ZlLxRoRSTztV1BIw5+807DfJUpEl2p3cKMgyd nTblyxROHq5BlmAy060d26SCdxjVGm7VBOt3A/EJa0dd+rfuDT7PgNCCaMEF/oWN 3x49eLx/CX8i1k6PaF4zhPPfuYpB7GLf0lYTQVdZ3IF8CGWY5+WQp31/8qYXXu21 tqnE9dRIYbGkAeTtyRHlDBw9Kf+xUjU6wsxT1rqbXIVZx213l5+tdOO+hhvWT2Xw ZuED5y9b3JS+mEr7H0QySKnaBobZ2pgHfDHGUHuO8Cipwd8jwiMviYNDPbgGHcrr Et5xc5rQNSUrIF7arAjwoNRmT6fDEZo65Sa5ie9JfZVby/Uf1Gy44Wi2s9hs66KN BZHbTYMgG+wTMKqOCWvsrdyWH/pIzy0X5tG90MttIWwFj2oBOAQ6dfeCOkVWTdKD 37cQrXaPVYn5SYuCMSstiu4xQoDurFlGuXRsOj0GVt66tUVIbC4ntH06ZzTQ7sfy zd1RM+Vl2Y7iX/mvq4c3bXbsiDzK6GsuXlqRA62ocJYhakZVh5reZsINm5edm5Fe wdHU8M7eu8SL7RDgrLyQ =Vq1g -----END PGP SIGNATURE----- --S6vg04ofUPzW4qJg--