From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: "Pali Rohár" <pali.rohar@gmail.com>
Cc: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@redhat.com>, Neil Brown <neilb@suse.de>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
dm-devel@redhat.com, linux-raid@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH v2 1/3] PM suspend/hibernate: Call notifier after freezing processes
Date: Sat, 18 Jul 2015 01:27:15 +0200 [thread overview]
Message-ID: <3179448.TScsKEAuyR@vostro.rjw.lan> (raw)
In-Reply-To: <20150716073302.GA10393@pali>
On Thursday, July 16, 2015 09:33:02 AM Pali Rohár wrote:
> On Thursday 16 July 2015 03:02:03 Rafael J. Wysocki wrote:
> > On Sunday, June 21, 2015 01:20:32 PM Pali Rohár wrote:
> > > To prevent race conditions on userspace processes with I/O some taks must be
> > > called after processes are freezed. This patch adds new events which are
> > > delivered by pm_notifier_call_chain() after freezing processes when doing
> > > suspend or hibernate action.
> > >
> > > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> > > ---
> > > include/linux/suspend.h | 2 ++
> > > kernel/power/hibernate.c | 2 ++
> > > kernel/power/suspend.c | 4 +++-
> > > 3 files changed, 7 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/include/linux/suspend.h b/include/linux/suspend.h
> > > index 5efe743..bc743c8 100644
> > > --- a/include/linux/suspend.h
> > > +++ b/include/linux/suspend.h
> > > @@ -368,6 +368,8 @@ static inline bool hibernation_available(void) { return false; }
> > > #define PM_POST_SUSPEND 0x0004 /* Suspend finished */
> > > #define PM_RESTORE_PREPARE 0x0005 /* Going to restore a saved image */
> > > #define PM_POST_RESTORE 0x0006 /* Restore failed */
> > > +#define PM_HIBERNATION_AFTER_FREEZE 0x0007 /* After hibernation freeze */
> > > +#define PM_SUSPEND_AFTER_FREEZE 0x0008 /* After suspend freeze */
> > >
> > > extern struct mutex pm_mutex;
> > >
> > > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> > > index 2329daa..184f7ee 100644
> > > --- a/kernel/power/hibernate.c
> > > +++ b/kernel/power/hibernate.c
> > > @@ -671,6 +671,8 @@ int hibernate(void)
> > > if (error)
> > > goto Exit;
> > >
> > > + pm_notifier_call_chain(PM_HIBERNATION_AFTER_FREEZE);
> >
> > Don't we need to check errors from these?
> >
>
> If yes, what to do in this case? Fail hibernation and goto Exit?
Yes, fail the transition in progress.
> > Also, if you're adding AFTER_FREEZE, it would be good to add BEFORE_THAW too
> > for symmetry.
> >
>
> But there is no use case for BEFORE_THAW. At least it is not needed for now.
For your use case, a single function pointer would be sufficient too.
> > > +
> > > lock_device_hotplug();
> > > /* Allocate memory management structures */
> > > error = create_basic_memory_bitmaps();
> > > diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> > > index 8d7a1ef..ba2a945 100644
> > > --- a/kernel/power/suspend.c
> > > +++ b/kernel/power/suspend.c
> > > @@ -277,8 +277,10 @@ static int suspend_prepare(suspend_state_t state)
> > > trace_suspend_resume(TPS("freeze_processes"), 0, true);
> > > error = suspend_freeze_processes();
> > > trace_suspend_resume(TPS("freeze_processes"), 0, false);
> > > - if (!error)
> > > + if (!error) {
> > > + pm_notifier_call_chain(PM_SUSPEND_AFTER_FREEZE);
> > > return 0;
> > > + }
> > >
> > > suspend_stats.failed_freeze++;
> > > dpm_save_failed_step(SUSPEND_FREEZE);
> > >
> >
>
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
next prev parent reply other threads:[~2015-07-17 23:00 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-05 17:20 [PATCH 0/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation Pali Rohár
2015-04-05 17:20 ` [PATCH 1/3] PM suspend/hibernate: Call notifier after freezing processes Pali Rohár
2015-04-09 0:28 ` Rafael J. Wysocki
2015-04-09 6:36 ` Pali Rohár
2015-04-09 17:13 ` Rafael J. Wysocki
2015-04-09 16:55 ` Pali Rohár
2015-04-05 17:20 ` [PATCH 2/3] dm: Export function dm_suspend_md() Pali Rohár
2015-04-05 17:20 ` [PATCH 3/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation Pali Rohár
2015-04-07 13:55 ` [dm-devel] " Alasdair G Kergon
2015-04-06 13:00 ` [PATCH 0/3] " Mike Snitzer
2015-04-06 13:25 ` Pavel Machek
2015-04-06 20:51 ` Mike Snitzer
2015-04-06 21:13 ` Why wipe crypto keys during suspend (was Re: [PATCH 0/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation) Pavel Machek
2015-04-06 13:29 ` [PATCH 0/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation Pali Rohár
2015-04-06 18:17 ` Pavel Machek
2015-04-06 21:27 ` Pali Rohár
2015-04-09 13:12 ` Mike Snitzer
2015-04-09 13:28 ` Pali Rohár
2015-04-09 14:08 ` Mike Snitzer
2015-04-09 14:16 ` Pali Rohár
2015-04-09 14:26 ` Mike Snitzer
2015-04-09 14:38 ` Pali Rohár
2015-04-14 6:50 ` Pavel Machek
2015-04-23 17:02 ` Pali Rohár
[not found] ` <mgnv2g$if5$2@ger.gmane.org>
2015-04-17 7:52 ` Mike Snitzer
2015-04-17 8:52 ` [dm-devel] " Ondrej Kozina
2015-04-17 15:53 ` Alex Elsayed
2015-04-14 6:41 ` Pavel Machek
2015-06-21 11:20 ` [PATCH v2 " Pali Rohár
2015-06-21 11:20 ` [PATCH v2 1/3] PM suspend/hibernate: Call notifier after freezing processes Pali Rohár
2015-07-16 1:02 ` Rafael J. Wysocki
2015-07-16 7:33 ` Pali Rohár
2015-07-17 23:27 ` Rafael J. Wysocki [this message]
2015-07-20 7:32 ` Pali Rohár
2015-07-20 21:46 ` Rafael J. Wysocki
2015-07-21 22:08 ` NeilBrown
2015-07-21 23:00 ` Rafael J. Wysocki
2015-07-21 23:03 ` Rafael J. Wysocki
2016-12-27 14:29 ` Pali Rohár
2015-06-21 11:20 ` [PATCH v2 2/3] dm: Export function dm_suspend_md() Pali Rohár
2015-07-17 14:04 ` Mike Snitzer
2015-07-17 14:22 ` Pali Rohár
2015-07-17 15:22 ` Mike Snitzer
2015-07-17 15:30 ` Mike Snitzer
2015-07-17 17:13 ` Pali Rohár
2015-07-17 17:31 ` Mike Snitzer
2015-06-21 11:20 ` [PATCH v2 3/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation Pali Rohár
2015-07-28 14:44 ` Pavel Machek
2015-07-28 14:48 ` Pali Rohár
2015-07-07 7:59 ` [PATCH v2 0/3] " Pali Rohár
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=3179448.TScsKEAuyR@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=pali.rohar@gmail.com \
--cc=pavel@ucw.cz \
--cc=snitzer@redhat.com \
/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).