public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [tip:core/urgent] lockdep: Fix wrong assumption in match_held_lock
       [not found] <1312547787.28695.2.camel@twins>
@ 2011-08-09 14:30 ` tip-bot for Peter Zijlstra
  2011-08-10  2:58   ` Yong Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: tip-bot for Peter Zijlstra @ 2011-08-09 14:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, sergey.senozhatsky, tglx,
	mingo

Commit-ID:  80e0401e35410a69bfae05b454db8a7187edd6b8
Gitweb:     http://git.kernel.org/tip/80e0401e35410a69bfae05b454db8a7187edd6b8
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Fri, 5 Aug 2011 14:26:17 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 9 Aug 2011 11:57:35 +0200

lockdep: Fix wrong assumption in match_held_lock

match_held_lock() was assuming it was being called on a lock class
that had already seen usage.

This condition was true for bug-free code using lockdep_assert_held(),
since you're in fact holding the lock when calling it. However the
assumption fails the moment you assume the assertion can fail, which
is the whole point of having the assertion in the first place.

Anyway, now that there's more lockdep_is_held() users, notably
__rcu_dereference_check(), its much easier to trigger this since we
test for a number of locks and we only need to hold any one of them to
be good.

Reported-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1312547787.28695.2.camel@twins
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/lockdep.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 8c24294..91d67ce 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -3111,7 +3111,13 @@ static int match_held_lock(struct held_lock *hlock, struct lockdep_map *lock)
 		if (!class)
 			class = look_up_lock_class(lock, 0);
 
-		if (DEBUG_LOCKS_WARN_ON(!class))
+		/*
+		 * If look_up_lock_class() failed to find a class, we're trying
+		 * to test if we hold a lock that has never yet been acquired.
+		 * Clearly if the lock hasn't been acquired _ever_, we're not
+		 * holding it either, so report failure.
+		 */
+		if (!class)
 			return 0;
 
 		if (DEBUG_LOCKS_WARN_ON(!hlock->nest_lock))

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [tip:core/urgent] lockdep: Fix wrong assumption in match_held_lock
  2011-08-09 14:30 ` [tip:core/urgent] lockdep: Fix wrong assumption in match_held_lock tip-bot for Peter Zijlstra
@ 2011-08-10  2:58   ` Yong Zhang
  2011-08-10 10:01     ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Yong Zhang @ 2011-08-10  2:58 UTC (permalink / raw)
  To: mingo, hpa, linux-kernel, a.p.zijlstra, sergey.senozhatsky, tglx,
	mingo
  Cc: linux-tip-commits

On Tue, Aug 09, 2011 at 02:30:02PM +0000, tip-bot for Peter Zijlstra wrote:
> Commit-ID:  80e0401e35410a69bfae05b454db8a7187edd6b8
> Gitweb:     http://git.kernel.org/tip/80e0401e35410a69bfae05b454db8a7187edd6b8
> Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
> AuthorDate: Fri, 5 Aug 2011 14:26:17 +0200
> Committer:  Ingo Molnar <mingo@elte.hu>
> CommitDate: Tue, 9 Aug 2011 11:57:35 +0200
> 
> lockdep: Fix wrong assumption in match_held_lock
> 
> match_held_lock() was assuming it was being called on a lock class
> that had already seen usage.
> 
> This condition was true for bug-free code using lockdep_assert_held(),
> since you're in fact holding the lock when calling it. However the
> assumption fails the moment you assume the assertion can fail, which
> is the whole point of having the assertion in the first place.
> 
> Anyway, now that there's more lockdep_is_held() users, notably
> __rcu_dereference_check(), its much easier to trigger this since we
> test for a number of locks and we only need to hold any one of them to
> be good.
> 
> Reported-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Link: http://lkml.kernel.org/r/1312547787.28695.2.camel@twins

BTW, I can't open this link.

Thanks,
Yong


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [tip:core/urgent] lockdep: Fix wrong assumption in match_held_lock
  2011-08-10  2:58   ` Yong Zhang
@ 2011-08-10 10:01     ` Peter Zijlstra
  2011-08-10 11:45       ` Yong Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2011-08-10 10:01 UTC (permalink / raw)
  To: Yong Zhang
  Cc: mingo, hpa, linux-kernel, sergey.senozhatsky, tglx, mingo,
	linux-tip-commits

On Wed, 2011-08-10 at 10:58 +0800, Yong Zhang wrote:

> > Link: http://lkml.kernel.org/r/1312547787.28695.2.camel@twins
> 
> BTW, I can't open this link.

Gah! I did mess that up, but I've no idea how though, I usually
copy/paste or let my script do it, in case of copy/paste one would
assume I picked the wrong msg, but a grep through my sent folder doesn't
find any email with that msgid.. and my script isn't imaginative enough
to  just make one up like that. Anyway:

  lkml.kernel.org/r/1312969382.23148.1.camel@twins

should be the actual link, however that doesn't appear to work either,
included the relevant headers of the actual email:

---

Subject: Re: select_task_rq_fair: WARNING: at kernel/lockdep.c match_held_lock
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>, 
 Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org,
 KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>, linux-mm@kvack.org
Date: Fri, 05 Aug 2011 14:36:20 +0200
In-Reply-To: <20110804155347.GB3562@swordfish.minsk.epam.com>
References: <20110804141306.GA3536@swordfish.minsk.epam.com>
         <1312470358.16729.25.camel@twins>
         <20110804153752.GA3562@swordfish.minsk.epam.com>
         <1312472867.16729.38.camel@twins>
         <20110804155347.GB3562@swordfish.minsk.epam.com>

Message-ID: <1312969382.23148.1.camel@twins>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [tip:core/urgent] lockdep: Fix wrong assumption in match_held_lock
  2011-08-10 10:01     ` Peter Zijlstra
@ 2011-08-10 11:45       ` Yong Zhang
  2011-08-10 11:48         ` Yong Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: Yong Zhang @ 2011-08-10 11:45 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, hpa, linux-kernel, sergey.senozhatsky, tglx, mingo,
	linux-tip-commits

On Wed, Aug 10, 2011 at 12:01:10PM +0200, Peter Zijlstra wrote:
> On Wed, 2011-08-10 at 10:58 +0800, Yong Zhang wrote:
> 
> > > Link: http://lkml.kernel.org/r/1312547787.28695.2.camel@twins
> > 
> > BTW, I can't open this link.
> 
> Gah! I did mess that up, but I've no idea how though, I usually
> copy/paste or let my script do it, in case of copy/paste one would
> assume I picked the wrong msg, but a grep through my sent folder doesn't
> find any email with that msgid.. and my script isn't imaginative enough
> to  just make one up like that. Anyway:
> 
>   lkml.kernel.org/r/1312969382.23148.1.camel@twins
> 
> should be the actual link, however that doesn't appear to work either,
> included the relevant headers of the actual email:
> 
> ---
> 
> Subject: Re: select_task_rq_fair: WARNING: at kernel/lockdep.c match_held_lock
> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>, 
>  Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org,
>  KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>, linux-mm@kvack.org
> Date: Fri, 05 Aug 2011 14:36:20 +0200
> In-Reply-To: <20110804155347.GB3562@swordfish.minsk.epam.com>
> References: <20110804141306.GA3536@swordfish.minsk.epam.com>
>          <1312470358.16729.25.camel@twins>
>          <20110804153752.GA3562@swordfish.minsk.epam.com>
>          <1312472867.16729.38.camel@twins>
>          <20110804155347.GB3562@swordfish.minsk.epam.com>
> 
> Message-ID: <1312969382.23148.1.camel@twins>

The actual one showed in maillist is like below:
---
Subject: Re: select_task_rq_fair: WARNING: at kernel/lockdep.c
 match_held_lock
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
        Andrew Morton <akpm@linux-foundation.org>,
        linux-kernel@vger.kernel.org,
        KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
        linux-mm@kvack.org
Date: Fri, 05 Aug 2011 14:36:20 +0200
In-Reply-To: <20110804155347.GB3562@swordfish.minsk.epam.com>
References: <20110804141306.GA3536@swordfish.minsk.epam.com>
         <1312470358.16729.25.camel@twins>
         <20110804153752.GA3562@swordfish.minsk.epam.com>
         <1312472867.16729.38.camel@twins>
         <20110804155347.GB3562@swordfish.minsk.epam.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8BIT
X-Mailer: Evolution 3.0.2- 
Message-ID: <1312547780.28695.1.camel@twins>
---

Not sure how the difference happens.

Thanks,
Yong

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [tip:core/urgent] lockdep: Fix wrong assumption in match_held_lock
  2011-08-10 11:45       ` Yong Zhang
@ 2011-08-10 11:48         ` Yong Zhang
  0 siblings, 0 replies; 5+ messages in thread
From: Yong Zhang @ 2011-08-10 11:48 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, hpa, linux-kernel, sergey.senozhatsky, tglx, mingo,
	linux-tip-commits

On Wed, Aug 10, 2011 at 07:45:50PM +0800, Yong Zhang wrote:
> On Wed, Aug 10, 2011 at 12:01:10PM +0200, Peter Zijlstra wrote:
> > On Wed, 2011-08-10 at 10:58 +0800, Yong Zhang wrote:
> > 
> > > > Link: http://lkml.kernel.org/r/1312547787.28695.2.camel@twins
> > > 
> > > BTW, I can't open this link.
> > 
> > Gah! I did mess that up, but I've no idea how though, I usually
> > copy/paste or let my script do it, in case of copy/paste one would
> > assume I picked the wrong msg, but a grep through my sent folder doesn't
> > find any email with that msgid.. and my script isn't imaginative enough
> > to  just make one up like that. Anyway:
> > 
> >   lkml.kernel.org/r/1312969382.23148.1.camel@twins
> > 
> > should be the actual link, however that doesn't appear to work either,
> > included the relevant headers of the actual email:
> > 
> > ---
> > 
> > Subject: Re: select_task_rq_fair: WARNING: at kernel/lockdep.c match_held_lock
> > From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> > Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>, 
> >  Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org,
> >  KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>, linux-mm@kvack.org
> > Date: Fri, 05 Aug 2011 14:36:20 +0200
> > In-Reply-To: <20110804155347.GB3562@swordfish.minsk.epam.com>
> > References: <20110804141306.GA3536@swordfish.minsk.epam.com>
> >          <1312470358.16729.25.camel@twins>
> >          <20110804153752.GA3562@swordfish.minsk.epam.com>
> >          <1312472867.16729.38.camel@twins>
> >          <20110804155347.GB3562@swordfish.minsk.epam.com>
> > 
> > Message-ID: <1312969382.23148.1.camel@twins>
> 
> The actual one showed in maillist is like below:

Hmm, you have mentioned it :)

> ---
> Subject: Re: select_task_rq_fair: WARNING: at kernel/lockdep.c
>  match_held_lock
> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
>         Andrew Morton <akpm@linux-foundation.org>,
>         linux-kernel@vger.kernel.org,
>         KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
>         linux-mm@kvack.org
> Date: Fri, 05 Aug 2011 14:36:20 +0200
> In-Reply-To: <20110804155347.GB3562@swordfish.minsk.epam.com>
> References: <20110804141306.GA3536@swordfish.minsk.epam.com>
>          <1312470358.16729.25.camel@twins>
>          <20110804153752.GA3562@swordfish.minsk.epam.com>
>          <1312472867.16729.38.camel@twins>
>          <20110804155347.GB3562@swordfish.minsk.epam.com>
> Content-Type: text/plain; charset="UTF-8"
> Content-Transfer-Encoding: 8BIT
> X-Mailer: Evolution 3.0.2- 
> Message-ID: <1312547780.28695.1.camel@twins>
> ---
> 
> Not sure how the difference happens.
> 
> Thanks,
> Yong

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-10 11:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1312547787.28695.2.camel@twins>
2011-08-09 14:30 ` [tip:core/urgent] lockdep: Fix wrong assumption in match_held_lock tip-bot for Peter Zijlstra
2011-08-10  2:58   ` Yong Zhang
2011-08-10 10:01     ` Peter Zijlstra
2011-08-10 11:45       ` Yong Zhang
2011-08-10 11:48         ` Yong Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox