From: Matt Helsley <matthltc@us.ibm.com>
To: Tomasz Buchert <Tomasz.Buchert@inria.fr>
Cc: Matt Helsley <matthltc@us.ibm.com>,
Paul Menage <menage@google.com>, Li Zefan <lizf@cn.fujitsu.com>,
containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cgroup_freezer: Freezing and task move race fix
Date: Tue, 10 Aug 2010 21:27:38 -0700 [thread overview]
Message-ID: <20100811042738.GH2927@count0.beaverton.ibm.com> (raw)
In-Reply-To: <4C61D044.2060703@inria.fr>
On Wed, Aug 11, 2010 at 12:18:44AM +0200, Tomasz Buchert wrote:
> Matt Helsley a écrit :
> > On Tue, Aug 10, 2010 at 09:53:21PM +0200, Tomasz Buchert wrote:
> >> Writing 'FROZEN' to freezer.state file does not
> >> forbid the task to be moved away from its cgroup
> >> (for a very short time). Nevertheless the moved task
> >> can become frozen OUTSIDE its cgroup which puts
> >> discussed task in a permanent 'D' state.
> >>
> >> This patch forbids migration of either FROZEN
> >> or FREEZING tasks.
> >>
> >> This behavior was observed and easily reproduced on
> >> a single core laptop. Program and instructions how
> >> to reproduce the bug can be fetched from:
> >> http://pentium.hopto.org/~thinred/repos/linux-misc/freezer_bug.c
> >
> > Thanks for the report and the test code.
> >
> > I'm will try to reproduce this race in the next few hours and analyze
> > it since I'm not sure the patch really fixes the race -- it may only
> > make the race trigger less frequently.
> >
> > At the very least the patch won't break the current code since it's
> > essentially a more-strict version of is_task_frozen_enough() -- it lets
> > fewer tasks attach/detach to/from frozen cgroups.
> >
> > Cheers,
> > -Matt Helsley
>
> Hi Matt!
> I am a novice if it comes to the kernel and I find the cgroup_freezer
> code especially complicated, so definetely this may be not enough to fix that.
> Notice also that if you uncomment the line 55 in my testcase this will also
> trigger the race! This, however, makes sense since process may not be in the cgroup anymore
> and consequently won't be thawed.
OK, I triggered it with that. Interesting.
> I think that this patch fixes these problems because it does the flag checking in a right order:
> first freezing() is used and then frozen() which assures (see frozen_process()) that
> the race will not happen. Right? :)
I see what you mean. It still seems like it wouldn't actually fix the race -- just make it
harder to trigger. I think you're saying this is what happens without the patch:
Time "bug" goes through these states cgroup code checks for these states
-----------------------------------------------------------------------------------
| freezing
| is_frozen? Nope.
| frozen
| is_freezing? Nope.
| <move>
V
But, without having carefully investigated the details, this could just as easily happen
with your patch:
Time "bug" goes through these states cgroup code checks for these states
-----------------------------------------------------------------------------------
| is_freezing? Nope.
| is_frozen? Nope.
| freezing
| <move>
| frozen
V
or:
Time "bug" goes through these states cgroup code checks for these states
-----------------------------------------------------------------------------------
| is_freezing? Nope.
| is_frozen? Nope.
| freezing
| frozen
| <move>
V
Time "bug" goes through these states cgroup code checks for these states
-----------------------------------------------------------------------------------
| is_freezing? Nope.
| freezing
| is_frozen? Nope.
| <move>
| frozen
V
or:
Time "bug" goes through these states cgroup code checks for these states
-----------------------------------------------------------------------------------
| is_freezing? Nope.
| freezing
| is_frozen? Nope.
| frozen
| <move>
V
(even with 1 cpu/core)
Your patch only improves things in the sense that it works for the first
example. We need to prevent the latter cases as well.
Cheers,
-Matt
next prev parent reply other threads:[~2010-08-11 4:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-10 19:53 Tomasz Buchert
2010-08-10 21:57 ` Matt Helsley
2010-08-10 22:18 ` Tomasz Buchert
2010-08-11 4:27 ` Matt Helsley [this message]
2010-08-11 7:35 ` Tomasz Buchert
2010-08-12 0:21 ` Matt Helsley
2010-08-12 0:53 ` Tomasz Buchert
2010-08-12 20:13 ` Matt Helsley
2010-08-18 1:13 ` Tomasz Buchert
2010-08-18 2:22 ` Matt Helsley
2010-08-19 8:37 ` Tomasz Buchert
2010-08-13 1:35 ` Rafael J. Wysocki
2010-08-11 1:10 ` Matt Helsley
2010-08-11 7:30 ` Tomasz Buchert
2010-08-11 8:01 ` Tomasz Buchert
2010-08-12 9:45 ` [PATCH 0/3] Two bugfixes for cgroup freezer Tomasz Buchert
2010-08-12 9:45 ` [PATCH 1/3] cgroup_freezer: Unnecessary test in cgroup_freezing_or_frozen Tomasz Buchert
2010-08-12 9:45 ` [PATCH 2/3] cgroup_freezer: Fix can_attach to prohibit moving from/to freezing/frozen cgroups Tomasz Buchert
2010-08-12 9:45 ` [PATCH 3/3] cgroup_freezer: update_freezer_state does incorrect state transactions Tomasz Buchert
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=20100811042738.GH2927@count0.beaverton.ibm.com \
--to=matthltc@us.ibm.com \
--cc=Tomasz.Buchert@inria.fr \
--cc=containers@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
/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®