提交 c3cecc68 编写于 作者: M Michal Hocko 提交者: Linus Torvalds

memcg: free entries in soft_limit_tree if allocation fails

If we are not able to allocate tree nodes for all NUMA nodes then we
should release those that were allocated.
Signed-off-by: NMichal Hocko <mhocko@suse.cz>
Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9fb4b7cc
...@@ -4960,7 +4960,7 @@ static int mem_cgroup_soft_limit_tree_init(void) ...@@ -4960,7 +4960,7 @@ static int mem_cgroup_soft_limit_tree_init(void)
tmp = -1; tmp = -1;
rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, tmp); rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, tmp);
if (!rtpn) if (!rtpn)
return 1; goto err_cleanup;
soft_limit_tree.rb_tree_per_node[node] = rtpn; soft_limit_tree.rb_tree_per_node[node] = rtpn;
...@@ -4971,6 +4971,16 @@ static int mem_cgroup_soft_limit_tree_init(void) ...@@ -4971,6 +4971,16 @@ static int mem_cgroup_soft_limit_tree_init(void)
} }
} }
return 0; return 0;
err_cleanup:
for_each_node_state(node, N_POSSIBLE) {
if (!soft_limit_tree.rb_tree_per_node[node])
break;
kfree(soft_limit_tree.rb_tree_per_node[node]);
soft_limit_tree.rb_tree_per_node[node] = NULL;
}
return 1;
} }
static struct cgroup_subsys_state * __ref static struct cgroup_subsys_state * __ref
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册