public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Hibernation: Fix lockdep report (v2)
@ 2007-11-04 13:59 Rafael J. Wysocki
  2007-11-04 18:38 ` Pavel Machek
  2007-11-13 18:45 ` Johannes Berg
  0 siblings, 2 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2007-11-04 13:59 UTC (permalink / raw)
  To: Len Brown; +Cc: Johannes Berg, Peter Zijlstra, pm list

[Len, please add this patch to the suspend branch, 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] 8+ messages in thread

* Re: [PATCH] Hibernation: Fix lockdep report (v2)
  2007-11-04 13:59 [PATCH] Hibernation: Fix lockdep report (v2) Rafael J. Wysocki
@ 2007-11-04 18:38 ` Pavel Machek
  2007-11-13 18:45 ` Johannes Berg
  1 sibling, 0 replies; 8+ messages in thread
From: Pavel Machek @ 2007-11-04 18:38 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Johannes Berg, Peter Zijlstra, pm list

On Sun 2007-11-04 14:59:22, Rafael J. Wysocki wrote:
> [Len, please add this patch to the suspend branch, 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>

ACK.
								Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [PATCH] Hibernation: Fix lockdep report (v2)
  2007-11-04 13:59 [PATCH] Hibernation: Fix lockdep report (v2) Rafael J. Wysocki
  2007-11-04 18:38 ` Pavel Machek
@ 2007-11-13 18:45 ` Johannes Berg
  2007-11-14 12:52   ` Peter Zijlstra
  2007-11-14 13:11   ` Rafael J. Wysocki
  1 sibling, 2 replies; 8+ messages in thread
From: Johannes Berg @ 2007-11-13 18:45 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: pm list, Peter Zijlstra


[-- Attachment #1.1: Type: text/plain, Size: 646 bytes --]


On Sun, 2007-11-04 at 14:59 +0100, Rafael J. Wysocki wrote:
> [Len, please add this patch to the suspend branch, 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.

Ping? Do I need to follow this or will somebody take care to merge it
before .24 closes?

Thanks,
Johannes

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] Hibernation: Fix lockdep report (v2)
  2007-11-13 18:45 ` Johannes Berg
@ 2007-11-14 12:52   ` Peter Zijlstra
  2007-11-14 13:11   ` Rafael J. Wysocki
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Zijlstra @ 2007-11-14 12:52 UTC (permalink / raw)
  To: Johannes Berg; +Cc: pm list


[-- Attachment #1.1: Type: text/plain, Size: 799 bytes --]


On Tue, 2007-11-13 at 19:45 +0100, Johannes Berg wrote:
> On Sun, 2007-11-04 at 14:59 +0100, Rafael J. Wysocki wrote:
> > [Len, please add this patch to the suspend branch, 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.
> 
> Ping? Do I need to follow this or will somebody take care to merge it
> before .24 closes?

I can feed it to Linus through the lockdep tree if Len hasn't picked it
up yet, Len?

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] Hibernation: Fix lockdep report (v2)
  2007-11-13 18:45 ` Johannes Berg
  2007-11-14 12:52   ` Peter Zijlstra
@ 2007-11-14 13:11   ` Rafael J. Wysocki
  1 sibling, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2007-11-14 13:11 UTC (permalink / raw)
  To: Johannes Berg; +Cc: pm list, Peter Zijlstra

On Tuesday, 13 of November 2007, Johannes Berg wrote:
> 
> On Sun, 2007-11-04 at 14:59 +0100, Rafael J. Wysocki wrote:
> > [Len, please add this patch to the suspend branch, 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.
> 
> Ping? Do I need to follow this or will somebody take care to merge it
> before .24 closes?

I wanted it to go via Len's tree, but unfortunately Len has not been responsive
recently.

I'll push it to Andrew later today.

Thanks,
Rafael

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

* [PATCH] Hibernation: Fix lockdep report (v2)
@ 2007-11-14 21:25 Rafael J. Wysocki
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2007-11-14 21:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Johannes Berg, pm list, Peter Zijlstra, LKML

[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] 8+ messages in thread

* Re: [PATCH] Hibernation: Fix lockdep report (v2)
       [not found] ` <20071114224200.GB7367@ucw.cz>
@ 2007-11-14 21:54   ` Peter Zijlstra
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Zijlstra @ 2007-11-14 21:54 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, pm list, Johannes Berg, LKML


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] 8+ messages in thread

* Re: [PATCH] Hibernation: Fix lockdep report (v2)
       [not found] <200711142225.58033.rjw@sisk.pl>
       [not found] ` <20071114224200.GB7367@ucw.cz>
@ 2007-11-14 22:42 ` Pavel Machek
  1 sibling, 0 replies; 8+ messages in thread
From: Pavel Machek @ 2007-11-14 22:42 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: LKML, Andrew Morton, pm list, Johannes Berg, Peter Zijlstra

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] 8+ messages in thread

end of thread, other threads:[~2007-11-14 22:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-04 13:59 [PATCH] Hibernation: Fix lockdep report (v2) Rafael J. Wysocki
2007-11-04 18:38 ` Pavel Machek
2007-11-13 18:45 ` Johannes Berg
2007-11-14 12:52   ` Peter Zijlstra
2007-11-14 13:11   ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2007-11-14 21:25 Rafael J. Wysocki
     [not found] <200711142225.58033.rjw@sisk.pl>
     [not found] ` <20071114224200.GB7367@ucw.cz>
2007-11-14 21:54   ` Peter Zijlstra
2007-11-14 22:42 ` Pavel Machek

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