* Peter Zijlstra <[email protected]> [2019-07-08 12:23:12]:

> On Sat, Jul 06, 2019 at 10:52:23PM +0530, Srikar Dronamraju wrote:
> > * Markus Elfring <[email protected]> [2019-07-06 16:05:17]:
> > 
> > > From: Markus Elfring <[email protected]>
> > > 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 <[email protected]>
> > > ---
> > >  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

Reply via email to