linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Johannes Berg <johannes@sipsolutions.net>,
	Ingo Molnar <mingo@elte.hu>,
	Zdenek Kabelac <zdenek.kabelac@gmail.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: INFO: possible circular locking dependency at cleanup_workqueue_thread
Date: Mon, 18 May 2009 22:00:57 +0200	[thread overview]
Message-ID: <1242676857.32543.1343.camel@laptop> (raw)
In-Reply-To: <20090518194749.GA3501@redhat.com>

On Mon, 2009-05-18 at 21:47 +0200, Oleg Nesterov wrote:
> On 05/17, Johannes Berg wrote:
> >
> > I'm not entirely sure yet, but I would think the problem might be a
> > false positive in the workqueue code -- remember this report only
> > triggers because cleanup_workqueue_thread() acquires the fake lock for
> > the workqueue.
> 
> I spent a lot of time, but I can't explain this report too :( Even
> if it is false positive, I don't understand why lockdep complains.
> 
> > Maybe it shouldn't do that from the CPU_POST_DEAD
> > notifier?
> 
> Well, in any case we should understand why we have the problem, before
> changing the code. And CPU_POST_DEAD is not special, why should we treat
> it specially and skip lock_map_acquire(wq->lockdep_map) ?
> 
> 
> But, I am starting to suspect we have some problems with lockdep too.
> OK, I can't explain what I mean... But consider this code:
> 
> 	DEFINE_SPINLOCK(Z);
> 	DEFINE_SPINLOCK(L1);
> 	DEFINE_SPINLOCK(L2);
> 
> 	#define L(l)	spin_lock(&l)
> 	#define U(l)	spin_unlock(&l)
> 
> 	void t1(void)
> 	{
> 		L(L1);
> 		L(L2);
> 
> 		U(L2);
> 		U(L1);
> 	}

(1) L1 -> L2  

> 	void t2(void)
> 	{
> 		L(L2);
> 			L(Z);

(2) L2 -> Z

> 		L(L1);

(3) Z -> L1

> 		U(L1);
> 			U(Z);
> 		U(L2);
> 	}
> 
> 	void tst(void)
> 	{
> 		t1();
> 		t2();
> 	}
> 
> We have the trivial AB-BA deadlock with L1 and L2, but lockdep says:
> 
> 	[ INFO: possible circular locking dependency detected ]
> 	2.6.30-rc6-00043-g22ef37e-dirty #3
> 	-------------------------------------------------------
> 	perl/676 is trying to acquire lock:
> 	 (L1){+.+...}, at: [<ffffffff802522b8>] t2+0x28/0x50
> 
> 	but task is already holding lock:
> 	 (Z){+.+...}, at: [<ffffffff802522ac>] t2+0x1c/0x50
> 
> 	which lock already depends on the new lock.
> 
> 
> 	the existing dependency chain (in reverse order) is:
> 
> 	-> #2 (Z){+.+...}:
> 
> 	-> #1 (L2){+.+...}:
> 
> 	-> #0 (L1){+.+...}:
> 
> 	other info that might help us debug this:
> 
> 	2 locks held by perl/676:
> 	 #0:  (L2){+.+...}, at: [<ffffffff802522a0>] t2+0x10/0x50
> 	 #1:  (Z){+.+...}, at: [<ffffffff802522ac>] t2+0x1c/0x50
> 
> This output looks obviously wrong, Z does not depend on L1 or any
> other lock.

It does, L1 -> L2 -> Z as per 1 and 2
which 3 obviously reverses.


  reply	other threads:[~2009-05-18 20:01 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-12  7:59 INFO: possible circular locking dependency at cleanup_workqueue_thread Zdenek Kabelac
2009-05-17  7:18 ` Ingo Molnar
2009-05-17 10:42   ` Ming Lei
2009-05-17 11:18   ` Johannes Berg
2009-05-17 13:10     ` Ingo Molnar
2009-05-18 19:47     ` Oleg Nesterov
2009-05-18 20:00       ` Peter Zijlstra [this message]
2009-05-18 20:16         ` Oleg Nesterov
2009-05-18 20:40           ` Peter Zijlstra
2009-05-18 22:14             ` Oleg Nesterov
2009-05-19  9:13               ` Peter Zijlstra
2009-05-19 10:49                 ` Peter Zijlstra
2009-05-19 14:53                   ` Oleg Nesterov
2009-05-19  8:51       ` Johannes Berg
2009-05-19 12:00         ` Oleg Nesterov
2009-05-19 15:33           ` Johannes Berg
2009-05-19 16:09             ` Oleg Nesterov
2009-05-19 16:27               ` Johannes Berg
2009-05-19 18:51                 ` Oleg Nesterov
2009-05-22 10:46                   ` Johannes Berg
2009-05-22 22:23                     ` Rafael J. Wysocki
2009-05-23  8:21                       ` Johannes Berg
2009-05-23 23:20                         ` Rafael J. Wysocki
2009-05-24  3:29                           ` Ming Lei
2009-05-24 11:09                             ` Rafael J. Wysocki
2009-05-24 12:48                               ` Ming Lei
2009-05-24 19:09                                 ` Rafael J. Wysocki
2009-05-24 14:30                           ` Alan Stern
2009-05-24 19:06                             ` Rafael J. Wysocki
2009-05-20  3:36             ` Ming Lei
2009-05-20  6:47               ` Johannes Berg
2009-05-20  7:09                 ` Ming Lei
2009-05-20  7:12                   ` Johannes Berg
2009-05-20  8:21                     ` Ming Lei
2009-05-20  8:45                       ` Johannes Berg
2009-05-22  8:03                 ` Ming Lei
2009-05-22  8:11                   ` Johannes Berg
2009-05-20 12:18   ` Peter Zijlstra
2009-05-20 13:18     ` Oleg Nesterov
2009-05-20 13:44       ` Peter Zijlstra
2009-05-20 13:55         ` Oleg Nesterov
2009-05-20 14:12           ` Peter Zijlstra
2009-05-24 18:58 ` 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=1242676857.32543.1343.camel@laptop \
    --to=a.p.zijlstra@chello.nl \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=rjw@sisk.pl \
    --cc=zdenek.kabelac@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).