All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Ingo Molnar <mingo@elte.hu>,
	Zdenek Kabelac <zdenek.kabelac@gmail.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: INFO: possible circular locking dependency at cleanup_workqueue_thread
Date: Tue, 19 May 2009 20:51:40 +0200	[thread overview]
Message-ID: <20090519185140.GA32012@redhat.com> (raw)
In-Reply-To: <1242750470.4797.42.camel@johannes.local>

On 05/19, Johannes Berg wrote:
>
> On Tue, 2009-05-19 at 18:09 +0200, Oleg Nesterov wrote:
>
> > > Right. But exactly this happens in the hibernate case --
> >
> > not sure I understand your "exactly this" ;)
> >
> > But your explanation of the deadlock below looks great!
>
> Yeah... I got side-tracked, I had a scenario in mind that actually
> needed cpu_add_remove_lock().
>
> > except I don't understand how cpu_add_remove_lock makes the difference...
> > And thus I can't understand why cpu_down() (called lockless) have the
> > same problems. Please see below.
> >
> > > Anyway, you can have a deadlock like this:
> > >
> > > CPU 3			CPU 2				CPU 1
> > > 							suspend/hibernate
> > > 			something:
> > > 			rtnl_lock()			device_pm_lock()
> > > 							-> mutex_lock(&dpm_list_mtx)
> > >
> > > 			mutex_lock(&dpm_list_mtx)
> > >
> > > linkwatch_work
> > >  -> rtnl_lock()
> > > 							disable_nonboot_cpus()
> >
> > let's suppose disable_nonboot_cpus() does not take cpu_add_remove_lock,
> >
> > > 							-> flush CPU 3 workqueue
> >
> > in this case the deadlock is still here?
> >
> > We can't flush because we hold the lock (dpm_list_mtx) which depends
> > on another lock taken by work->func(), the "classical" bug with flush.
> >
> > No?
>
> Yeah, it looks like cpu_add_remove_lock doesn't make a difference...
> It's just lockdep reporting a longer chain that also leads to a
> deadlock.

So. we should not call cpu_down/disable_nonboot_cpus under device_pm_lock().

At first glance this was changed by

	PM: Change hibernation code ordering
	4aecd6718939eb3c4145b248369b65f7483a8a02

	PM: Change suspend code ordering
	900af0d973856d6feb6fc088c2d0d3fde57707d3

commits. Rafael, could you take a look?


> OTOH just replace dpm_list_mtx with cpu_add_remove_lock and
> you have the same scenario...

Yes, but

> happens too, I guess, somehow.

Oh, I hope not ;) nobody should use cpu_maps_update_begin() except
cpu_down/up pathes. And workqueue.c, which uses it exactly because
we want to call _cpu_down()->flush_cpu_workqueue() without any other
locks held. But if the caller of cpu_down() holds some lock, then
we have the usual problems with the flush under lock.

Oleg.


  reply	other threads:[~2009-05-19 18:56 UTC|newest]

Thread overview: 50+ 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
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 [this message]
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  3:29                             ` Ming Lei
2009-05-24 11:09                             ` Rafael J. Wysocki
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 19:09                                 ` Rafael J. Wysocki
2009-05-24 12:48                               ` Ming Lei
2009-05-24 14:30                           ` Alan Stern
2009-05-24 19:06                             ` Rafael J. Wysocki
2009-05-24 19:06                             ` Rafael J. Wysocki
2009-05-24 14:30                           ` Alan Stern
2009-05-23 23:20                         ` 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=20090519185140.GA32012@redhat.com \
    --to=oleg@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.