From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751674AbcGRHIH (ORCPT ); Mon, 18 Jul 2016 03:08:07 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:62811 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751136AbcGRHIE (ORCPT ); Mon, 18 Jul 2016 03:08:04 -0400 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: schwidefsky@de.ibm.com X-IBM-RcptTo: kernel-janitors@vger.kernel.org;linux-kernel@vger.kernel.org;linux-s390@vger.kernel.org Date: Mon, 18 Jul 2016 09:07:35 +0200 From: Martin Schwidefsky To: Dan Carpenter Cc: Heiko Carstens , Michael Holzheu , Thomas Gleixner , Hendrik Brueckner , "Peter Zijlstra (Intel)" , Christian Borntraeger , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [patch] s390/smp: clean up a condition In-Reply-To: <20160714104022.GF18175@mwanda> References: <20160714104022.GF18175@mwanda> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16071807-0020-0000-0000-0000021FA7E8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16071807-0021-0000-0000-00003D14DE39 Message-Id: <20160718090735.103390c9@mschwide> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-07-18_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607180086 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 Jul 2016 13:40:22 +0300 Dan Carpenter wrote: > I can never remember precedence rules. Let's add some parenthesis so > this code is more clear. > > Signed-off-by: Dan Carpenter > --- > 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.