linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] s390/smp: clean up a condition
@ 2016-07-14 10:40 Dan Carpenter
  2016-07-18  7:07 ` Martin Schwidefsky
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-07-14 10:40 UTC (permalink / raw)
  To: Martin Schwidefsky
  Cc: Heiko Carstens, Michael Holzheu, Thomas Gleixner,
	Hendrik Brueckner, Peter Zijlstra (Intel), Christian Borntraeger,
	linux-s390, linux-kernel, kernel-janitors

I can never remember precedence rules.  Let's add some parenthesis so
this code is more clear.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
The original code is correct right?  We didn't intend to say:

	sclp_max = sclp.max_cores * (sclp_max ?: nr_cpu_ids);

diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 5c8f7ca..35531fe 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -887,7 +887,7 @@ void __init smp_fill_possible_mask(void)
 
 	sclp_max = max(sclp.mtid, sclp.mtid_cp) + 1;
 	sclp_max = min(smp_max_threads, sclp_max);
-	sclp_max = sclp.max_cores * sclp_max ?: nr_cpu_ids;
+	sclp_max = (sclp.max_cores * sclp_max) ?: nr_cpu_ids;
 	possible = setup_possible_cpus ?: nr_cpu_ids;
 	possible = min(possible, sclp_max);
 	for (cpu = 0; cpu < possible && cpu < nr_cpu_ids; cpu++)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] s390/smp: clean up a condition
  2016-07-14 10:40 [patch] s390/smp: clean up a condition Dan Carpenter
@ 2016-07-18  7:07 ` Martin Schwidefsky
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Schwidefsky @ 2016-07-18  7:07 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Heiko Carstens, Michael Holzheu, Thomas Gleixner,
	Hendrik Brueckner, Peter Zijlstra (Intel), Christian Borntraeger,
	linux-s390, linux-kernel, kernel-janitors

On Thu, 14 Jul 2016 13:40:22 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> I can never remember precedence rules.  Let's add some parenthesis so
> this code is more clear.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> The original code is correct right?  We didn't intend to say:
> 
> 	sclp_max = sclp.max_cores * (sclp_max ?: nr_cpu_ids);
> 
> diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
> index 5c8f7ca..35531fe 100644
> --- a/arch/s390/kernel/smp.c
> +++ b/arch/s390/kernel/smp.c
> @@ -887,7 +887,7 @@ void __init smp_fill_possible_mask(void)
> 
>  	sclp_max = max(sclp.mtid, sclp.mtid_cp) + 1;
>  	sclp_max = min(smp_max_threads, sclp_max);
> -	sclp_max = sclp.max_cores * sclp_max ?: nr_cpu_ids;
> +	sclp_max = (sclp.max_cores * sclp_max) ?: nr_cpu_ids;
>  	possible = setup_possible_cpus ?: nr_cpu_ids;
>  	possible = min(possible, sclp_max);
>  	for (cpu = 0; cpu < possible && cpu < nr_cpu_ids; cpu++)
> 

The code calculates the number of threads to use, then multiplies
it with the number of cores to get the number of logical CPUs.
If the product happens to be zero because the number of cores
could not be determined, then nr_cpu_ids is going to be used.

So the code is correct but with the parenthesis it is easier to
read. Applied & thanks.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-18  7:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-14 10:40 [patch] s390/smp: clean up a condition Dan Carpenter
2016-07-18  7:07 ` Martin Schwidefsky

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).