[PATCH 35/38] tick-broadcast: do checks before taking locks in tick_do_broadcast_on_off()

From: Viresh Kumar
Date: Mon Apr 14 2014 - 12:28:19 EST


Some of the checks which may force tick_do_broadcast_on_off() to return early
can be done before taking locks. This would make these codepaths faster.

Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
---
kernel/time/tick-broadcast.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 1597d03..3b07569 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -329,27 +329,22 @@ unlock:
*/
static void tick_do_broadcast_on_off(unsigned long *reason)
{
- struct clock_event_device *bc, *dev;
- struct tick_device *td;
+ struct tick_device *td = tick_get_cpu_device();
+ struct clock_event_device *bc, *dev = td->evtdev;
+ int cpu = smp_processor_id(), bc_stopped;
unsigned long flags;
- int cpu, bc_stopped;
-
- raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
-
- cpu = smp_processor_id();
- td = tick_get_device(cpu);
- dev = td->evtdev;
- bc = tick_broadcast_device.evtdev;

/*
* Is the device not affected by the powerstate ?
*/
if (!dev || !(dev->features & CLOCK_EVT_FEAT_C3STOP))
- goto out;
+ return;

if (!tick_device_is_functional(dev))
- goto out;
+ return;

+ raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
+ bc = tick_broadcast_device.evtdev;
bc_stopped = cpumask_empty(tick_broadcast_mask);

switch (*reason) {
@@ -385,7 +380,6 @@ static void tick_do_broadcast_on_off(unsigned long *reason)
else
tick_broadcast_setup_oneshot(bc);
}
-out:
raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
}

--
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/