Received: by 10.223.164.202 with SMTP id h10csp194221wrb; Wed, 29 Nov 2017 20:03:53 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ3x/xIGOKm5/IFgh2GtE6xePFDePcD5afCX02DypY51y5CtfJBrpaXOwDNAlULamRfHoc6 X-Received: by 10.84.135.3 with SMTP id 3mr1184971pli.147.1512014633234; Wed, 29 Nov 2017 20:03:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512014633; cv=none; d=google.com; s=arc-20160816; b=jDiAUAjHLh0k/tDODlkVz4ZpNqmzz3ZDoROubVFvumnV+OGRjEGl0Jp6Un7Lc7YQl4 3EdF/naMv+yrlFRijpcuAoqMsq5WqDbG6OBUhxAm/g8loPsrpAXC6yyBLU3gSJES14KC neUoduuWNKeoB+JKLl7pwKb0KQwbem9mYXiDvGdRPyIEnKoFEa06xIe1x0j7aGGClsLh JhlBqWDXBN57SWGfIUUHJmtRyU/VaeNM2irK8IcewreHUjUJTp2G+wC0q2csh390Df/x SQutQny2P90+Cf1i8qGDsDvNl28CedMdDvds2oZFziTCSbuMBYCw0sV1SERMEELxlJ2D z1FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=CHlwlTlAfkAHowPprmd9wNNLx5Rwdx4c1YHJwEr2UTU=; b=ba/mtF/5Jf/x359YZyoMzE+TqqJdAlL2DvbTYC+vaByQ7rc/K0jf3LNMhg3KTq2bgw MDNuHxOc6pxLHtfuvqXgORCVLEtneNl4VB0/NGbvKnIfHWsCh8jBQeysxAOO3kZz+Nn7 Kn+lKgeZGBo8Ykx1pYnmmL3HwKSkMM9EYQ5K6HUgVSj7etzCRA4JXro6xiMgJ3PTA4nL yiNR4k08KdkK9UFDk8EZYMvGbND2HCmaxBAc6SXQhrgUtsNW7zKZ+sI+c0JvS8ErByw3 fnjKqSj/GHoIPQ36TsjlL5OYUBAqb4PUxu60Wp+e5W1zFL56Fv6Huxv6gsmslHg9oXUF KStw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=FqMsqo7C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q62si2519851pfd.99.2017.11.29.20.03.40; Wed, 29 Nov 2017 20:03:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=FqMsqo7C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753874AbdK3EDI (ORCPT + 99 others); Wed, 29 Nov 2017 23:03:08 -0500 Received: from ozlabs.org ([103.22.144.67]:48319 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753158AbdK3EDD (ORCPT ); Wed, 29 Nov 2017 23:03:03 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3ynNzT3H3Lz9sCZ; Thu, 30 Nov 2017 15:03:01 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1512014581; bh=ADbemIwIg0+8PSZ35NJq7cG+3Ou2VrdUGA1i0Id+uYM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FqMsqo7CImx93GheWvkif++/sxsnbW+u1JYqb9wESb/8FwjwKEw5LtjwRAQghhSMs 4/zzUQKj4aj90iK2Qz2LsiLDEpUH+VNTrFjpI0TLR2l4ROi1IYTfw8ztXpkWiMid3I 9u04963Bh4wAnPoDWZJ1sRxoGt8qG41Y6cmddS2A= Date: Thu, 30 Nov 2017 14:40:40 +1100 From: David Gibson To: Serhii Popovych Cc: linux-kernel@vger.kernel.org, michael@ellerman.id.au, paulus@samba.org, linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org Subject: Re: [PATCH 1/4] KVM: PPC: Book3S HV: Drop prepare_done from struct kvm_resize_hpt and cleanups Message-ID: <20171130034040.GO3023@umbus.fritz.box> References: <1511973506-65683-1-git-send-email-spopovyc@redhat.com> <1511973506-65683-2-git-send-email-spopovyc@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Thv7PGoFpDPJ7Oar" Content-Disposition: inline In-Reply-To: <1511973506-65683-2-git-send-email-spopovyc@redhat.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Thv7PGoFpDPJ7Oar Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 29, 2017 at 11:38:23AM -0500, Serhii Popovych wrote: > Replace ->prepare_done flag functionality with special handling > of -EBUSY in ->error as indicator that allocation work is running. >=20 > Besides cosmetics this reduces size of struct kvm_resize_hpt by > __alignof__(struct kvm_hpt_info) and saves few bytes of code. >=20 > While there correct comment in struct kvm_resize_hpt about locking > used to protect access to certain fields. >=20 > Assert with BUG_ON() in case of HPT allocation thread work runs > more than once for resize request or resize_hpt_allocate() > returns -EBUSY that is treated specially. >=20 > Change comparison against zero to make checkpatch.pl happy. >=20 > Signed-off-by: Serhii Popovych Reviewed-by: David Gibson > --- > arch/powerpc/kvm/book3s_64_mmu_hv.c | 42 ++++++++++++++++++++++---------= ------ > 1 file changed, 25 insertions(+), 17 deletions(-) >=20 > diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3= s_64_mmu_hv.c > index 235319c..0534aab 100644 > --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c > +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c > @@ -65,11 +65,17 @@ struct kvm_resize_hpt { > u32 order; > =20 > /* These fields protected by kvm->lock */ > + > + /* Possible values and their usage: > + * <0 an error occurred during allocation, > + * -EBUSY allocation is in the progress, > + * 0 allocation made successfuly. > + */ > int error; > - bool prepare_done; > =20 > - /* Private to the work thread, until prepare_done is true, > - * then protected by kvm->resize_hpt_sem */ > + /* Private to the work thread, until error !=3D -EBUSY, > + * then protected by kvm->lock. > + */ > struct kvm_hpt_info hpt; > }; > =20 > @@ -1432,15 +1438,21 @@ static void resize_hpt_prepare_work(struct work_s= truct *work) > struct kvm *kvm =3D resize->kvm; > int err; > =20 > + BUG_ON(resize->error !=3D -EBUSY); > + > resize_hpt_debug(resize, "resize_hpt_prepare_work(): order =3D %d\n", > resize->order); > =20 > err =3D resize_hpt_allocate(resize); > =20 > + /* We have strict assumption about -EBUSY > + * when preparing for HPT resize. > + */ > + BUG_ON(err =3D=3D -EBUSY); > + > mutex_lock(&kvm->lock); > =20 > resize->error =3D err; > - resize->prepare_done =3D true; > =20 > mutex_unlock(&kvm->lock); > } > @@ -1465,14 +1477,12 @@ long kvm_vm_ioctl_resize_hpt_prepare(struct kvm *= kvm, > =20 > if (resize) { > if (resize->order =3D=3D shift) { > - /* Suitable resize in progress */ > - if (resize->prepare_done) { > - ret =3D resize->error; > - if (ret !=3D 0) > - resize_hpt_release(kvm, resize); > - } else { > + /* Suitable resize in progress? */ > + ret =3D resize->error; > + if (ret =3D=3D -EBUSY) > ret =3D 100; /* estimated time in ms */ > - } > + else if (ret) > + resize_hpt_release(kvm, resize); > =20 > goto out; > } > @@ -1492,6 +1502,8 @@ long kvm_vm_ioctl_resize_hpt_prepare(struct kvm *kv= m, > ret =3D -ENOMEM; > goto out; > } > + > + resize->error =3D -EBUSY; > resize->order =3D shift; > resize->kvm =3D kvm; > INIT_WORK(&resize->work, resize_hpt_prepare_work); > @@ -1546,16 +1558,12 @@ long kvm_vm_ioctl_resize_hpt_commit(struct kvm *k= vm, > if (!resize || (resize->order !=3D shift)) > goto out; > =20 > - ret =3D -EBUSY; > - if (!resize->prepare_done) > - goto out; > - > ret =3D resize->error; > - if (ret !=3D 0) > + if (ret) > goto out; > =20 > ret =3D resize_hpt_rehash(resize); > - if (ret !=3D 0) > + if (ret) > goto out; > =20 > resize_hpt_pivot(resize); --=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 --Thv7PGoFpDPJ7Oar Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAloffbUACgkQbDjKyiDZ s5IQhhAA31vBjydx799tzGBY59NqRkjQpMIRv1nPPDi2jZsLI7QJf0l1bSWCAHhs Qfcx1xB0MZlU+ZTegcKvcPu8FodlvR4m5o/+2mzSl4zwAeeasJYgus7TylFjeeQg KXDHWziWgTMpP+lFPzTFJOZu2J8NCcpkSKttcKzy7tH6eSBmwGjvXM+U7+IszMmT cuLFOTB81MxRUb8sjLWRfmlimiWSts4WKzkaRIYxVWPIT+0VnYMeKrTwNUN8Mtcd iKjLNhY9dhTzRQd4dOgPcud4Y11wdh40vEST/UaSM7L8FFkLMmsfRaKxQY1nQ/Aq DdZ2DfEdQnlQGo7wwOZXv/3Fdy1Vy1VWb5Diw46pWeLDCIYxjJxIJv3FjVVFrgsC YikBQXn7A07g7vRw6UxjR4SpuWEjo4gh8DhtLY5HLPQrUg0yfhCwrod82hZlE2Pg 4M6I/ZIHHNNgxaXaO33tQk5f4RsRWw7sZhmPVTfqrzTSYbB34trJNkOpsd3b3PlX alfWhJxA5BnySCfarRvhw3ZjvTWRO48ZMamtLRgXvhT30y+EJLtSq4tkXBDO844v pV17K+iD59RKM0mzZsA5gmj/rOeKu86s9KA57yftIvMwO8ZVc0zXtiQOlBkK+bkg 1nS0cypTJkdRsGjKZXHmEHuNjzCVcTmNpRu3oEFZxhqPqAC0AtM= =c929 -----END PGP SIGNATURE----- --Thv7PGoFpDPJ7Oar-- From 1585419220701158959@xxx Wed Nov 29 16:39:51 +0000 2017 X-GM-THRID: 1585419220701158959 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread