linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Dufour <ldufour@linux.ibm.com>
To: Daniel Henrique Barboza <danielhb413@gmail.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/3] powerpc/pseries: break early in dlpar_memory_add_by_count() loops
Date: Thu, 24 Jun 2021 10:45:40 +0200	[thread overview]
Message-ID: <c0a3bb20-e3ed-1522-8411-510e94633511@linux.ibm.com> (raw)
In-Reply-To: <20210622133923.295373-3-danielhb413@gmail.com>

Le 22/06/2021 à 15:39, Daniel Henrique Barboza a écrit :
> After a successful dlpar_add_lmb() call the LMB is marked as reserved.
> Later on, depending whether we added enough LMBs or not, we rely on
> the marked LMBs to see which ones might need to be removed, and we
> remove the reservation of all of them.
> 
> These are done in for_each_drmem_lmb() loops without any break
> condition. This means that we're going to check all LMBs of the partition
> even after going through all the reserved ones.
> 
> This patch adds break conditions in both loops to avoid this. The
> 'lmbs_added' variable was renamed to 'lmbs_reserved', and it's now
> being decremented each time a lmb reservation is removed, indicating
> if there are still marked LMBs to be processed.

Reviewed-by: Laurent Dufour <ldufour@linux.ibm.com>

> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>   arch/powerpc/platforms/pseries/hotplug-memory.c | 17 ++++++++++++-----
>   1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
> index 28a7fd90232f..c0a03e1537cb 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
> @@ -673,7 +673,7 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add)
>   {
>   	struct drmem_lmb *lmb;
>   	int lmbs_available = 0;
> -	int lmbs_added = 0;
> +	int lmbs_reserved = 0;
>   	int rc;
>   
>   	pr_info("Attempting to hot-add %d LMB(s)\n", lmbs_to_add);
> @@ -714,13 +714,12 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add)
>   		 * requested LMBs cannot be added.
>   		 */
>   		drmem_mark_lmb_reserved(lmb);
> -
> -		lmbs_added++;
> -		if (lmbs_added == lmbs_to_add)
> +		lmbs_reserved++;
> +		if (lmbs_reserved == lmbs_to_add)
>   			break;
>   	}
>   
> -	if (lmbs_added != lmbs_to_add) {
> +	if (lmbs_reserved != lmbs_to_add) {
>   		pr_err("Memory hot-add failed, removing any added LMBs\n");
>   
>   		for_each_drmem_lmb(lmb) {
> @@ -735,6 +734,10 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add)
>   				dlpar_release_drc(lmb->drc_index);
>   
>   			drmem_remove_lmb_reservation(lmb);
> +			lmbs_reserved--;
> +
> +			if (lmbs_reserved == 0)
> +				break;
>   		}
>   		rc = -EINVAL;
>   	} else {
> @@ -745,6 +748,10 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add)
>   			pr_debug("Memory at %llx (drc index %x) was hot-added\n",
>   				 lmb->base_addr, lmb->drc_index);
>   			drmem_remove_lmb_reservation(lmb);
> +			lmbs_reserved--;
> +
> +			if (lmbs_reserved == 0)
> +				break;
>   		}
>   		rc = 0;
>   	}
> 


  reply	other threads:[~2021-06-24  8:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 13:39 [PATCH 0/3] powerpc/pseries: cleanups for dlpar_memory_add* functions Daniel Henrique Barboza
2021-06-22 13:39 ` [PATCH 1/3] powerpc/pseries: skip reserved LMBs in dlpar_memory_add_by_count() Daniel Henrique Barboza
2021-06-24  8:39   ` Laurent Dufour
2021-06-22 13:39 ` [PATCH 2/3] powerpc/pseries: break early in dlpar_memory_add_by_count() loops Daniel Henrique Barboza
2021-06-24  8:45   ` Laurent Dufour [this message]
2021-06-25  6:21   ` Michael Ellerman
2021-06-22 13:39 ` [PATCH 3/3] powerpc/pseries: fail quicker in dlpar_memory_add_by_ic() Daniel Henrique Barboza
2021-06-24  8:48   ` Laurent Dufour
2021-06-25  6:21 ` [PATCH 0/3] powerpc/pseries: cleanups for dlpar_memory_add* functions Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c0a3bb20-e3ed-1522-8411-510e94633511@linux.ibm.com \
    --to=ldufour@linux.ibm.com \
    --cc=danielhb413@gmail.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).