linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: kernel-janitors@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched/topology: One function call less in build_group_from_child_sched_domain()
Date: Sat, 6 Jul 2019 22:52:23 +0530	[thread overview]
Message-ID: <20190706172223.GA12680@linux.vnet.ibm.com> (raw)
In-Reply-To: <ad2e7dfb-3323-b214-716e-a6cae41b8bcc@web.de>

* Markus Elfring <Markus.Elfring@web.de> [2019-07-06 16:05:17]:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>
> ---
>  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.

>  	atomic_inc(&sg->ref);
>  	return sg;
>  }
> --
> 2.22.0
> 

-- 
Thanks and Regards
Srikar Dronamraju


  reply	other threads:[~2019-07-06 17:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-06 14:05 [PATCH] sched/topology: One function call less in build_group_from_child_sched_domain() Markus Elfring
2019-07-06 17:22 ` Srikar Dronamraju [this message]
2019-07-08  9:38   ` Enrico Weigelt, metux IT consult
2019-07-08 14:27     ` Srikar Dronamraju
2019-07-08 10:23   ` Peter Zijlstra
2019-07-08 14:07     ` Srikar Dronamraju
2019-07-08 15:44       ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190706172223.GA12680@linux.vnet.ibm.com \
    --to=srikar@linux.vnet.ibm.com \
    --cc=Markus.Elfring@web.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).