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


Groups > linux.kernel > #1539089

[PATCH v4 09/15] lockdep: Make print_circular_bug() crosslock-aware

From Byungchul Park <byungchul.park@lge.com>
Newsgroups linux.kernel
Subject [PATCH v4 09/15] lockdep: Make print_circular_bug() crosslock-aware
Date 2016-12-09 06:20 +0100
Message-ID <sMlLc-7BJ-19@gated-at.bofh.it> (permalink)
References <sMlLb-7BJ-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Friends of print_circular_bug() reporting circular bug assumes that
target hlock is owned by the current. However, in crossrelease feature,
target hlock can be owned by any context.

In this case, the circular bug is caused by target hlock which cannot be
released since its dependent lock cannot be released. So the report
format needs to be changed to be aware of this.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 kernel/locking/lockdep.c | 56 +++++++++++++++++++++++++++++++++---------------
 1 file changed, 39 insertions(+), 17 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index fbd07ee..cb1a600 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -1126,22 +1126,41 @@ print_circular_lock_scenario(struct held_lock *src,
 		printk("\n\n");
 	}
 
-	printk(" Possible unsafe locking scenario:\n\n");
-	printk("       CPU0                    CPU1\n");
-	printk("       ----                    ----\n");
-	printk("  lock(");
-	__print_lock_name(target);
-	printk(");\n");
-	printk("                               lock(");
-	__print_lock_name(parent);
-	printk(");\n");
-	printk("                               lock(");
-	__print_lock_name(target);
-	printk(");\n");
-	printk("  lock(");
-	__print_lock_name(source);
-	printk(");\n");
-	printk("\n *** DEADLOCK ***\n\n");
+	if (cross_class(target)) {
+		printk(" Possible unsafe locking scenario by crosslock:\n\n");
+		printk("       CPU0                    CPU1\n");
+		printk("       ----                    ----\n");
+		printk("  lock(");
+		__print_lock_name(parent);
+		printk(");\n");
+		printk("  lock(");
+		__print_lock_name(target);
+		printk(");\n");
+		printk("                               lock(");
+		__print_lock_name(source);
+		printk(");\n");
+		printk("                               unlock(");
+		__print_lock_name(target);
+		printk(");\n");
+		printk("\n *** DEADLOCK ***\n\n");
+	} else {
+		printk(" Possible unsafe locking scenario:\n\n");
+		printk("       CPU0                    CPU1\n");
+		printk("       ----                    ----\n");
+		printk("  lock(");
+		__print_lock_name(target);
+		printk(");\n");
+		printk("                               lock(");
+		__print_lock_name(parent);
+		printk(");\n");
+		printk("                               lock(");
+		__print_lock_name(target);
+		printk(");\n");
+		printk("  lock(");
+		__print_lock_name(source);
+		printk(");\n");
+		printk("\n *** DEADLOCK ***\n\n");
+	}
 }
 
 /*
@@ -1166,7 +1185,10 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth,
 	printk("%s/%d is trying to acquire lock:\n",
 		curr->comm, task_pid_nr(curr));
 	print_lock(check_src);
-	printk("\nbut task is already holding lock:\n");
+	if (cross_class(hlock_class(check_tgt)))
+		printk("\nbut now in the release context of lock:\n");
+	else
+		printk("\nbut task is already holding lock:\n");
 	print_lock(check_tgt);
 	printk("\nwhich lock already depends on the new lock.\n\n");
 	printk("\nthe existing dependency chain (in reverse order) is:\n");
-- 
1.9.1

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


Thread

[PATCH v4 00/15] lockdep: Implement crossrelease feature Byungchul Park <byungchul.park@lge.com> - 2016-12-09 06:20 +0100
  [PATCH v4 09/15] lockdep: Make print_circular_bug() crosslock-aware Byungchul Park <byungchul.park@lge.com> - 2016-12-09 06:20 +0100
  [PATCH v4 01/15] x86/dumpstack: Optimize save_stack_trace Byungchul Park <byungchul.park@lge.com> - 2016-12-09 06:20 +0100
  [PATCH v4 12/15] lockdep: Apply crossrelease to PG_locked lock Byungchul Park <byungchul.park@lge.com> - 2016-12-09 06:20 +0100
  [PATCH v4 08/15] lockdep: Make crossrelease use save_stack_trace_fast() Byungchul Park <byungchul.park@lge.com> - 2016-12-09 06:20 +0100
  [PATCH v4 06/15] lockdep: Make save_trace can skip stack tracing of the current Byungchul Park <byungchul.park@lge.com> - 2016-12-09 06:30 +0100
  [PATCH v4 03/15] lockdep: Refactor lookup_chain_cache() Byungchul Park <byungchul.park@lge.com> - 2016-12-09 06:30 +0100
  [PATCH v4 04/15] lockdep: Add a function building a chain between two classes Byungchul Park <byungchul.park@lge.com> - 2016-12-09 06:30 +0100

csiph-web