diff options
author | Kevin Hao <haokexin@gmail.com> | 2019-11-06 00:16:57 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-11-06 11:47:50 -0500 |
commit | 5cbf2fff3bba8d3c6a4d47c1754de1cf57e2b01f (patch) | |
tree | 25bc30bf2caa8885f914a052558a8b2b62257ab4 /lib/dump_stack.c | |
parent | a31631302abce4c80913d4dc741c4a6b07969b0e (diff) |
dump_stack: avoid the livelock of the dump_lock
In the current code, we use the atomic_cmpxchg() to serialize the output
of the dump_stack(), but this implementation suffers the thundering herd
problem. We have observed such kind of livelock on a Marvell cn96xx
board(24 cpus) when heavily using the dump_stack() in a kprobe handler.
Actually we can let the competitors to wait for the releasing of the
lock before jumping to atomic_cmpxchg(). This will definitely mitigate
the thundering herd problem. Thanks Linus for the suggestion.
[akpm@linux-foundation.org: fix comment]
Link: http://lkml.kernel.org/r/20191030031637.6025-1-haokexin@gmail.com
Fixes: b58d977432c8 ("dump_stack: serialize the output from dump_stack()")
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/dump_stack.c')
-rw-r--r-- | lib/dump_stack.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/dump_stack.c b/lib/dump_stack.c index 5cff72f18c4a..33ffbf308853 100644 --- a/lib/dump_stack.c +++ b/lib/dump_stack.c | |||
@@ -106,7 +106,12 @@ retry: | |||
106 | was_locked = 1; | 106 | was_locked = 1; |
107 | } else { | 107 | } else { |
108 | local_irq_restore(flags); | 108 | local_irq_restore(flags); |
109 | cpu_relax(); | 109 | /* |
110 | * Wait for the lock to release before jumping to | ||
111 | * atomic_cmpxchg() in order to mitigate the thundering herd | ||
112 | * problem. | ||
113 | */ | ||
114 | do { cpu_relax(); } while (atomic_read(&dump_lock) != -1); | ||
110 | goto retry; | 115 | goto retry; |
111 | } | 116 | } |
112 | 117 | ||