Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1360350

[PATCH] lib/spinlock_debug: Prevent a unnecessary recursive spin_dump()

From Byungchul Park <byungchul.park@lge.com>
Newsgroups linux.kernel
Subject [PATCH] lib/spinlock_debug: Prevent a unnecessary recursive spin_dump()
Date 2016-03-18 07:00 +0100
Message-ID <rdVC1-1o4-1@gated-at.bofh.it> (permalink)
References <rbsE9-4Ih-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v6 0/2] Make printing of spin_dump() deferred to avoid a deadlock Byungchul Park <byungchul.park@lge.com> - 2016-03-11 11:40 +0100
  [PATCH v6 2/2] printk: Make printing of spin_dump() deferred to avoid a deadlock Byungchul Park <byungchul.park@lge.com> - 2016-03-11 11:40 +0100
    Re: [PATCH v6 2/2] printk: Make printing of spin_dump() deferred to  avoid a deadlock Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-03-14 02:40 +0100
      Re: [PATCH v6 2/2] printk: Make printing of spin_dump() deferred to  avoid a deadlock Byungchul Park <byungchul.park@lge.com> - 2016-03-14 03:40 +0100
        Re: [PATCH v6 2/2] printk: Make printing of spin_dump() deferred to  avoid a deadlock Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-03-14 03:40 +0100
          Re: [PATCH v6 2/2] printk: Make printing of spin_dump() deferred to  avoid a deadlock Byungchul Park <byungchul.park@lge.com> - 2016-03-14 05:20 +0100
            Re: [PATCH v6 2/2] printk: Make printing of spin_dump() deferred to  avoid a deadlock Byungchul Park <byungchul.park@lge.com> - 2016-03-16 03:10 +0100
  [PATCH v6 1/2] printk: Factor out buffering and irq work queuing in printk_deferred Byungchul Park <byungchul.park@lge.com> - 2016-03-11 11:40 +0100
    Re: [PATCH v6 1/2] printk: Factor out buffering and irq work queuing  in printk_deferred Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-03-14 02:30 +0100
      Re: [PATCH v6 1/2] printk: Factor out buffering and irq work queuing  in printk_deferred Byungchul Park <byungchul.park@lge.com> - 2016-03-14 05:50 +0100
  [PATCH] lib/spinlock_debug: Prevent a unnecessary recursive  spin_dump() Byungchul Park <byungchul.park@lge.com> - 2016-03-18 07:00 +0100

csiph-web