[PATCH V2 09/16] cpuidle: reduce code duplication inside cpuidle_idle_call()

From: Viresh Kumar
Date: Thu Oct 03 2013 - 12:01:04 EST


We are doing this twice in cpuidle_idle_call() routine:
drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP

Would be better if we actually store this in a local variable and use that. That
would remove code duplication as well as make this piece of code run fast (in
case compiler wasn't able to optimize it earlier)

Acked-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
---
drivers/cpuidle/cpuidle.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 518b542..ffc637a 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -118,6 +118,7 @@ int cpuidle_idle_call(void)
struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
struct cpuidle_driver *drv;
int next_state, entered_state;
+ bool broadcast;

if (off || !initialized)
return -ENODEV;
@@ -141,7 +142,9 @@ int cpuidle_idle_call(void)

trace_cpu_idle_rcuidle(next_state, dev->cpu);

- if (drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP)
+ broadcast = drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP;
+
+ if (broadcast)
clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER,
&dev->cpu);

@@ -151,7 +154,7 @@ int cpuidle_idle_call(void)
else
entered_state = cpuidle_enter_state(dev, drv, next_state);

- if (drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP)
+ if (broadcast)
clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT,
&dev->cpu);

--
1.7.12.rc2.18.g61b472e

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/