* [PATCH] Hibernation: Fix lockdep report (v2)
@ 2007-11-14 21:25 Rafael J. Wysocki
2007-11-14 22:42 ` Pavel Machek
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2007-11-14 21:25 UTC (permalink / raw)
To: Andrew Morton; +Cc: Johannes Berg, Peter Zijlstra, LKML, Pavel Machek, pm list
[Andrew, please consider this as 2.6.24 material, thanks.]
---
From: Johannes Berg <johannes@sipsolutions.net>
Lockdep reports a circular locking dependency in the hibernate code
because
- during system boot hibernate code (from an initcall) locks pm_mutex
and then a sysfs buffer mutex via name_to_dev_t
- during regular operation hibernate code locks pm_mutex under a
sysfs buffer mutex because it's called from sysfs methods.
The deadlock can never happen because during initcall invocation nothing
can write to sysfs yet. This removes the lockdep report by marking the
initcall locking as being in a different class.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
kernel/power/disk.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
Index: linux-2.6/kernel/power/disk.c
===================================================================
--- linux-2.6.orig/kernel/power/disk.c
+++ linux-2.6/kernel/power/disk.c
@@ -456,7 +456,17 @@ static int software_resume(void)
int error;
unsigned int flags;
- mutex_lock(&pm_mutex);
+ /*
+ * name_to_dev_t() below takes a sysfs buffer mutex when sysfs
+ * is configured into the kernel. Since the regular hibernate
+ * trigger path is via sysfs which takes a buffer mutex before
+ * calling hibernate functions (which take pm_mutex) this can
+ * cause lockdep to complain about a possible ABBA deadlock
+ * which cannot happen since we're in the boot code here and
+ * sysfs can't be invoked yet. Therefore, we use a subclass
+ * here to avoid lockdep complaining.
+ */
+ mutex_lock_nested(&pm_mutex, SINGLE_DEPTH_NESTING);
if (!swsusp_resume_device) {
if (!strlen(resume_file)) {
mutex_unlock(&pm_mutex);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Hibernation: Fix lockdep report (v2)
2007-11-14 22:42 ` Pavel Machek
@ 2007-11-14 21:54 ` Peter Zijlstra
0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2007-11-14 21:54 UTC (permalink / raw)
To: Pavel Machek
Cc: Rafael J. Wysocki, Andrew Morton, Johannes Berg, LKML, pm list
On Wed, 2007-11-14 at 22:42 +0000, Pavel Machek wrote:
> On Wed 2007-11-14 22:25:57, Rafael J. Wysocki wrote:
> > [Andrew, please consider this as 2.6.24 material, thanks.]
> > ---
> > From: Johannes Berg <johannes@sipsolutions.net>
> >
> > Lockdep reports a circular locking dependency in the hibernate code
> > because
> > - during system boot hibernate code (from an initcall) locks pm_mutex
> > and then a sysfs buffer mutex via name_to_dev_t
> > - during regular operation hibernate code locks pm_mutex under a
> > sysfs buffer mutex because it's called from sysfs methods.
> >
> > The deadlock can never happen because during initcall invocation nothing
> > can write to sysfs yet. This removes the lockdep report by marking the
> > initcall locking as being in a different class.
> >
> > Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
I guess mine got lost too :-)
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Cc: Pavel Machek <pavel@ucw.cz>
>
> ACK...
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Hibernation: Fix lockdep report (v2)
2007-11-14 21:25 [PATCH] Hibernation: Fix lockdep report (v2) Rafael J. Wysocki
@ 2007-11-14 22:42 ` Pavel Machek
2007-11-14 21:54 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2007-11-14 22:42 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Andrew Morton, Johannes Berg, Peter Zijlstra, LKML, pm list
On Wed 2007-11-14 22:25:57, Rafael J. Wysocki wrote:
> [Andrew, please consider this as 2.6.24 material, thanks.]
> ---
> From: Johannes Berg <johannes@sipsolutions.net>
>
> Lockdep reports a circular locking dependency in the hibernate code
> because
> - during system boot hibernate code (from an initcall) locks pm_mutex
> and then a sysfs buffer mutex via name_to_dev_t
> - during regular operation hibernate code locks pm_mutex under a
> sysfs buffer mutex because it's called from sysfs methods.
>
> The deadlock can never happen because during initcall invocation nothing
> can write to sysfs yet. This removes the lockdep report by marking the
> initcall locking as being in a different class.
>
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Pavel Machek <pavel@ucw.cz>
ACK...
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-14 21:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-14 21:25 [PATCH] Hibernation: Fix lockdep report (v2) Rafael J. Wysocki
2007-11-14 22:42 ` Pavel Machek
2007-11-14 21:54 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®