RE: [PATCH v2] cpufreq: powernv: Set the cpus to nominal frequency during reboot/kexec

From: David Laight
Date: Mon Sep 01 2014 - 05:14:51 EST


From: Shilpa Bhat
> Hi Viresh,
> On Fri, 2014-08-29 at 05:33 +0530, Viresh Kumar wrote:
> > On 28 August 2014 19:36, Shilpasri G Bhat
> > <shilpa.bhat@xxxxxxxxxxxxxxxxxx> wrote:
> > >
> > > Changes v1->v2:
> > > Invoke .target() driver callback to set the cpus to nominal frequency
> > > in reboot notifier, instead of calling cpufreq_suspend() as suggested
> > > by Viresh Kumar.
> > > Modified the commit message.
> >
> > This changelog will get commited, is this what you want?
>
> > > + if (unlikely(rebooting) && new_index != get_nominal_index())
> > > + return -EBUSY;
> >
> > Have you placed the unlikely only around 'rebooting' intentionally or
> > should it cover whole if statement?
> >
>
> Yes unlikely() should cover the whole if statement...

Actually it probably shouldn't.
You need to look at the generated code with each different set of 'unlikely()'
to see how gcc processes them.
In this case, if 'rebooting' is false you want to 'fall through' on a statically
predicted 'not taken' branch. You don't ever care about the second clause.
With an 'unlikely' covering the entire statement gcc could easily add a
forwards conditional branch (that will be mis-predicted) for the 'rebooting' test.

(Yes, I spent a lot of time getting gcc to generate branches that were
correctly statically predicted for some code where every cycle mattered.)

David

N‹§²æ¸›yú²X¬¶ÇvØ–)Þ{.nlj·¥Š{±‘êX§¶›¡Ü}©ž²ÆzÚj:+v‰¨¾«‘êZ+€Êzf£¢·hšˆ§~†­†Ûÿû®w¥¢¸?™¨è&¢)ßf”ùy§m…á«a¶Úÿ 0¶ìå