From: Linus Torvalds <torvalds@linux-foundation.org>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
Andrew Morton <akpm@linux-foundation.org>,
Gautham R Shenoy <ego@in.ibm.com>,
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: Fri, 11 May 2007 17:08:48 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.0.98.0705111656240.3986@woody.linux-foundation.org> (raw)
In-Reply-To: <20070511234819.GA508@tv-sign.ru>
On Sat, 12 May 2007, Oleg Nesterov wrote:
>
> things change, ->mm is not stable if the kernel thread does use_mm/unuse_mm.
->mm is not stable *regardless*!
Trivial examples:
- kernel thread does execve()
- user thread does exit().
The use "use_mm()" and "unuse_mm()" things are total red herrings.
If the freezer depends on the difference between user and kernel threads,
then THAT PATCH IS BUGGY. It's that simple. It tests something that simply
isn't stable outside the lock, and then returns that value after having
unlocked it.
It might as well return a random number.
> However, the return value == 0 does not change in that particular case,
> exactly because is_user_space() takes task_lock().
As does exit_mm() etc.
That's NOT THE POINT. You cannot use the end result after releasing the
task lock, because the moment you release the task lock, it becomes
totally irrelevant, and may not be true any more.
Example (a):
- you ask "is_user_space(p)", it returns 1.
- before you actually have time to do anything about it, the task exists,
and (since you don't hold the lock any more) will now have a NULL
tsk->mm again (and would now return 0 if you called it again).
Example (b):
- you ask "is_user_space(p)" and it returns 0, because it's a kernel
thread
- before you actually do anything about it (but after you released the
task lock), the kernel thread does an "execve(/sbin/hotplug)" and is no
longer a kernel thread.
In both cases will the caller have a return value THAT IS NO LONGER TRUE.
See? The locking was pointless. Exactly because you release the lock
before the user can actually do anything about the return value!
The fact that the locking protects against the very specific case of AIO
where the threads _stay_ user tasks and don't really change is pretty much
irrelevant, as far as I can see.
Anyway, I think the whole freezer thing is broken. There's no reason to
freeze kernel threads.
If you want to freeze user processes, go ahead. But then you need a lock
to make sure that new processes don't *become* user processes (ie you need
to disable hotplug).
And if you want to protect against cpufreq, do so. But don't try to say
that you want to freeze all kernel threads. Just protect against cpufreq
threads. Don't make all the other threads that have *zero* interest in
freezing have to worry about it.
Linus
next prev parent reply other threads:[~2007-05-12 0:09 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 [this message]
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
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=alpine.LFD.0.98.0705111656240.3986@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--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=rjw@sisk.pl \
/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
all inboxes | Powered by JetHome®