lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 26 Aug 2011 15:32:04 -0700
From:	Andi Kleen <andi@...stfloor.org>
To:	tglx@...utronix.de
Cc:	linux-kernel@...r.kernel.org, tim.c.chen@...ux.intel.com,
	Andi Kleen <ak@...ux.intel.com>
Subject: [PATCH 3/3] tick-broadcast: push down tick_broadcast_lock

From: Andi Kleen <ak@...ux.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@...ux.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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ