lkml.org 
[lkml]   [2011]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/4] Avoid broadcast time lock when not changing the timeout
Date
From: Andi Kleen <ak@linux.intel.com>

Don't take the global lock when the new timeout is larger than the
old timeout.

The timeout on the broadcast device should never shrink, so this
is safe to do.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
kernel/time/tick-broadcast.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index c1587cb..4776742 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -524,6 +524,17 @@ static void set_broadcast_sibling_state(int cpu, int enter)
}
}

+static void set_broadcast_timeout(ktime_t to, struct clock_event_device *bc)
+{
+ unsigned long flags;
+
+ if (to.tv64 < bc->next_event.tv64) {
+ raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
+ tick_broadcast_set_event(to, 1);
+ raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+ }
+}
+
/*
* Powerstate information: The system enters/leaves a state, where
* affected devices might stop
@@ -532,7 +543,6 @@ void tick_broadcast_oneshot_control(unsigned long reason)
{
struct clock_event_device *bc, *dev;
struct tick_device *td;
- unsigned long flags;
int cpu;
ktime_t timeout;

@@ -556,14 +566,12 @@ void tick_broadcast_oneshot_control(unsigned long reason)
reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER))
return;

- raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
if (reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER) {
if (!__get_cpu_var(state).need_oneshot) {
/* Turn all slaves into oneshots */
set_broadcast_sibling_state(cpu, 1);
clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN);
- if (timeout.tv64 < bc->next_event.tv64)
- tick_broadcast_set_event(timeout, 1);
+ set_broadcast_timeout(timeout, bc);
}
} else {
if (__get_cpu_var(state).need_oneshot) {
@@ -574,7 +582,6 @@ void tick_broadcast_oneshot_control(unsigned long reason)
tick_program_event(dev->next_event, 1);
}
}
- raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
}

/*
--
1.7.4.4


\
 
 \ /
  Last update: 2011-05-06 23:43    [from the cache]
©2003-2011 Jasper Spaans