From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Ming Lei <ming.lei@canonical.com>
Cc: linux-kernel@vger.kernel.org,
Alan Stern <stern@rowland.harvard.edu>,
Oliver Neukum <oneukum@suse.de>, Minchan Kim <minchan@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [RFC PATCH v1 2/3] PM / Runtime: force memory allocation with no I/O during runtime_resume callbcack
Date: Wed, 17 Oct 2012 07:43:04 +0200 [thread overview]
Message-ID: <6431373.tJcdR3m2Df@vostro.rjw.lan> (raw)
In-Reply-To: <1350403183-12650-3-git-send-email-ming.lei@canonical.com>
On Tuesday 16 of October 2012 23:59:42 Ming Lei wrote:
> This patch applies the introduced memalloc_noio_save() and
> memalloc_noio_restore() 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 | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index 3148b10..c71a8f0 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -503,6 +503,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
> int (*callback)(struct device *);
> struct device *parent = NULL;
> int retval = 0;
> + unsigned int noio_flag;
>
> trace_rpm_resume(dev, rpmflags);
>
> @@ -652,7 +653,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.
> + */
> + memalloc_noio_save(noio_flag);
> retval = rpm_callback(callback, dev);
> + memalloc_noio_restore(noio_flag);
> if (retval) {
> __update_runtime_status(dev, RPM_SUSPENDED);
> pm_runtime_cancel_pending(dev);
This appears to be a bit too heavy handed. First of all, it seems to affect
all memory allocations going in parallel with the resume callback. Second,
it affects all resume callbacks, not only those where the problem really
appears. As a result, we are likely to get some memory allocation failures
that don't happen without the patch and don't really need to happen at all.
Thanks,
Rafael
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
next prev parent reply other threads:[~2012-10-17 5:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-16 15:59 [RFC PATCH v1 0/3] mm/PM/USB: memory allocation with no io in need Ming Lei
2012-10-16 15:59 ` [RFC PATCH v1 1/3] mm: teach mm by current context info to not do I/O during memory allocation Ming Lei
2012-10-16 20:19 ` Andrew Morton
2012-10-17 1:54 ` Ming Lei
2012-10-17 23:54 ` Andrew Morton
2012-10-19 3:52 ` Ming Lei
2012-10-17 3:40 ` Ming Lei
2012-10-17 5:14 ` Kamezawa Hiroyuki
2012-10-17 10:56 ` Ming Lei
2012-10-16 15:59 ` [RFC PATCH v1 2/3] PM / Runtime: force memory allocation with no I/O during runtime_resume callbcack Ming Lei
2012-10-17 5:43 ` Rafael J. Wysocki [this message]
2012-10-17 11:07 ` Ming Lei
2012-10-18 23:16 ` Rafael J. Wysocki
2012-10-19 1:41 ` Ming Lei
2012-10-16 15:59 ` [RFC PATCH v1 3/3] USB: forbid memory allocation with I/O during bus reset Ming Lei
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=6431373.tJcdR3m2Df@vostro.rjw.lan \
--to=rjw@sisk.pl \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=ming.lei@canonical.com \
--cc=oneukum@suse.de \
--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®