From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Len Brown <lenb@kernel.org>
Cc: Johannes Berg <johannes@sipsolutions.net>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
pm list <linux-pm@lists.linux-foundation.org>
Subject: [PATCH] Hibernation: Fix lockdep report (v2)
Date: Sun, 4 Nov 2007 14:59:22 +0100 [thread overview]
Message-ID: <200711041459.23082.rjw@sisk.pl> (raw)
[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);
next reply other threads:[~2007-11-04 13:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-04 13:59 Rafael J. Wysocki [this message]
2007-11-04 18:38 ` [PATCH] Hibernation: Fix lockdep report (v2) 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
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=200711041459.23082.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=a.p.zijlstra@chello.nl \
--cc=johannes@sipsolutions.net \
--cc=lenb@kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
/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