From: Ming Lei <ming.lei@canonical.com>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-pm@vger.kernel.org,
Ming Lei <ming.lei@canonical.com>,
Alan Stern <stern@rowland.harvard.edu>,
Oliver Neukum <oneukum@suse.de>,
"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: [RFC PATCH 2/3] PM / Runtime: force memory allocation with no I/O during runtime_resume callbcack
Date: Mon, 15 Oct 2012 13:14:18 +0800 [thread overview]
Message-ID: <1350278059-14904-3-git-send-email-ming.lei@canonical.com> (raw)
In-Reply-To: <1350278059-14904-1-git-send-email-ming.lei@canonical.com>
This patch applies the introduces tsk_memalloc_forbid_io() and
tsk_memalloc_allow_io() to force memory allocation with no I/O
during runtime_resume callback.
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Oliver Neukum <oneukum@suse.de>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/base/power/runtime.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 3148b10..76836c1 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -652,7 +652,20 @@ static int rpm_resume(struct device *dev, int rpmflags)
if (!callback && dev->driver && dev->driver->pm)
callback = dev->driver->pm->runtime_resume;
+ /*
+ * Deadlock might be caused if memory allocation with GFP_KERNEL
+ * happens inside runtime_resume callback of one block device's
+ * ancestor or the block device itself. The easiest approach is
+ * to forbid I/O inside runtime_resume of all devices.
+ *
+ * In fact, it can be done only if the deivce is a block device
+ * or there is one block device descendant. But that may become
+ * complicated and not efficient because device tree traversing
+ * is involved.
+ */
+ tsk_memalloc_forbid_io(current);
retval = rpm_callback(callback, dev);
+ tsk_memalloc_allow_io(current);
if (retval) {
__update_runtime_status(dev, RPM_SUSPENDED);
pm_runtime_cancel_pending(dev);
--
1.7.9.5
next prev parent reply other threads:[~2012-10-15 5:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-15 5:14 [RFC PATCH 0/3] mm/PM/USB: force memory allocation with no io in need Ming Lei
2012-10-15 5:14 ` [RFC PATCH 1/3] mm: teach mm by current context info to not do I/O during memory allocation Ming Lei
2012-10-15 14:33 ` Alan Stern
2012-10-15 14:41 ` Ming Lei
2012-10-15 15:47 ` Minchan Kim
2012-10-16 1:56 ` Ming Lei
2012-10-16 5:49 ` Minchan Kim
2012-10-16 7:08 ` Ming Lei
2012-10-16 13:09 ` Minchan Kim
2012-10-16 13:47 ` Ming Lei
2012-10-16 13:53 ` Minchan Kim
2012-10-15 5:14 ` Ming Lei [this message]
2012-10-15 14:14 ` [RFC PATCH 2/3] PM / Runtime: force memory allocation with no I/O during runtime_resume callbcack Alan Stern
2012-10-15 14:35 ` Ming Lei
2012-10-15 5:14 ` [RFC PATCH 3/3] USB: forbid memory allocation with I/O during bus reset if storage interface exits Ming Lei
2012-10-15 9:34 ` Oliver Neukum
2012-10-15 12:06 ` Ming Lei
2012-10-15 12:30 ` Oliver Neukum
2012-10-15 13:21 ` Ming Lei
2012-10-15 16:04 ` Oliver Neukum
2012-10-15 16:48 ` Greg Kroah-Hartman
2012-10-16 7:41 ` Ming Lei
2012-10-15 16:48 ` Greg Kroah-Hartman
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=1350278059-14904-3-git-send-email-ming.lei@canonical.com \
--to=ming.lei@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.de \
--cc=rjw@sisk.pl \
--cc=stern@rowland.harvard.edu \
/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
all inboxes | Powered by JetHome®