LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: 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,
	Aneesh Kumar <aneesh.kumar@gmail.com>
Subject: Re: [RFC][PATCH 4/7] Freezer: Fix vfork problem
Date: Sun, 25 Feb 2007 11:46:12 +0100	[thread overview]
Message-ID: <20070225104612.GM2045@elf.ucw.cz> (raw)
In-Reply-To: <200702231122.44040.rjw@sisk.pl>

Hi!

> Currently try_to_freeze_tasks() has to wait until all of the vforked processes
> exit and for this reason every user can make it fail.  To fix this problem
> we can introduce the additional process flag PF_FREEZER_SKIP to be used by tasks
> that do not want to be counted as freezable by the freezer and want to have
> TIF_FREEZE set nevertheless.  Then, this flag can be set by tasks using
> sys_vfork() before they call wait_for_completion() and cleared after they have
> woken up and called try_to_freeze().  In case such a task freezes with
> PF_FREEZER_SKIP set, refrigerator() clears this flag for the current task before
> calling frozen_process(current) to avoid having both PF_FREEZER_SKIP and
> PF_FROZEN set at the same time.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

> @@ -1393,7 +1394,9 @@ long do_fork(unsigned long clone_flags,
>  		tracehook_report_clone_complete(clone_flags, nr, p);
>  
>  		if (clone_flags & CLONE_VFORK) {
> +			freezer_do_not_count();
>  			wait_for_completion(&vfork);
> +			freezer_count();
>  			tracehook_report_vfork_done(p, nr);
>  		}
>  	} else {

All the infrastructure for this...Would it be easier to introduce

void fastcall __sched wait_for_completion_freezeable(struct completion *x)
{
        might_sleep();

        spin_lock_irq(&x->wait.lock);
        if (!x->done) {
                DECLARE_WAITQUEUE(wait, current);

                wait.flags |= WQ_FLAG_EXCLUSIVE;
                __add_wait_queue_tail(&x->wait, &wait);
                do {
                        __set_current_state(TASK_UNINTERRUPTIBLE);
                        spin_unlock_irq(&x->wait.lock);
                        schedule();
try_to_freeze(); /* HERE */
                        spin_lock_irq(&x->wait.lock);
                } while (!x->done);
                __remove_wait_queue(&x->wait, &wait);
        }
        x->done--;
        spin_unlock_irq(&x->wait.lock);
}

...and be done with that, in a very obvious way? (Ok, you probably do
not want to duplicate the function, but you get the idea).
								Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2007-02-25 10:46 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 [this message]
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
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=20070225104612.GM2045@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --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=paulmck@linux.vnet.ibm.com \
    --cc=rjw@sisk.pl \
    --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).