Skip to contentSkip to conversation

s390/smp: clean up a condition

PATCH In review Dan Carpenter 2 participants 2 messages Jul 14, 2016 – Jul 18, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/smp: clean up a condition

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

---
The original code is correct right? We didn't intend to say:

	sclp_max = sclp.max_cores * (sclp_max ?: nr_cpu_ids);
arch/s390/kernel/smp.c +1 -1
index 5c8f7ca..35531fe 100644
@@ -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++)
#1 lore raw
Quoted 15 lines · On Thu, 14 Jul 2016 13:40:22 +0300 Dan Carpenter <[email protected]>…

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

---
The original code is correct right? We didn't intend to say:

	sclp_max = sclp.max_cores * (sclp_max ?: nr_cpu_ids);
arch/s390/kernel/smp.c +0 -0
index 5c8f7ca..35531fe 100644

arch/s390/kernel/smp.c void __init smp_fill_possible_mask(void) · line 893

Quoted 8 lines
arch/s390/kernel/smp.c +1 -1
@@ -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.

Signature · 4 lines
blue skies,
   Martin.

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