public inbox for linuxppc-dev@ozlabs.org
 help / color / mirror / Atom feed
From: Yury Norov <ynorov@nvidia.com>
To: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org,
	yury.norov@gmail.com, linux@rasmusvillemoes.dk,
	linux-kernel@vger.kernel.org, chleroy@kernel.org
Subject: Re: [PATCH 2/2] powerpc: Few misc cpumask code refactors
Date: Sat, 28 Mar 2026 16:27:36 -0400	[thread overview]
Message-ID: <acgzqVOlH_RlY8D8@yury> (raw)
In-Reply-To: <20260327063129.127302-3-sshegde@linux.ibm.com>

On Fri, Mar 27, 2026 at 12:01:29PM +0530, Shrikanth Hegde wrote:
> A few miscellanous changes in handling cpumask api's in the order
> they appear:
> 
> - cpumask_next(cpu, mask) >= nr_cpu_ids is used to determine if
>   cpu is the last CPU. 
> 
> - cpumask_next can take -1 as valid argument. So simplify cpuinfo
>   iterator. /proc/cpuinfo shows same info with patch.
> 
> - cpumask_weight can't be more than nr_cpu_ids. So remove the pointless
>   comparison.
> 
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
>  arch/powerpc/kernel/setup-common.c | 7 ++-----
>  arch/powerpc/sysdev/xive/common.c  | 7 +++----
>  2 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
> index b1761909c23f..47215eab296b 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -323,7 +323,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
>  	seq_putc(m, '\n');
>  
>  	/* If this is the last cpu, print the summary */
> -	if (cpumask_next(cpu_id, cpu_online_mask) >= nr_cpu_ids)
> +	if (cpu_id == cpumask_last(cpu_online_mask))
>  		show_cpuinfo_summary(m);
>  
>  	return 0;
> @@ -331,10 +331,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
>  
>  static void *c_start(struct seq_file *m, loff_t *pos)
>  {
> -	if (*pos == 0)	/* just in case, cpu 0 is not the first */
> -		*pos = cpumask_first(cpu_online_mask);
> -	else
> -		*pos = cpumask_next(*pos - 1, cpu_online_mask);
> +	*pos = cpumask_next(*pos - 1, cpu_online_mask);
>  	if ((*pos) < nr_cpu_ids)
>  		return (void *)(unsigned long)(*pos + 1);
>  	return NULL;
> diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
> index b6446abe29a6..91dd3b364d7d 100644
> --- a/arch/powerpc/sysdev/xive/common.c
> +++ b/arch/powerpc/sysdev/xive/common.c
> @@ -548,11 +548,10 @@ static void xive_dec_target_count(int cpu)
>  static int xive_find_target_in_mask(const struct cpumask *mask,
>  				    unsigned int fuzz)
>  {
> -	int cpu, first, num, i;
> +	int cpu, first, i;
>  
> -	/* Pick up a starting point CPU in the mask based on  fuzz */
> -	num = min_t(int, cpumask_weight(mask), nr_cpu_ids);
> -	first = fuzz % num;
> +	/* Pick up a starting point CPU in the mask based on fuzz */
> +	first = fuzz % cpumask_weight(mask);

For this function I've got a deeper rework.

https://lore.kernel.org/all/20260319033647.881246-3-ynorov@nvidia.com/

For the rest:
Reviewed-by: Yury Norov <ynorov@nvidia.com>

>  
>  	/* Locate it */
>  	cpu = cpumask_first(mask);
> -- 
> 2.47.3


      reply	other threads:[~2026-03-28 20:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-27  6:31 [PATCH 0/2] powerpc: A few misc cpumask refactors Shrikanth Hegde
2026-03-27  6:31 ` [PATCH 1/2] powerpc: Use cpumask_next_wrap instead Shrikanth Hegde
2026-03-28 20:44   ` Yury Norov
2026-03-29  9:18     ` Shrikanth Hegde
2026-03-27  6:31 ` [PATCH 2/2] powerpc: Few misc cpumask code refactors Shrikanth Hegde
2026-03-28 20:27   ` Yury Norov [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=acgzqVOlH_RlY8D8@yury \
    --to=ynorov@nvidia.com \
    --cc=chleroy@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=sshegde@linux.ibm.com \
    --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