From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CDC9C433ED for ; Thu, 13 May 2021 05:24:38 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD2EA613D3 for ; Thu, 13 May 2021 05:24:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD2EA613D3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Fgg8431TGz3c7f for ; Thu, 13 May 2021 15:24:36 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=201602 header.b=owQ9oHgU; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=203.11.71.1; helo=ozlabs.org; envelope-from=dgibson@ozlabs.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=201602 header.b=owQ9oHgU; dkim-atps=neutral Received: from ozlabs.org (ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Fgg663GWpz2yhr for ; Thu, 13 May 2021 15:22:54 +1000 (AEST) Received: by ozlabs.org (Postfix, from userid 1007) id 4Fgg653tmkz9sj1; Thu, 13 May 2021 15:22:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1620883373; bh=Vb4rmnIjEjqEVJw5BsKv6K7QbndJNhjYRfkTiT3g7F8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=owQ9oHgUz12/1YNr+MKZ+ZhlKO1uzFXuNLDDOQfc65BZmX7eUZELnmXwfqB80MvRj hkVczRzQLTt93BBhL3dQoT0foLVwhAKfij/aAmRaoEHFTcMi8VpJ82rkVMU1uLQ+iF 0ThijDF4ie2VGAfLZOgDq21BjLWGNKm4u/662pwg= Date: Thu, 13 May 2021 15:20:09 +1000 From: David Gibson To: Daniel Henrique Barboza Subject: Re: [PATCH v2 3/4] powerpc/pseries: break early in dlpar_memory_remove_by_count() loops Message-ID: References: <20210512202809.95363-1-danielhb413@gmail.com> <20210512202809.95363-4-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BESH7SqVVhQOjPsA" Content-Disposition: inline In-Reply-To: <20210512202809.95363-4-danielhb413@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" --BESH7SqVVhQOjPsA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 12, 2021 at 05:28:08PM -0300, Daniel Henrique Barboza wrote: > After marking the LMBs as reserved depending on dlpar_remove_lmb() rc, > we evaluate whether we need to add the LMBs back or if we can release > the LMB DRCs. In both cases, a for_each_drmem_lmb() loop without a break > condition is used. This means that we're going to cycle through all LMBs > of the partition even after we're done with what we were going to do. >=20 > This patch adds break conditions in both loops to avoid this. The > 'lmbs_removed' variable was renamed to 'lmbs_reserved', and it's now > being decremented each time a lmb reservation is removed, indicating > that the operation we're doing (adding back LMBs or releasing DRCs) is > completed. >=20 > Signed-off-by: Daniel Henrique Barboza Reviewed-by: David Gibson The fact that DRCONF_MEM_RESERVED and DRMEM_LMB_RESERVED look so similar but have totally different meanings doesn't make this easy to follow :/. > --- > arch/powerpc/platforms/pseries/hotplug-memory.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) >=20 > diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/power= pc/platforms/pseries/hotplug-memory.c > index c21d9278c1ce..3c7ce5361ce3 100644 > --- a/arch/powerpc/platforms/pseries/hotplug-memory.c > +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c > @@ -402,7 +402,7 @@ static int dlpar_remove_lmb(struct drmem_lmb *lmb) > static int dlpar_memory_remove_by_count(u32 lmbs_to_remove) > { > struct drmem_lmb *lmb; > - int lmbs_removed =3D 0; > + int lmbs_reserved =3D 0; > int lmbs_available =3D 0; > int rc; > =20 > @@ -436,12 +436,12 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to= _remove) > */ > drmem_mark_lmb_reserved(lmb); > =20 > - lmbs_removed++; > - if (lmbs_removed =3D=3D lmbs_to_remove) > + lmbs_reserved++; > + if (lmbs_reserved =3D=3D lmbs_to_remove) > break; > } > =20 > - if (lmbs_removed !=3D lmbs_to_remove) { > + if (lmbs_reserved !=3D lmbs_to_remove) { > pr_err("Memory hot-remove failed, adding LMB's back\n"); > =20 > for_each_drmem_lmb(lmb) { > @@ -454,6 +454,10 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to_= remove) > lmb->drc_index); > =20 > drmem_remove_lmb_reservation(lmb); > + > + lmbs_reserved--; > + if (lmbs_reserved =3D=3D 0) > + break; > } > =20 > rc =3D -EINVAL; > @@ -467,6 +471,10 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to_= remove) > lmb->base_addr); > =20 > drmem_remove_lmb_reservation(lmb); > + > + lmbs_reserved--; > + if (lmbs_reserved =3D=3D 0) > + break; > } > rc =3D 0; > } --=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 --BESH7SqVVhQOjPsA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAmCctwkACgkQbDjKyiDZ s5IfJw//Ux7Mw/V03RbxwIG9TA0nP+HCymU2jruw1eV0z42LAQcfiIkY31iZ1iRA jy3Kel8eDpnvrCCjzWNMOD+yjjTNUCA0VuJ2XmyoBpGcH5UplsU+1Zn0Qjft1P18 9avb49y8jlUOgnNS5AuKsIIolDsO7oqULjtQbIoG1PrGBI3LigmSIBoqTqttSSl5 hgOikliBjn/Oiy+SFSIAuXi9mVynezjpjI066UFzMtiUtWjAXnXU7SgXi1YdMf/e w+NUpRCcPyI52XcO+/feDUughtpGApD0O8AxJh4uHwD6NThpzMb8Kfc1EbeJrbpT ZvLlZw03bBG+F6rfVyza1Vcpxef/jtkxXXPC/kZdkEGp95DOr4dIEaCS9t9fVLz9 kJw1YYTgZz2ODMSvELigxmsHS3zdQWjDgaOlemhRUGfVAfE7ZktSBxlX16qQJiuh a6TxMeTjfExNgBxUCUgDDPAQ9qg9mhAhtgTQVpTA0263S0LXliWfaMdpUwJCCMGs 7CT5CxVTc/rqF56wpELSv63a/vKpOkoAvRyziwTahdi3okdnG/KHJA+GBKRnxtoH GITFDuBkV0Zx2nsxwyS6M/H4TuR2k1v18grihrZkREhAqiUcNQprU710TCQES8ED IrzYQfr/Jx1kt7aMeQ4il573GqqEK54ecb7zYjtgc9dH6fI1R0I= =uU+X -----END PGP SIGNATURE----- --BESH7SqVVhQOjPsA--