Skip to contentSkip to conversation

LOCKDEP: minor fix for debug_show_all_locks()

PATCH Applied sniper 3 participants 4 messages Oct 27, 2008 – Oct 28, 2008

lore
Share & tools
lore

sniper

author
#0 lore raw

PATCH 1/1 LOCKDEP: minor fix for debug_show_all_locks()

When we failed to get tasklist_lock eventually (count equals 0), we should only print " ignoring it.\n", and not print " locked it.\n" needlessly.

---

kernel/lockdep.c +2 -0
index dbda475..12bf812 100644
@@ -3417,10 +3417,12 @@ retry:
 		}
 		printk(" ignoring it.\n");
 		unlock = 0;
+		goto print_locks;
 	}
 	if (count != 10)
 		printk(" locked it.\n");
 
+print_locks:
 	do_each_thread(g, p) {
 		/*
 		 * It's not reliable to print a task's held locks
#1 lore raw
Quoted 3 lines · sniper

When we failed to get tasklist_lock eventually (count equals 0), we should only print " ignoring it.\n", and not print " locked it.\n" needlessly.

well spotted!

Minor nit:

kernel/lockdep.c retry: · line 3426

Quoted 13 lines
kernel/lockdep.c +2 -0
@@ -3417,10 +3417,12 @@ retry:
 		}
 		printk(" ignoring it.\n");
 		unlock = 0;
+		goto print_locks;
 	}
 	if (count != 10)
 		printk(" locked it.\n");
 
+print_locks:
 	do_each_thread(g, p) {

please move the "if (count != 10)" line into the else section of the trylock, instead of introducing a label and a goto.

Ingo

#2 lore raw

When we failed to get tasklist_lock eventually (count equals 0), we should only print " ignoring it.\n", and not print " locked it.\n" needlessly.

---

kernel/lockdep.c +1 -2
index dbda475..6533fd9 100644
@@ -3417,8 +3417,7 @@ retry:
 		}
 		printk(" ignoring it.\n");
 		unlock = 0;
-	}
-	if (count != 10)
+	} else if (count != 10)
 		printk(" locked it.\n");
 
 	do_each_thread(g, p) {
Applied
#3 lore raw
Quoted 12 lines · qinghuang feng

When we failed to get tasklist_lock eventually (count equals 0), we should only print " ignoring it.\n", and not print " locked it.\n" needlessly.

---

kernel/lockdep.c +0 -0
index dbda475..6533fd9 100644

kernel/lockdep.c retry: · line 3422

Quoted 8 lines
kernel/lockdep.c +1 -2
@@ -3417,8 +3417,7 @@ retry:
 		}
 		printk(" ignoring it.\n");
 		unlock = 0;
-	}
-	if (count != 10)
+	} else if (count != 10)
 		printk(" locked it.\n");
 

applied to tip/core/urgent, thanks!

note that i've done two small tweaks to the patch:

- added curly braces to the else branch as well - the convention is to mirror the curly braces of the main branch in such cases.

- added KERN_CONT for the printk

Ingo

-------------->

Quoted 1 line

From 46fec7ac40e452a2ea5e63648d98b6bb2b5898f9 Mon Sep 17 00:00:00 2001

From: qinghuang feng <[email protected]>
Date: Tue, 28 Oct 2008 17:24:28 +0800
Subject: [PATCH] lockdep: minor fix for debug_show_all_locks()

When we failed to get tasklist_lock eventually (count equals 0), we should only print " ignoring it.\n", and not print " locked it.\n" needlessly.

---
 kernel/lockdep.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/lockdep.c +3 -2
index dbda475..11832ac 100644
@@ -3417,9 +3417,10 @@ retry:
 		}
 		printk(" ignoring it.\n");
 		unlock = 0;
+	} else {
+		if (count != 10)
+			printk(KERN_CONT " locked it.\n");
 	}
-	if (count != 10)
-		printk(" locked it.\n");
 
 	do_each_thread(g, p) {
 		/*