lkml.org 
[lkml]   [2011]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] tick-broadcast: push down tick_broadcast_lock
Date
From: Andi Kleen <ak@linux.intel.com>

For the oneshot case, only take the tick_broadcast_lock when the
global device is actually changing. For the case when the new
event is only setting the wakeup to a later time than it already
is we don't need the lock.

This avoids lock contention for some special cases on systems
that don't have an always running per cpu timer. It's not a full
solution to the scalability problem there unfortunately, just
the first step.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
kernel/time/tick-broadcast.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 7f33b15..1576da7 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -485,23 +485,33 @@ void tick_broadcast_oneshot_control(unsigned long reason)

bc = tick_broadcast_device.evtdev;

- raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
if (reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER) {
if (!__get_cpu_var(state).need_oneshot) {
__get_cpu_var(state).need_oneshot = 1;
clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN);
- if (dev->next_event.tv64 < bc->next_event.tv64)
+
+ /* Only take the lock if the events gets set earlier */
+ if (dev->next_event.tv64 < bc->next_event.tv64) {
+ raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
tick_broadcast_set_event(dev->next_event, 1);
+ raw_spin_unlock_irqrestore(&tick_broadcast_lock,
+ flags);
+ }
}
} else {
if (__get_cpu_var(state).need_oneshot) {
__get_cpu_var(state).need_oneshot = 0;
clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT);
- if (dev->next_event.tv64 != KTIME_MAX)
+
+ /* Only take the lock if the event changes */
+ if (dev->next_event.tv64 != KTIME_MAX) {
+ raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
tick_program_event(dev->next_event, 1);
+ raw_spin_unlock_irqrestore(&tick_broadcast_lock,
+ flags);
+ }
}
}
- raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
}

/*
--
1.7.4.4


\
 
 \ /
  Last update: 2011-08-27 00:35    [W:0.122 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site