mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Yury Norov <yury.norov@gmail.com>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Christophe Leroy <christophe.leroy@csgroup.eu>,
	Thomas Gleixner <tglx@linutronix.de>,
	Frederic Barrat <fbarrat@linux.ibm.com>,
	Andrew Donnellan <ajd@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: pci-ioda: Optimize pnv_ioda_pick_m64_pe()
Date: Tue, 22 Jul 2025 10:36:05 +0200	[thread overview]
Message-ID: <874a2b30-ec4d-4b72-9f25-81429f03ccb7@kernel.org> (raw)
In-Reply-To: <20250720010552.427903-1-yury.norov@gmail.com>

On 20. 07. 25, 3:05, Yury Norov wrote:
> bitmap_empty() in pnv_ioda_pick_m64_pe() is O(N) and useless, because
> the following find_next_bit() does the same work.
> 
> Drop it, and while there replace a while() loop with the dedicated
> for_each_set_bit().
> 
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> ---
>   arch/powerpc/platforms/powernv/pci-ioda.c | 18 +++++-------------
>   1 file changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index d8ccf2c9b98a..c7a421ead992 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -313,24 +313,16 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
>   	/* Figure out reserved PE numbers by the PE */
>   	pnv_ioda_reserve_m64_pe(bus, pe_alloc, all);
>   
> -	/*
> -	 * the current bus might not own M64 window and that's all
> -	 * contributed by its child buses. For the case, we needn't
> -	 * pick M64 dependent PE#.
> -	 */
> -	if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) {
> -		kfree(pe_alloc);
> -		return NULL;
> -	}
> -
>   	/*
>   	 * Figure out the master PE and put all slave PEs to master
>   	 * PE's list to form compound PE.
> +	 *
> +	 * The current bus might not own M64 window and that's all
> +	 * contributed by its child buses. For the case, we needn't
> +	 * pick M64 dependent PE#.
>   	 */
>   	master_pe = NULL;
> -	i = -1;
> -	while ((i = find_next_bit(pe_alloc, phb->ioda.total_pe_num, i + 1)) <
> -		phb->ioda.total_pe_num) {
> +	for_each_set_bit(i, pe_alloc, phb->ioda.total_pe_num) {

Makes sense. Could you also:
* use bitmap_alloc()
* use __cleanup() to free the bitmap
* make i unsigned
?

thanks,
-- 
js
suse labs

      reply	other threads:[~2025-07-22  8:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-20  1:05 Yury Norov
2025-07-22  8:36 ` Jiri Slaby [this message]

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=874a2b30-ec4d-4b72-9f25-81429f03ccb7@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=ajd@linux.ibm.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=fbarrat@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=yury.norov@gmail.com \
    /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

all inboxes | Powered by JetHome®