lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20160718090735.103390c9@mschwide>
Date:	Mon, 18 Jul 2016 09:07:35 +0200
From:	Martin Schwidefsky <schwidefsky@...ibm.com>
To:	Dan Carpenter <dan.carpenter@...cle.com>
Cc:	Heiko Carstens <heiko.carstens@...ibm.com>,
	Michael Holzheu <holzheu@...ux.vnet.ibm.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Hendrik Brueckner <brueckner@...ux.vnet.ibm.com>,
	"Peter Zijlstra (Intel)" <peterz@...radead.org>,
	Christian Borntraeger <borntraeger@...ibm.com>,
	linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [patch] s390/smp: clean up a condition

On Thu, 14 Jul 2016 13:40:22 +0300
Dan Carpenter <dan.carpenter@...cle.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@...cle.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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ