public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	a.p.zijlstra@chello.nl, peterz@infradead.org, npiggin@suse.de,
	heiko.carstens@de.ibm.com, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:core/locking] lockdep: fix deadlock in lockdep_trace_alloc
Date: Fri, 20 Mar 2009 10:26:53 GMT	[thread overview]
Message-ID: <tip-b0992675bc7a5eca3c6a5eeea5ed680cec09c8e7@git.kernel.org> (raw)
In-Reply-To: <1237544000.24626.52.camel@twins>

Commit-ID:  b0992675bc7a5eca3c6a5eeea5ed680cec09c8e7
Gitweb:     http://git.kernel.org/tip/b0992675bc7a5eca3c6a5eeea5ed680cec09c8e7
Author:     Peter Zijlstra <peterz@infradead.org>
AuthorDate: Fri, 20 Mar 2009 11:13:20 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 20 Mar 2009 11:23:15 +0100

lockdep: fix deadlock in lockdep_trace_alloc

Heiko reported that we grab the graph lock with irqs enabled.

Fix this by providng the same wrapper as all other lockdep entry
functions have.

Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Nick Piggin <npiggin@suse.de>
LKML-Reference: <1237544000.24626.52.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 kernel/lockdep.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 77ac37f..c750038 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2257,7 +2257,7 @@ void trace_softirqs_off(unsigned long ip)
 		debug_atomic_inc(&redundant_softirqs_off);
 }
 
-void lockdep_trace_alloc(gfp_t gfp_mask)
+static void __lockdep_trace_alloc(gfp_t gfp_mask)
 {
 	struct task_struct *curr = current;
 
@@ -2282,6 +2282,20 @@ void lockdep_trace_alloc(gfp_t gfp_mask)
 	mark_held_locks(curr, RECLAIM_FS);
 }
 
+void lockdep_trace_alloc(gfp_t gfp_mask)
+{
+	unsigned long flags;
+
+	if (unlikely(current->lockdep_recursion))
+		return;
+
+	raw_local_irq_save(flags);
+	current->lockdep_recursion = 1;
+	__lockdep_trace_alloc(gfp_mask);
+	current->lockdep_recursion = 0;
+	raw_local_irq_restore(flags);
+}
+
 static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock)
 {
 	/*

  parent reply	other threads:[~2009-03-20 10:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-20 10:13 lockdep: fix deadlock in lockdep_trace_alloc Peter Zijlstra
2009-03-20 10:26 ` [PATCH] " Peter Zijlstra
2009-03-20 13:07   ` Heiko Carstens
2009-03-20 13:45     ` Peter Zijlstra
2009-03-20 14:00       ` Heiko Carstens
2009-03-20 10:26 ` Peter Zijlstra [this message]
2009-03-21 12:33   ` [PATCH] lockdep: fix deadlock in lockdep_trace_alloc -v2 Peter Zijlstra
2009-03-21 16:18     ` [tip:core/locking] lockdep: fix deadlock in lockdep_trace_alloc, take 2 Peter Zijlstra
2009-03-30 21:24 ` [tip:core/locking-v2] lockdep: fix deadlock in lockdep_trace_alloc Peter Zijlstra

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=tip-b0992675bc7a5eca3c6a5eeea5ed680cec09c8e7@git.kernel.org \
    --to=peterz@infradead.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=npiggin@suse.de \
    --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