Message ID | 20170403215414.16951-3-anton@ozlabs.org (mailing list archive) |
---|---|
State | Mainlined |
Delegated to: | Rafael Wysocki |
Headers | show |
On Tue, 4 Apr 2017 07:54:14 +1000 Anton Blanchard <anton@ozlabs.org> wrote: > From: Anton Blanchard <anton@samba.org> > > When in the snooze_loop() we want to take up the least amount of > resources. On my version of gcc (6.3), we end up with an extra > branch because it predicts snooze_timeout_en to be false, whereas it > is almost always true. > > Use likely() to avoid the branch and be a little nicer to the > other non idle threads on the core. Patches 2 and 3 look fine. Should they be replicated to cpuidle-pseries.c as well? Thanks, Nick > > Signed-off-by: Anton Blanchard <anton@samba.org> > --- > drivers/cpuidle/cpuidle-powernv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c > index 8c991c254b95..251a60bfa8ee 100644 > --- a/drivers/cpuidle/cpuidle-powernv.c > +++ b/drivers/cpuidle/cpuidle-powernv.c > @@ -58,7 +58,7 @@ static int snooze_loop(struct cpuidle_device *dev, > ppc64_runlatch_off(); > HMT_very_low(); > while (!need_resched()) { > - if (snooze_timeout_en && get_tb() > snooze_exit_time) > + if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) > break; > } >
* Anton Blanchard <anton@ozlabs.org> [2017-04-04 07:54:14]: > From: Anton Blanchard <anton@samba.org> > > When in the snooze_loop() we want to take up the least amount of > resources. On my version of gcc (6.3), we end up with an extra > branch because it predicts snooze_timeout_en to be false, whereas it > is almost always true. By default snooze_timeout_en is true. It will become false only when we do not want to exit the snooze loop and that will be when snooze is the only idle state available in the platform, which is a rare case. > Use likely() to avoid the branch and be a little nicer to the > other non idle threads on the core. > > Signed-off-by: Anton Blanchard <anton@samba.org> Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> > --- > drivers/cpuidle/cpuidle-powernv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c > index 8c991c254b95..251a60bfa8ee 100644 > --- a/drivers/cpuidle/cpuidle-powernv.c > +++ b/drivers/cpuidle/cpuidle-powernv.c > @@ -58,7 +58,7 @@ static int snooze_loop(struct cpuidle_device *dev, > ppc64_runlatch_off(); > HMT_very_low(); > while (!need_resched()) { > - if (snooze_timeout_en && get_tb() > snooze_exit_time) > + if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) > break; > } > > -- > 2.11.0 >
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index 8c991c254b95..251a60bfa8ee 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c @@ -58,7 +58,7 @@ static int snooze_loop(struct cpuidle_device *dev, ppc64_runlatch_off(); HMT_very_low(); while (!need_resched()) { - if (snooze_timeout_en && get_tb() > snooze_exit_time) + if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) break; }