From: Pavel Machek <pavel@ucw.cz>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: suspend-devel@lists.sourceforge.net, pm list <linux-pm@lists.osdl.org>
Subject: Re: [RFC][PATCH -mm 1/5] PM: Make freeze_processes SMP-safe
Date: Thu, 30 Nov 2006 00:55:23 +0100 [thread overview]
Message-ID: <20061129235523.GA1952@elf.ucw.cz> (raw)
In-Reply-To: <200611290040.37965.rjw@sisk.pl>
Hi!
> > > I do not like the counting idea; it should be simpler to just check if
> > > all the processes are still stopped.
> >
> > I thought about that but didn't invent anything reasonable enough.
> >
> > > But I'm not sure if this is enough. What if signal is being delivered
> > > on another CPU while freezing, still being delivered while this second
> > > check runs, and then SIGCONT is delivered?
> >
> > Hm, is this possible in practice? I mean, if todo is 0 and nr_stopped doesn't
> > change, then there are no processes that can send the SIGCONT (unless someone
> > creates a kernel thread with PF_NOFREEZE that will do just that).
> >
> > Anyway, for now I've no idea how to fix this properly. Will think about it
> > tomorrow.
>
> As far as this particular problem is concerned, I think there are two possible
> solutions.
>
> One of them would be do disable the delivery of continuation signals before
> we start freezing processes, but I don't know how to do this exactly so that
> it's not racy. Also it would be quite intrusive.
>
> The other one may be something along with the lines of the appended patch.
There has to be a better solution. Stopped tasks are suspended
somewhere in kernel, right? One try_to_freeze() and problem should be
solved, in regular way, and without tricks...?
Pavel
>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
> kernel/power/process.c | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
> Index: linux-2.6.19-rc6-mm2/kernel/power/process.c
> ===================================================================
> --- linux-2.6.19-rc6-mm2.orig/kernel/power/process.c 2006-11-28 22:49:30.000000000 +0100
> +++ linux-2.6.19-rc6-mm2/kernel/power/process.c 2006-11-29 00:10:05.000000000 +0100
> @@ -28,8 +28,7 @@ static inline int freezeable(struct task
> if ((p == current) ||
> (p->flags & PF_NOFREEZE) ||
> (p->exit_state == EXIT_ZOMBIE) ||
> - (p->exit_state == EXIT_DEAD) ||
> - (p->state == TASK_STOPPED))
> + (p->exit_state == EXIT_DEAD))
> return 0;
> return 1;
> }
> @@ -103,9 +102,13 @@ static unsigned int try_to_freeze_tasks(
> if (frozen(p))
> continue;
>
> + if (p->state == TASK_STOPPED && freezing(p))
> + continue;
> +
> if (p->state == TASK_TRACED &&
> (frozen(p->parent) ||
> - p->parent->state == TASK_STOPPED)) {
> + (p->parent->state == TASK_STOPPED &&
> + freezing(p->parent)))) {
> cancel_freezing(p);
> continue;
> }
> @@ -185,6 +188,18 @@ int freeze_processes(void)
> return 0;
> }
>
> +static void release_stopped_tasks(void)
> +{
> + struct task_struct *g, *p;
> +
> + read_lock(&tasklist_lock);
> + do_each_thread(g, p) {
> + if (p->state == TASK_STOPPED)
> + cancel_freezing(p);
> + } while_each_thread(g, p);
> + read_unlock(&tasklist_lock);
> +}
> +
> static void thaw_tasks(int thaw_user_space)
> {
> struct task_struct *g, *p;
> @@ -207,6 +222,7 @@ static void thaw_tasks(int thaw_user_spa
> void thaw_processes(void)
> {
> printk("Restarting tasks ... ");
> + release_stopped_tasks();
> thaw_tasks(FREEZER_KERNEL_THREADS);
> thaw_tasks(FREEZER_USER_SPACE);
> schedule();
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Suspend-devel mailing list
> Suspend-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/suspend-devel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
next prev parent reply other threads:[~2006-11-29 23:55 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-25 21:10 [RFC][PATCH -mm] PM: Change ordering of suspend and resume code Rafael J. Wysocki
2006-11-25 21:29 ` [RFC][PATCH -mm 1/5] PM: Make freeze_processes SMP-safe Rafael J. Wysocki
2006-11-26 7:47 ` Pavel Machek
2006-11-26 10:02 ` Rafael J. Wysocki
2006-11-26 11:15 ` Rafael J. Wysocki
2006-11-26 13:34 ` Rafael J. Wysocki
2006-11-26 19:48 ` Pavel Machek
2006-11-26 23:09 ` Rafael J. Wysocki
2006-11-26 23:28 ` Pavel Machek
2006-11-27 2:41 ` [linux-pm] " Alan Stern
2006-11-27 20:04 ` Rafael J. Wysocki
2006-11-27 10:50 ` Pavel Machek
2006-11-27 20:02 ` Rafael J. Wysocki
2006-11-29 23:56 ` Pavel Machek
2006-11-28 23:40 ` Rafael J. Wysocki
2006-11-29 23:55 ` Pavel Machek [this message]
2006-11-30 0:21 ` Rafael J. Wysocki
2006-11-30 15:07 ` Rafael J. Wysocki
2006-11-30 15:43 ` [linux-pm] " Alan Stern
2006-11-30 16:04 ` Rafael J. Wysocki
2006-11-30 19:23 ` Rafael J. Wysocki
2006-11-30 22:34 ` Alan Stern
2006-11-30 22:57 ` Rafael J. Wysocki
2006-12-01 14:56 ` Alan Stern
2006-12-01 19:57 ` Rafael J. Wysocki
2006-12-01 21:17 ` Alan Stern
2006-12-01 21:19 ` Rafael J. Wysocki
2006-12-01 22:07 ` Alan Stern
2006-12-01 23:38 ` Rafael J. Wysocki
2006-12-02 11:55 ` Pavel Machek
2006-12-02 15:39 ` Alan Stern
2006-12-03 11:17 ` Rafael J. Wysocki
2006-11-30 21:55 ` [Suspend-devel] " Rafael J. Wysocki
2006-11-26 19:45 ` [linux-pm] " Pavel Machek
2006-11-26 23:37 ` Luca
2006-11-25 21:34 ` [RFC][PATCH -mm 2/5] swsusp: Change code ordering in disk.c Rafael J. Wysocki
2006-11-25 21:38 ` [RFC][PATCH -mm 3/5] swsusp: Change code ordering in user.c Rafael J. Wysocki
2006-11-25 21:45 ` [RFC][PATCH -mm 4/5] swsusp: Add PLATFORM_SNAPSHOT and PLATFORM_RESTORE ioctls Rafael J. Wysocki
2006-11-26 19:51 ` [linux-pm] " Pavel Machek
2006-11-26 23:12 ` Rafael J. Wysocki
2006-11-26 23:29 ` Pavel Machek
2006-11-27 10:37 ` Pavel Machek
2006-11-25 21:49 ` [RFC][PATCH -mm 5/5] PM: Change code ordering in main.c Rafael J. Wysocki
2006-11-26 7:44 ` [RFC][PATCH -mm] PM: Change ordering of suspend and resume code Pavel Machek
2006-11-26 10:08 ` Rafael J. Wysocki
2006-11-26 21:31 ` Pavel Machek
2006-11-26 23:15 ` Rafael J. Wysocki
2006-11-30 14:02 ` Stefan Seyfried
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=20061129235523.GA1952@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=linux-pm@lists.osdl.org \
--cc=rjw@sisk.pl \
--cc=suspend-devel@lists.sourceforge.net \
/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