public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>, Nick Piggin <npiggin@suse.de>,
	"lkml," <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] lockdep: fix deadlock in lockdep_trace_alloc
Date: Fri, 20 Mar 2009 15:00:10 +0100	[thread overview]
Message-ID: <20090320150010.054fa8fc@osiris.boeblingen.de.ibm.com> (raw)
In-Reply-To: <1237556700.24626.100.camel@twins>

On Fri, 20 Mar 2009 14:45:00 +0100
Peter Zijlstra <peterz@infradead.org> wrote:
> Subject: lockdep: fix deadlock in lockdep_trace_alloc
> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Date: Fri Mar 20 11:24:21 CET 2009
> 
> Heiko reported that we grab the graph lock with irqs enabled.
> 
> Fix this by providing 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>
> ---
>  kernel/lockdep.c |   21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6/kernel/lockdep.c
> ===================================================================
> --- linux-2.6.orig/kernel/lockdep.c
> +++ linux-2.6/kernel/lockdep.c
> @@ -2258,7 +2258,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, unsigned long flags)
>  {
>  	struct task_struct *curr = current;
> 
> @@ -2277,12 +2277,29 @@ void lockdep_trace_alloc(gfp_t gfp_mask)
>  	if (!(gfp_mask & __GFP_FS))
>  		return;
> 
> -	if (DEBUG_LOCKS_WARN_ON(irqs_disabled()))
> +	if (DEBUG_LOCKS_WARN_ON(raw_irqs_disabled_flags(flags)))
>  		return;
> 
>  	mark_held_locks(curr, RECLAIM_FS);
>  }
> 
> +static void check_flags(unsigned long flags);
> +
> +void lockdep_trace_alloc(gfp_t gfp_mask)
> +{
> +	unsigned long flags;
> +
> +	if (unlikely(current->lockdep_recursion))
> +		return;
> +
> +	raw_local_irq_save(flags);
> +	check_flags(flags);
> +	current->lockdep_recursion = 1;
> +	__lockdep_trace_alloc(gfp_mask, flags);
> +	current->lockdep_recursion = 0;
> +	raw_local_irq_restore(flags);
> +}
> +

This one works ;)

Tested-by: Heiko Carstens <heiko.carstens@de.ibm.com>

  reply	other threads:[~2009-03-20 14:00 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 [this message]
2009-03-20 10:26 ` [tip:core/locking] " Peter Zijlstra
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=20090320150010.054fa8fc@osiris.boeblingen.de.ibm.com \
    --to=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=npiggin@suse.de \
    --cc=peterz@infradead.org \
    /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