The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: ego@in.ibm.com, Oleg Nesterov <oleg@tv-sign.ru>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>, Pavel Machek <pavel@ucw.cz>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH 1/7] Freezer: Read PF_BORROWED_MM in a nonracy way
Date: Sat, 12 May 2007 11:27:36 +0200	[thread overview]
Message-ID: <200705121127.37655.rjw@sisk.pl> (raw)
In-Reply-To: <20070512081622.GA26265@in.ibm.com>

On Saturday, 12 May 2007 10:16, Gautham R Shenoy wrote:
> On Sat, May 12, 2007 at 02:01:41AM +0200, Rafael J. Wysocki wrote:
> > 
> > > So you migt as well not return any value at all, since the returned value 
> > > is apparently meaningless once the lock has been released.
> > 
> > No, it is not meaningless.
> 
> Right.
> 
> Agreed that the returned value might not necessarily reflect the
> current state of thread in question. Can it pose any problems?
> 
> Case : is_user_space() returns 0: 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> We think the thread is a kernel thread.
> So we don't count this thread when the case is FREEZER_USER_SPACE. 
> 
> Now this thread can perform an execve() and enter the 
> userspace. It might not freeze.
> So we would be declaring that all the userspace threads have been frozen,
> when actually we might have this one li'l unfrozen devil from the 
> userspace. 
> 
> Do we care? 
> For cpu hotplug, I don't think so.
> 
> Because, like Oleg pointed out,  we know we'll anyway freeze all the 
> leftover threads while handling the case FREEZER_KERNEL_THREADS.
> 
> But I am not sure if this is the case with suspend/hibernate, since we
> need to do a sys_sync() between try_freeze_tasks(FREEZE_USER_SPACE) and
> try_to_freeze_tasks(FREEZE_KERNEL_THREADS).

>From the point of view of syncing it's only necessary to make sure that we
won't freeze a kernel thread that's needed for the syncing.  We can have an
additional user space task running at this point.

> Case:is_user_space() returns 1:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> We think the thread is from userspace.
> We count this thread when the case is FREEZER_USER_SPACE. Now the
> thread enters the kernel space by either doing a daemonize() or exit().
> 
> The freezer code loops *atleast* twice before declaring the system
> frozen. So if this metamorphosis occurs between iteration i and
> iteration i+1, in i+1, we note that this thread is now a kernel thread,
> and don't count it anymore.
> 
> However, between the 'i'th and 'i+1'th interation, if this thread calls
> try_to_freeze(), it'll enter the refrigerator. We now have a cold
> kernel thread when we were trying to freeze only userspace.

Hmm, I'm not sure if the task can call try_to_freeze() after doing exit().
May it happen?

> So, the question should be, are we clearing the TIF_FREEZING flag in places
> where the thread can become a kernel thread and eventually call try_to_freeze.
> I won't expect an exiting thread to call try_to_freeze, but a
> daemonize()ed thread can.
> 
> So should we perform that check in reparent_to_kthreadd() ?
> We are protected by the tasklist_lock there, no?

Yes.  Still, I think the daemonize()ed threads should clear their TIF_FREEZE
flag unconditionally right after they have called exit_mm().  So that would be
in daemonize().

Or, perhaps, it's better to clear TIF_FREEZE (unconditionally) in exit_mm(),
after we've done tsk->mm = NULL?  Oleg, what do you think?

Greetings,
Rafael 

  reply	other threads:[~2007-05-12  9:23 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-10 22:35 [PATCH 0/7] Freezer bugfixes Rafael J. Wysocki
2007-05-10 22:36 ` [PATCH 1/7] Freezer: Read PF_BORROWED_MM in a nonracy way Rafael J. Wysocki
2007-05-11 19:39   ` Andrew Morton
2007-05-11 20:21     ` Oleg Nesterov
2007-05-11 20:40     ` Rafael J. Wysocki
2007-05-11 22:56       ` Linus Torvalds
2007-05-11 23:20         ` Oleg Nesterov
2007-05-11 23:32           ` Linus Torvalds
2007-05-11 23:48             ` Oleg Nesterov
2007-05-12  0:05               ` Oleg Nesterov
2007-05-12  0:08               ` Linus Torvalds
2007-05-12  0:40                 ` Oleg Nesterov
2007-05-12  1:01                   ` Oleg Nesterov
2007-05-12  1:24                   ` Linus Torvalds
2007-05-12  9:01                     ` Rafael J. Wysocki
2007-05-12 10:45                       ` Rafael J. Wysocki
2007-05-12 14:18                         ` Oleg Nesterov
2007-05-12 16:35                           ` Rafael J. Wysocki
2007-05-12 16:58                             ` Oleg Nesterov
2007-05-12 17:16                               ` Rafael J. Wysocki
2007-05-12 17:43                     ` Oleg Nesterov
2007-05-12  1:11                 ` Rafael J. Wysocki
2007-05-11 23:22         ` Rafael J. Wysocki
2007-05-11 23:25           ` Andrew Morton
2007-05-12  0:16             ` Rafael J. Wysocki
2007-05-11 23:29           ` Linus Torvalds
2007-05-12  0:01             ` Rafael J. Wysocki
2007-05-12  8:16               ` Gautham R Shenoy
2007-05-12  9:27                 ` Rafael J. Wysocki [this message]
2007-05-12 10:13                   ` Gautham R Shenoy
2007-05-12 10:41                     ` Rafael J. Wysocki
2007-05-12 10:52                       ` Gautham R Shenoy
2007-05-12 11:34                         ` Rafael J. Wysocki
2007-05-12 14:25                   ` Oleg Nesterov
2007-05-12 14:59                     ` migrate_dead_tasks() vs sleep-after-exit_notify() problems? Oleg Nesterov
2007-05-10 22:37 ` [PATCH 2/7] Freezer: Close potential race between refrigerator and thaw_tasks Rafael J. Wysocki
2007-05-10 22:38 ` [PATCH 3/7] Freezer: Fix vfork problem Rafael J. Wysocki
2007-05-10 22:39 ` [PATCH 4/7] Freezer: Take kernel_execve into consideration Rafael J. Wysocki
2007-05-10 22:41 ` [PATCH 5/7] Freezer: Fix kthread_create vs freezer theoretical race Rafael J. Wysocki
2007-05-10 22:43 ` [PATCH 6/7] Freezer: Fix PF_NOFREEZE vs freezeable race Rafael J. Wysocki
2007-05-10 22:44 ` [PATCH 7/7] Freezer: Move frozen_process to kernel/power/process.c 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=200705121127.37655.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=ego@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    --cc=pavel@ucw.cz \
    --cc=torvalds@linux-foundation.org \
    /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