From mboxrd@z Thu Jan 1 00:00:00 1970 From: Srikar Dronamraju Date: Mon, 08 Jul 2019 14:19:51 +0000 Subject: Re: [PATCH] sched/topology: One function call less in build_group_from_child_sched_domain() Message-Id: <20190708140751.GA10675@linux.vnet.ibm.com> List-Id: References: <20190706172223.GA12680@linux.vnet.ibm.com> <20190708102312.GF3402@hirez.programming.kicks-ass.net> In-Reply-To: <20190708102312.GF3402@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Peter Zijlstra Cc: Markus Elfring , kernel-janitors@vger.kernel.org, Ingo Molnar , LKML * Peter Zijlstra [2019-07-08 12:23:12]: > On Sat, Jul 06, 2019 at 10:52:23PM +0530, Srikar Dronamraju wrote: > > * Markus Elfring [2019-07-06 16:05:17]: > > > > > From: Markus Elfring > > > Date: Sat, 6 Jul 2019 16:00:13 +0200 > > > > > > Avoid an extra function call by using a ternary operator instead of > > > a conditional statement. > > > > > > This issue was detected by using the Coccinelle software. > > > > > > Signed-off-by: Markus Elfring > > > --- > > > kernel/sched/topology.c | 6 +----- > > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > > > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > > > index f751ce0b783e..6190eb52c30a 100644 > > > --- a/kernel/sched/topology.c > > > +++ b/kernel/sched/topology.c > > > @@ -886,11 +886,7 @@ build_group_from_child_sched_domain(struct sched_domain *sd, int cpu) > > > return NULL; > > > > > > sg_span = sched_group_span(sg); > > > - if (sd->child) > > > - cpumask_copy(sg_span, sched_domain_span(sd->child)); > > > - else > > > - cpumask_copy(sg_span, sched_domain_span(sd)); > > > - > > > + cpumask_copy(sg_span, sched_domain_span(sd->child ? sd->child : sd)); > > > > At runtime, Are we avoiding a function call? > > However I think we are avoiding a branch instead of a conditional, which may > > be beneficial. > > It all depends on what the compiler does; also this is super slow path > stuff and the patch makes code less readable (IMO). > Yes, it definitely makes code readable. I was only commenting on the changelog/subject which says avoids a function call which I think it doesn't. -- Thanks and Regards Srikar Dronamraju From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6494AC606BF for ; Mon, 8 Jul 2019 14:08:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4638A21537 for ; Mon, 8 Jul 2019 14:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731611AbfGHOIC (ORCPT ); Mon, 8 Jul 2019 10:08:02 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:2264 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727401AbfGHOIC (ORCPT ); Mon, 8 Jul 2019 10:08:02 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x68E7e36095033 for ; Mon, 8 Jul 2019 10:08:01 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tm5yj3kfj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 08 Jul 2019 10:07:59 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Jul 2019 15:07:56 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 8 Jul 2019 15:07:53 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x68E7q5348758888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 Jul 2019 14:07:53 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6BB2A4051; Mon, 8 Jul 2019 14:07:52 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B03F9A4053; Mon, 8 Jul 2019 14:07:51 +0000 (GMT) Received: from linux.vnet.ibm.com (unknown [9.126.150.29]) by d06av23.portsmouth.uk.ibm.com (Postfix) with SMTP; Mon, 8 Jul 2019 14:07:51 +0000 (GMT) Date: Mon, 8 Jul 2019 19:37:51 +0530 From: Srikar Dronamraju To: Peter Zijlstra Cc: Markus Elfring , kernel-janitors@vger.kernel.org, Ingo Molnar , LKML Subject: Re: [PATCH] sched/topology: One function call less in build_group_from_child_sched_domain() Reply-To: Srikar Dronamraju References: <20190706172223.GA12680@linux.vnet.ibm.com> <20190708102312.GF3402@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20190708102312.GF3402@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-TM-AS-GCONF: 00 x-cbid: 19070814-0016-0000-0000-000002904D88 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19070814-0017-0000-0000-000032EDFB8B Message-Id: <20190708140751.GA10675@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-08_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=731 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907080176 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Peter Zijlstra [2019-07-08 12:23:12]: > On Sat, Jul 06, 2019 at 10:52:23PM +0530, Srikar Dronamraju wrote: > > * Markus Elfring [2019-07-06 16:05:17]: > > > > > From: Markus Elfring > > > Date: Sat, 6 Jul 2019 16:00:13 +0200 > > > > > > Avoid an extra function call by using a ternary operator instead of > > > a conditional statement. > > > > > > This issue was detected by using the Coccinelle software. > > > > > > Signed-off-by: Markus Elfring > > > --- > > > kernel/sched/topology.c | 6 +----- > > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > > > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > > > index f751ce0b783e..6190eb52c30a 100644 > > > --- a/kernel/sched/topology.c > > > +++ b/kernel/sched/topology.c > > > @@ -886,11 +886,7 @@ build_group_from_child_sched_domain(struct sched_domain *sd, int cpu) > > > return NULL; > > > > > > sg_span = sched_group_span(sg); > > > - if (sd->child) > > > - cpumask_copy(sg_span, sched_domain_span(sd->child)); > > > - else > > > - cpumask_copy(sg_span, sched_domain_span(sd)); > > > - > > > + cpumask_copy(sg_span, sched_domain_span(sd->child ? sd->child : sd)); > > > > At runtime, Are we avoiding a function call? > > However I think we are avoiding a branch instead of a conditional, which may > > be beneficial. > > It all depends on what the compiler does; also this is super slow path > stuff and the patch makes code less readable (IMO). > Yes, it definitely makes code readable. I was only commenting on the changelog/subject which says avoids a function call which I think it doesn't. -- Thanks and Regards Srikar Dronamraju