From: Byungchul Park <byungchul.park@lge.com>
To: akpm@linux-foundation.org, mingo@kernel.org
Cc: linux-kernel@vger.kernel.org, akinobu.mita@gmail.com,
jack@suse.cz, sergey.senozhatsky.work@gmail.com,
peter@hurleysoftware.com, tglx@linutronix.de,
peterz@infradead.org, rostedt@goodmis.org
Subject: [PATCH] lib/spinlock_debug: Prevent a unnecessary recursive spin_dump()
Date: Fri, 18 Mar 2016 14:55:05 +0900 [thread overview]
Message-ID: <20160318055505.GO5220@X58A-UD3R> (raw)
In-Reply-To: <1457692627-14076-1-git-send-email-byungchul.park@lge.com>
This can protect an infinit recursion by unnecessary warning, too.
-----8<-----
>From 81f06a6f9c7f2e782267a2539c6c869d4214354c Mon Sep 17 00:00:00 2001
From: Byungchul Park <byungchul.park@lge.com>
Date: Fri, 18 Mar 2016 11:35:24 +0900
Subject: [PATCH] lib/spinlock_debug: Prevent a unnecessary recursive
spin_dump()
Printing "lockup suspected" for the same lock more than once is
meaningless. Furtheremore, it can cause an infinite recursion if it's
on the way printing something by printk().
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
kernel/locking/spinlock_debug.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/kernel/locking/spinlock_debug.c b/kernel/locking/spinlock_debug.c
index fd24588..30559c6 100644
--- a/kernel/locking/spinlock_debug.c
+++ b/kernel/locking/spinlock_debug.c
@@ -138,14 +138,25 @@ static void __spin_lock_debug(raw_spinlock_t *lock)
{
u64 i;
u64 loops = loops_per_jiffy * HZ;
+ static raw_spinlock_t *suspected_lock = NULL;
for (i = 0; i < loops; i++) {
if (arch_spin_trylock(&lock->raw_lock))
return;
__delay(1);
}
- /* lockup suspected: */
- spin_dump(lock, "lockup suspected");
+
+ /*
+ * When we suspect a lockup, it's good enough to inform it once for
+ * the same lock. Otherwise it could cause an infinite recursion if
+ * it's within printk().
+ */
+ if (suspected_lock != lock) {
+ suspected_lock = lock;
+ /* lockup suspected: */
+ spin_dump(lock, "lockup suspected");
+ suspected_lock = NULL;
+ }
#ifdef CONFIG_SMP
trigger_all_cpu_backtrace();
#endif
--
1.9.1
prev parent reply other threads:[~2016-03-18 5:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-11 10:37 [PATCH v6 0/2] Make printing of spin_dump() deferred to avoid a deadlock Byungchul Park
2016-03-11 10:37 ` [PATCH v6 1/2] printk: Factor out buffering and irq work queuing in printk_deferred Byungchul Park
2016-03-14 1:21 ` Sergey Senozhatsky
2016-03-14 4:45 ` Byungchul Park
2016-03-11 10:37 ` [PATCH v6 2/2] printk: Make printing of spin_dump() deferred to avoid a deadlock Byungchul Park
2016-03-14 1:37 ` Sergey Senozhatsky
2016-03-14 2:30 ` Byungchul Park
2016-03-14 2:40 ` Sergey Senozhatsky
2016-03-14 4:17 ` Byungchul Park
2016-03-16 2:06 ` Byungchul Park
2016-03-18 5:55 ` Byungchul Park [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160318055505.GO5220@X58A-UD3R \
--to=byungchul.park@lge.com \
--cc=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peter@hurleysoftware.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome