[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121108141848.GA12973@htj.dyndns.org>
Date: Thu, 8 Nov 2012 06:18:48 -0800
From: Tejun Heo <tj@...nel.org>
To: Michal Hocko <mhocko@...e.cz>
Cc: lizefan@...wei.com, rjw@...k.pl,
containers@...ts.linux-foundation.org, cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
fweisbec@...il.com
Subject: Re: [PATCH 9/9 v2] cgroup_freezer: implement proper hierarchy support
Hello, Michal.
On Thu, Nov 08, 2012 at 03:08:52PM +0100, Michal Hocko wrote:
> This seems to be racy because parent->state access is not linearized.
> Say we have parallel freeze and thawing on a tree like the following:
> A
> |
> B
> |
> C
>
> pre_order will visit them in B, C order.
> CPU1 CPU2
> freezer_apply_state(A, true)
> A->state & FREEZING == true freezer_apply_state(A, false)
> A->state & FREEZING == false
> freezer_apply_state(B, false)
> B->state & FREEZING == false
> freezer_apply_state(B, true)
>
> B->state & FREEZING == true
> freezer_apply_state(C, true)
> freezer_apply_state(C, false)
>
> So A, C are thawed while B is frozen. Or am I missing something which
> would prevent from this kind of race?
The rule is that there will be at least one inheritance operation
after a parent is updated. The exact order of propagation doesn't
matter as long as there's at least one inheritance event after the
latest update to a parent. This works because inheritance operations
are atomic to each other. If one inheritance operation "saw" an
update to its parent, the next inheritance operation is guaranteed to
see at least upto that update.
So, in the above example in CPU2, (B->state & FREEZING) test and
freezer_apply_state(C, false) can't be interleaved with the same
inheritance operation from CPU1. They either happen before or after.
Maybe it's too subtle. The only reason I didn't use a giant
freezer_mutex was that I wanted to demonstrate how to do state
propagation without depending on single giant lock. Maybe nobody
wants that and this should use one mutex to protect the hierarchy. I
don't know.
Thanks.
--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists