/[packages]/cauldron/kernel/current/PATCHES/patches/0004-locking-lockdep-Fix-debug_locks-off-performance-prob.patch
ViewVC logotype

Contents of /cauldron/kernel/current/PATCHES/patches/0004-locking-lockdep-Fix-debug_locks-off-performance-prob.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1329221 - (show annotations) (download)
Fri Nov 9 22:05:45 2018 UTC (5 years, 10 months ago) by tmb
File size: 3046 byte(s)
add fixes from sashas autosel queue
1 From f707470b0622333c42926ac322c72c3f1786d20b Mon Sep 17 00:00:00 2001
2 From: Waiman Long <longman@redhat.com>
3 Date: Thu, 18 Oct 2018 21:45:17 -0400
4 Subject: [PATCH 004/145] locking/lockdep: Fix debug_locks off performance
5 problem
6
7 [ Upstream commit 9506a7425b094d2f1d9c877ed5a78f416669269b ]
8
9 It was found that when debug_locks was turned off because of a problem
10 found by the lockdep code, the system performance could drop quite
11 significantly when the lock_stat code was also configured into the
12 kernel. For instance, parallel kernel build time on a 4-socket x86-64
13 server nearly doubled.
14
15 Further analysis into the cause of the slowdown traced back to the
16 frequent call to debug_locks_off() from the __lock_acquired() function
17 probably due to some inconsistent lockdep states with debug_locks
18 off. The debug_locks_off() function did an unconditional atomic xchg
19 to write a 0 value into debug_locks which had already been set to 0.
20 This led to severe cacheline contention in the cacheline that held
21 debug_locks. As debug_locks is being referenced in quite a few different
22 places in the kernel, this greatly slow down the system performance.
23
24 To prevent that trashing of debug_locks cacheline, lock_acquired()
25 and lock_contended() now checks the state of debug_locks before
26 proceeding. The debug_locks_off() function is also modified to check
27 debug_locks before calling __debug_locks_off().
28
29 Signed-off-by: Waiman Long <longman@redhat.com>
30 Cc: Andrew Morton <akpm@linux-foundation.org>
31 Cc: Linus Torvalds <torvalds@linux-foundation.org>
32 Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
33 Cc: Peter Zijlstra <peterz@infradead.org>
34 Cc: Thomas Gleixner <tglx@linutronix.de>
35 Cc: Will Deacon <will.deacon@arm.com>
36 Link: http://lkml.kernel.org/r/1539913518-15598-1-git-send-email-longman@redhat.com
37 Signed-off-by: Ingo Molnar <mingo@kernel.org>
38 Signed-off-by: Sasha Levin <sashal@kernel.org>
39 ---
40 kernel/locking/lockdep.c | 4 ++--
41 lib/debug_locks.c | 2 +-
42 2 files changed, 3 insertions(+), 3 deletions(-)
43
44 diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
45 index dd13f865ad40..26b57e24476f 100644
46 --- a/kernel/locking/lockdep.c
47 +++ b/kernel/locking/lockdep.c
48 @@ -4122,7 +4122,7 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)
49 {
50 unsigned long flags;
51
52 - if (unlikely(!lock_stat))
53 + if (unlikely(!lock_stat || !debug_locks))
54 return;
55
56 if (unlikely(current->lockdep_recursion))
57 @@ -4142,7 +4142,7 @@ void lock_acquired(struct lockdep_map *lock, unsigned long ip)
58 {
59 unsigned long flags;
60
61 - if (unlikely(!lock_stat))
62 + if (unlikely(!lock_stat || !debug_locks))
63 return;
64
65 if (unlikely(current->lockdep_recursion))
66 diff --git a/lib/debug_locks.c b/lib/debug_locks.c
67 index 96c4c633d95e..124fdf238b3d 100644
68 --- a/lib/debug_locks.c
69 +++ b/lib/debug_locks.c
70 @@ -37,7 +37,7 @@ EXPORT_SYMBOL_GPL(debug_locks_silent);
71 */
72 int debug_locks_off(void)
73 {
74 - if (__debug_locks_off()) {
75 + if (debug_locks && __debug_locks_off()) {
76 if (!debug_locks_silent) {
77 console_verbose();
78 return 1;
79 --
80 2.19.1
81

  ViewVC Help
Powered by ViewVC 1.1.30