All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 3.18 01/22] locking/lockdep: Fix debug_locks off performance problem
@ 2018-10-31 23:11 Sasha Levin
  2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 02/22] ataflop: fix error handling during setup Sasha Levin
                   ` (20 more replies)
  0 siblings, 21 replies; 24+ messages in thread
From: Sasha Levin @ 2018-10-31 23:11 UTC (permalink / raw)
  To: stable, linux-kernel
  Cc: Waiman Long, Andrew Morton, Linus Torvalds, Paul E . McKenney,
	Peter Zijlstra, Thomas Gleixner, Will Deacon, Ingo Molnar,
	Sasha Levin

From: Waiman Long <longman@redhat.com>

[ Upstream commit 9506a7425b094d2f1d9c877ed5a78f416669269b ]

It was found that when debug_locks was turned off because of a problem
found by the lockdep code, the system performance could drop quite
significantly when the lock_stat code was also configured into the
kernel. For instance, parallel kernel build time on a 4-socket x86-64
server nearly doubled.

Further analysis into the cause of the slowdown traced back to the
frequent call to debug_locks_off() from the __lock_acquired() function
probably due to some inconsistent lockdep states with debug_locks
off. The debug_locks_off() function did an unconditional atomic xchg
to write a 0 value into debug_locks which had already been set to 0.
This led to severe cacheline contention in the cacheline that held
debug_locks.  As debug_locks is being referenced in quite a few different
places in the kernel, this greatly slow down the system performance.

To prevent that trashing of debug_locks cacheline, lock_acquired()
and lock_contended() now checks the state of debug_locks before
proceeding. The debug_locks_off() function is also modified to check
debug_locks before calling __debug_locks_off().

Signed-off-by: Waiman Long <longman@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Link: http://lkml.kernel.org/r/1539913518-15598-1-git-send-email-longman@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/locking/lockdep.c | 4 ++--
 lib/debug_locks.c        | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index f99008534275..fb90ca3a296e 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3808,7 +3808,7 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)
 {
 	unsigned long flags;
 
-	if (unlikely(!lock_stat))
+	if (unlikely(!lock_stat || !debug_locks))
 		return;
 
 	if (unlikely(current->lockdep_recursion))
@@ -3828,7 +3828,7 @@ void lock_acquired(struct lockdep_map *lock, unsigned long ip)
 {
 	unsigned long flags;
 
-	if (unlikely(!lock_stat))
+	if (unlikely(!lock_stat || !debug_locks))
 		return;
 
 	if (unlikely(current->lockdep_recursion))
diff --git a/lib/debug_locks.c b/lib/debug_locks.c
index 96c4c633d95e..124fdf238b3d 100644
--- a/lib/debug_locks.c
+++ b/lib/debug_locks.c
@@ -37,7 +37,7 @@ EXPORT_SYMBOL_GPL(debug_locks_silent);
  */
 int debug_locks_off(void)
 {
-	if (__debug_locks_off()) {
+	if (debug_locks && __debug_locks_off()) {
 		if (!debug_locks_silent) {
 			console_verbose();
 			return 1;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2018-11-01  1:29 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-31 23:11 [PATCH AUTOSEL 3.18 01/22] locking/lockdep: Fix debug_locks off performance problem Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 02/22] ataflop: fix error handling during setup Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 03/22] swim: fix cleanup on setup error Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 04/22] tun: Consistently configure generic netdev params via rtnetlink Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 05/22] perf tools: Free temporary 'sys' string in read_event_files() Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 06/22] perf tools: Cleanup trace-event-info 'tdata' leak Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 07/22] cpupower: Fix coredump on VMWare Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 08/22] mmc: sdhci-pci-o2micro: Add quirk for O2 Micro dev 0x8620 rev 0x01 Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 09/22] x86/olpc: Indicate that legacy PC XO-1 platform should not register RTC Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 10/22] regulator: fixed: Default enable high on DT regulators Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 11/22] x86: boot: Fix EFI stub alignment Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 12/22] kprobes: Return error if we fail to reuse kprobe instead of BUG_ON() Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 13/22] ath10k: schedule hardware restart if WMI command times out Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 14/22] scsi: esp_scsi: Track residual for PIO transfers Sasha Levin
2018-10-31 23:11 ` [PATCH AUTOSEL 3.18 15/22] Drivers: hv: kvp: Fix two "this statement may fall through" warnings Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 16/22] ext4: fix argument checking in EXT4_IOC_MOVE_EXT Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 17/22] MD: fix invalid stored role for a disk Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 18/22] usb: chipidea: Prevent unbalanced IRQ disable Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 19/22] uio: ensure class is registered before devices Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 20/22] scsi: lpfc: Correct soft lockup when running mds diagnostics Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 21/22] signal: Always deliver the kernel's SIGKILL and SIGSTOP to a pid namespace init Sasha Levin
2018-10-31 23:12 ` [PATCH AUTOSEL 3.18 22/22] mfd: menelaus: Fix possible race condition and leak Sasha Levin
2018-11-01  0:27   ` Alexandre Belloni
2018-11-01  1:29     ` Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.