LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: "Aneesh Kumar" <aneesh.kumar@gmail.com>
Cc: "Pavel Machek" <pavel@ucw.cz>,
	LKML <linux-kernel@vger.kernel.org>,
	paulmck@linux.vnet.ibm.com, ego@in.ibm.com, akpm@osdl.org,
	mingo@elte.hu, vatsa@in.ibm.com, dipankar@in.ibm.com,
	venkatesh.pallipadi@intel.com, Oleg Nesterov <oleg@tv-sign.ru>
Subject: Re: [RFC][PATCH 4/7] Freezer: Fix vfork problem
Date: Sun, 25 Feb 2007 16:05:40 +0100	[thread overview]
Message-ID: <200702251605.42312.rjw@sisk.pl> (raw)
In-Reply-To: <cc723f590702250633i27a79a9tedd5fe670cd9e4ed@mail.gmail.com>

On Sunday, 25 February 2007 15:33, Aneesh Kumar wrote:
> On 2/25/07, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > On Sunday, 25 February 2007 11:45, Rafael J. Wysocki wrote:
> > > Hi,
> > >
> > > =========
> > --- linux-2.6.20-mm2.orig/kernel/power/process.c        2007-02-22 23:44:04.000000000 +0100
> > +++ linux-2.6.20-mm2/kernel/power/process.c     2007-02-23 22:33:11.000000000 +0100
> > @@ -127,22 +127,12 @@ static unsigned int try_to_freeze_tasks(
> >                                 cancel_freezing(p);
> >                                 continue;
> >                         }
> > -                       if (is_user_space(p)) {
> > -                               if (!freeze_user_space)
> > -                                       continue;
> > -
> > -                               /* Freeze the task unless there is a vfork
> > -                                * completion pending
> > -                                */
> > -                               if (!p->vfork_done)
> > -                                       freeze_process(p);
> > -                       } else {
> > -                               if (freeze_user_space)
> > -                                       continue;
> > +                       if (is_user_space(p) == !freeze_user_space)
> > +                               continue;
> >
> 
> How about ?
> if ( ! (is_user_space(p) == freeze_user_space) )
>      continue;

I think it would be safer to do

if ( is_user_space(p) != !!freeze_user_space)
      continue;

which is equivalent to my previous version, but contains one '!' more. ;-)

Seriously, the one in the patch is consistent with the other occurrences of
it in the file and I'm going to change it anyway in a separate patch
(while freezing kernel threads we need to freeze userspace tasks too in case
one of the kernel threads called kernel_execve() in the meantime).

> BTW one of the concern that vatsa had was; is it ok to allow some of
> the tasks to be left running  ( the parent from vfork ) while
> freezing.  I guess we can solve this in a nice way.
> 
> in fork.c
> 
> if (clone_flags & CLONE_VFORK) {
>                         p->vfork_done = &vfork;
>                         p->flags |= PF_PARENT_WAKEUP_ON_FREEZE;
>                         init_completion(&vfork);
> }
> 
> 
> and in freeze_process(struct task_struct *p)
> 
> if ( p->flags & PF_PARENT_WAKEUP_ON_FREEZE ) {
>   wake_up_parent();
> }
> 
> now parent should be wating for these completion via
> 
> wait_for_completion_freezable(); // pavel's implementation.

Hm, I think this leaves us with an analogous problem: we need a method
to tell a vforking task that the child should set PF_PARENT_WAKEUP_ON_FREEZE.

In the approach with PF_FREEZER_SKIP we need a method to tell the
vforking task that it should skip try_to_freeze() in freezer_count(), and I
think there are some possible ways to do this.  The patch doesn't implement
any of them, because this is a different issue that can be deal with later.

Greetings,
Rafael

  reply	other threads:[~2007-02-25 15:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-23 10:16 [RFC][PATCH 0/7] Freezer: Hardening and preparation for CPU hotplug changes Rafael J. Wysocki
2007-02-23 10:18 ` [RFC][PATCH 1/7] Freezer: Read PF_BORROWED_MM in a nonracy way Rafael J. Wysocki
2007-02-25 10:43   ` Pavel Machek
2007-02-23 10:19 ` [RFC][PATCH 2/7] Freezer: Fix memory ordering in refrigerator Rafael J. Wysocki
2007-02-23 10:21 ` [RFC][PATCH 3/7] Freezer: Close theoretical race between refrigerator and thaw_tasks Rafael J. Wysocki
2007-02-25 10:44   ` Pavel Machek
2007-02-23 10:22 ` [RFC][PATCH 4/7] Freezer: Fix vfork problem Rafael J. Wysocki
2007-02-25 10:46   ` Pavel Machek
2007-02-25 10:45     ` Rafael J. Wysocki
2007-02-25 12:59       ` Rafael J. Wysocki
2007-02-25 14:33         ` Aneesh Kumar
2007-02-25 15:05           ` Rafael J. Wysocki [this message]
2007-02-25 15:28             ` Aneesh Kumar
2007-02-25 15:40               ` Aneesh Kumar
2007-02-25 19:17                 ` Rafael J. Wysocki
2007-02-25 20:31                   ` Oleg Nesterov
2007-02-25 20:33                     ` Rafael J. Wysocki
2007-02-25 13:01     ` Aneesh Kumar
2007-02-25 13:43       ` Rafael J. Wysocki
2007-02-23 10:23 ` [RFC][PATCH 5/7] Freezer: Remove PF_NOFREEZE from rcutorture thread Rafael J. Wysocki
2007-02-25 10:44   ` Pavel Machek
2007-02-23 10:25 ` [RFC][PATCH 6/7] Freezer: Remove PF_NOFREEZE from bluetooth threads Rafael J. Wysocki
2007-02-25 10:44   ` Pavel Machek
2007-02-25 23:53   ` Marcel Holtmann
2007-02-23 10:26 ` [RFC][PATCH 7/7] Freezer: Add try_to_freeze calls to all kernel threads Rafael J. Wysocki
2007-02-25 10:45   ` Pavel Machek

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=200702251605.42312.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@osdl.org \
    --cc=aneesh.kumar@gmail.com \
    --cc=dipankar@in.ibm.com \
    --cc=ego@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@tv-sign.ru \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=pavel@ucw.cz \
    --cc=vatsa@in.ibm.com \
    --cc=venkatesh.pallipadi@intel.com \
    --subject='Re: [RFC][PATCH 4/7] Freezer: Fix vfork problem' \
    /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

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).