From 1e0216aad2ca6877a0652b59d8f82cd371cd13db Mon Sep 17 00:00:00 2001 From: Johannes Weiner Date: Tue, 29 May 2012 15:06:24 -0700 Subject: [PATCH] --- yaml --- r: 308839 b: refs/heads/master c: 91c63734f6908425903aed69c04035592f18d398 h: refs/heads/master i: 308837: ac26583c0bf54598789b408e07dda2d91df0c9cc 308835: 8d3107683c2799241303916db0cb2a9b7091daa6 308831: 30911fa6897d65a6ead1a9bf075a5ec31fbcb624 v: v3 --- [refs] | 2 +- trunk/kernel/cgroup.c | 20 ++++++++++---------- trunk/mm/memcontrol.c | 14 +++++++++----- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/[refs] b/[refs] index 72b9cb92d2b2..c103ea20182a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0ce72d4f7333248efbef1f3309770c7edb1b2625 +refs/heads/master: 91c63734f6908425903aed69c04035592f18d398 diff --git a/trunk/kernel/cgroup.c b/trunk/kernel/cgroup.c index a0c6af34d500..0f3527d6184a 100644 --- a/trunk/kernel/cgroup.c +++ b/trunk/kernel/cgroup.c @@ -5132,7 +5132,7 @@ EXPORT_SYMBOL_GPL(css_depth); * @root: the css supporsed to be an ancestor of the child. * * Returns true if "root" is an ancestor of "child" in its hierarchy. Because - * this function reads css->id, this use rcu_dereference() and rcu_read_lock(). + * this function reads css->id, the caller must hold rcu_read_lock(). * But, considering usual usage, the csses should be valid objects after test. * Assuming that the caller will do some action to the child if this returns * returns true, the caller must take "child";s reference count. @@ -5144,18 +5144,18 @@ bool css_is_ancestor(struct cgroup_subsys_state *child, { struct css_id *child_id; struct css_id *root_id; - bool ret = true; - rcu_read_lock(); child_id = rcu_dereference(child->id); + if (!child_id) + return false; root_id = rcu_dereference(root->id); - if (!child_id - || !root_id - || (child_id->depth < root_id->depth) - || (child_id->stack[root_id->depth] != root_id->id)) - ret = false; - rcu_read_unlock(); - return ret; + if (!root_id) + return false; + if (child_id->depth < root_id->depth) + return false; + if (child_id->stack[root_id->depth] != root_id->id) + return false; + return true; } void free_css_id(struct cgroup_subsys *ss, struct cgroup_subsys_state *css) diff --git a/trunk/mm/memcontrol.c b/trunk/mm/memcontrol.c index 92675fe8a2ef..faad98e6d17d 100644 --- a/trunk/mm/memcontrol.c +++ b/trunk/mm/memcontrol.c @@ -1152,12 +1152,16 @@ struct lruvec *mem_cgroup_lru_move_lists(struct zone *zone, static bool mem_cgroup_same_or_subtree(const struct mem_cgroup *root_memcg, struct mem_cgroup *memcg) { - if (root_memcg != memcg) { - return (root_memcg->use_hierarchy && - css_is_ancestor(&memcg->css, &root_memcg->css)); - } + bool ret; - return true; + if (root_memcg == memcg) + return true; + if (!root_memcg->use_hierarchy) + return false; + rcu_read_lock(); + ret = css_is_ancestor(&memcg->css, &root_memcg->css); + rcu_read_unlock(); + return ret; } int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *memcg)