From: Hugh Dickins <hughd@google.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Ondrej Zary <linux@rainbow-software.org>,
Andrew Morton <akpm@linux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Kernel development list <linux-kernel@vger.kernel.org>,
Balbir Singh <balbir@in.ibm.com>
Subject: Re: 2.6.35.5: hibernation broken... AGAIN
Date: Tue, 30 Nov 2010 17:21:39 -0800 (PST) [thread overview]
Message-ID: <alpine.LSU.2.00.1011301715480.15050@tigran.mtv.corp.google.com> (raw)
In-Reply-To: <201012010138.53575.rjw@sisk.pl>
On Wed, 1 Dec 2010, Rafael J. Wysocki wrote:
> Below is an updated patch in which I tried to address your comments.
>
> I didn't find it very useful to couple pm_restore_gfp_mask() with the thawing
> of tasks, but nevertheless I think all of the spots where it's needed are
> covered now.
So far as I can see, yes, they are: I'm still a bit worried about
future changes leaving the wrong gfp mask behind by mistake;
but I trust you more than I trust me on that, so you can add my
Acked-by: Hugh Dickins <hughd@google.com> when it comes to
sending in the patch.
Thanks,
Hugh
>
> The patch has only been compile-tested for now, so caveat emptor.
>
> Thanks,
> Rafael
>
> ---
> include/linux/gfp.h | 4 ++--
> kernel/power/hibernate.c | 22 ++++++++++++----------
> kernel/power/suspend.c | 5 ++---
> kernel/power/user.c | 2 ++
> mm/page_alloc.c | 18 +++++++++++-------
> 5 files changed, 29 insertions(+), 22 deletions(-)
>
> Index: linux-2.6/kernel/power/hibernate.c
> ===================================================================
> --- linux-2.6.orig/kernel/power/hibernate.c
> +++ linux-2.6/kernel/power/hibernate.c
> @@ -327,7 +327,6 @@ static int create_image(int platform_mod
> int hibernation_snapshot(int platform_mode)
> {
> int error;
> - gfp_t saved_mask;
>
> error = platform_begin(platform_mode);
> if (error)
> @@ -339,7 +338,7 @@ int hibernation_snapshot(int platform_mo
> goto Close;
>
> suspend_console();
> - saved_mask = clear_gfp_allowed_mask(GFP_IOFS);
> + pm_restrict_gfp_mask();
> error = dpm_suspend_start(PMSG_FREEZE);
> if (error)
> goto Recover_platform;
> @@ -348,7 +347,10 @@ int hibernation_snapshot(int platform_mo
> goto Recover_platform;
>
> error = create_image(platform_mode);
> - /* Control returns here after successful restore */
> + /*
> + * Control returns here (1) after the image has been created or the
> + * image creation has failed and (2) after a successful restore.
> + */
>
> Resume_devices:
> /* We may need to release the preallocated image pages here. */
> @@ -357,7 +359,10 @@ int hibernation_snapshot(int platform_mo
>
> dpm_resume_end(in_suspend ?
> (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE);
> - set_gfp_allowed_mask(saved_mask);
> +
> + if (error || !in_suspend)
> + pm_restore_gfp_mask();
> +
> resume_console();
> Close:
> platform_end(platform_mode);
> @@ -452,17 +457,16 @@ static int resume_target_kernel(bool pla
> int hibernation_restore(int platform_mode)
> {
> int error;
> - gfp_t saved_mask;
>
> pm_prepare_console();
> suspend_console();
> - saved_mask = clear_gfp_allowed_mask(GFP_IOFS);
> + pm_restrict_gfp_mask();
> error = dpm_suspend_start(PMSG_QUIESCE);
> if (!error) {
> error = resume_target_kernel(platform_mode);
> dpm_resume_end(PMSG_RECOVER);
> }
> - set_gfp_allowed_mask(saved_mask);
> + pm_restore_gfp_mask();
> resume_console();
> pm_restore_console();
> return error;
> @@ -476,7 +480,6 @@ int hibernation_restore(int platform_mod
> int hibernation_platform_enter(void)
> {
> int error;
> - gfp_t saved_mask;
>
> if (!hibernation_ops)
> return -ENOSYS;
> @@ -492,7 +495,6 @@ int hibernation_platform_enter(void)
>
> entering_platform_hibernation = true;
> suspend_console();
> - saved_mask = clear_gfp_allowed_mask(GFP_IOFS);
> error = dpm_suspend_start(PMSG_HIBERNATE);
> if (error) {
> if (hibernation_ops->recover)
> @@ -536,7 +538,6 @@ int hibernation_platform_enter(void)
> Resume_devices:
> entering_platform_hibernation = false;
> dpm_resume_end(PMSG_RESTORE);
> - set_gfp_allowed_mask(saved_mask);
> resume_console();
>
> Close:
> @@ -647,6 +648,7 @@ int hibernate(void)
> if (!error)
> power_down();
> in_suspend = 0;
> + pm_restore_gfp_mask();
> } else {
> pr_debug("PM: Image restored successfully.\n");
> }
> Index: linux-2.6/kernel/power/user.c
> ===================================================================
> --- linux-2.6.orig/kernel/power/user.c
> +++ linux-2.6/kernel/power/user.c
> @@ -263,6 +263,7 @@ static long snapshot_ioctl(struct file *
> case SNAPSHOT_UNFREEZE:
> if (!data->frozen || data->ready)
> break;
> + pm_restore_gfp_mask();
> thaw_processes();
> usermodehelper_enable();
> data->frozen = 0;
> @@ -275,6 +276,7 @@ static long snapshot_ioctl(struct file *
> error = -EPERM;
> break;
> }
> + pm_restore_gfp_mask();
> error = hibernation_snapshot(data->platform_support);
> if (!error)
> error = put_user(in_suspend, (int __user *)arg);
> Index: linux-2.6/mm/page_alloc.c
> ===================================================================
> --- linux-2.6.orig/mm/page_alloc.c
> +++ linux-2.6/mm/page_alloc.c
> @@ -104,19 +104,23 @@ gfp_t gfp_allowed_mask __read_mostly = G
> * only be modified with pm_mutex held, unless the suspend/hibernate code is
> * guaranteed not to run in parallel with that modification).
> */
> -void set_gfp_allowed_mask(gfp_t mask)
> +
> +static gfp_t saved_gfp_mask;
> +
> +void pm_restore_gfp_mask(void)
> {
> WARN_ON(!mutex_is_locked(&pm_mutex));
> - gfp_allowed_mask = mask;
> + if (saved_gfp_mask) {
> + gfp_allowed_mask = saved_gfp_mask;
> + saved_gfp_mask = 0;
> + }
> }
>
> -gfp_t clear_gfp_allowed_mask(gfp_t mask)
> +void pm_restrict_gfp_mask(void)
> {
> - gfp_t ret = gfp_allowed_mask;
> -
> WARN_ON(!mutex_is_locked(&pm_mutex));
> - gfp_allowed_mask &= ~mask;
> - return ret;
> + saved_gfp_mask = gfp_allowed_mask;
> + gfp_allowed_mask &= ~GFP_IOFS;
> }
> #endif /* CONFIG_PM_SLEEP */
>
> Index: linux-2.6/include/linux/gfp.h
> ===================================================================
> --- linux-2.6.orig/include/linux/gfp.h
> +++ linux-2.6/include/linux/gfp.h
> @@ -360,7 +360,7 @@ void drain_local_pages(void *dummy);
>
> extern gfp_t gfp_allowed_mask;
>
> -extern void set_gfp_allowed_mask(gfp_t mask);
> -extern gfp_t clear_gfp_allowed_mask(gfp_t mask);
> +extern void pm_restrict_gfp_mask(void);
> +extern void pm_restore_gfp_mask(void);
>
> #endif /* __LINUX_GFP_H */
> Index: linux-2.6/kernel/power/suspend.c
> ===================================================================
> --- linux-2.6.orig/kernel/power/suspend.c
> +++ linux-2.6/kernel/power/suspend.c
> @@ -197,7 +197,6 @@ static int suspend_enter(suspend_state_t
> int suspend_devices_and_enter(suspend_state_t state)
> {
> int error;
> - gfp_t saved_mask;
>
> if (!suspend_ops)
> return -ENOSYS;
> @@ -208,7 +207,7 @@ int suspend_devices_and_enter(suspend_st
> goto Close;
> }
> suspend_console();
> - saved_mask = clear_gfp_allowed_mask(GFP_IOFS);
> + pm_restrict_gfp_mask();
> suspend_test_start();
> error = dpm_suspend_start(PMSG_SUSPEND);
> if (error) {
> @@ -225,7 +224,7 @@ int suspend_devices_and_enter(suspend_st
> suspend_test_start();
> dpm_resume_end(PMSG_RESUME);
> suspend_test_finish("resume devices");
> - set_gfp_allowed_mask(saved_mask);
> + pm_restore_gfp_mask();
> resume_console();
> Close:
> if (suspend_ops->end)
>
next prev parent reply other threads:[~2010-12-01 1:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-17 10:39 2.6.35.5: hibernation broken... AGAIN Ondrej Zary
2010-11-17 20:53 ` Rafael J. Wysocki
2010-11-17 21:04 ` Andrew Morton
2010-11-17 21:12 ` Rafael J. Wysocki
2010-11-17 21:18 ` Ondrej Zary
2010-11-17 23:46 ` Hugh Dickins
2010-11-20 15:07 ` Ondrej Zary
2010-11-26 11:43 ` Ondrej Zary
2010-11-26 23:10 ` Rafael J. Wysocki
2010-11-27 14:58 ` Ondrej Zary
2010-11-27 20:47 ` Rafael J. Wysocki
2010-11-30 22:16 ` Hugh Dickins
2010-11-30 23:07 ` Rafael J. Wysocki
2010-12-01 0:38 ` Rafael J. Wysocki
2010-12-01 0:53 ` KAMEZAWA Hiroyuki
2010-12-01 21:25 ` Rafael J. Wysocki
2010-12-01 22:23 ` Rafael J. Wysocki
2010-12-01 23:37 ` KAMEZAWA Hiroyuki
2010-12-02 0:00 ` Rafael J. Wysocki
2010-12-01 1:21 ` Hugh Dickins [this message]
2010-12-01 20:57 ` Rafael J. Wysocki
2010-12-06 21:09 ` Ondrej Zary
2010-12-06 22:57 ` Rafael J. Wysocki
2010-11-26 20:24 ` Rafael J. Wysocki
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=alpine.LSU.2.00.1011301715480.15050@tigran.mtv.corp.google.com \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@in.ibm.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rainbow-software.org \
--cc=rjw@sisk.pl \
/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;
as well as URLs for NNTP newsgroup(s).