Commit 8787a1df30c7b75521fe8cbed42895d47e6b8d52
Committed by
Linus Torvalds
1 parent
0e50ce3b50
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
memcg: move mem_cgroup_soft_limit_tree_init to mem_cgroup_init
Per-node-zone soft limit tree is currently initialized when the root cgroup is created which is OK but it pointlessly pollutes memcg allocation code with something that can be called when the memcg subsystem is initialized by mem_cgroup_init along with other controller specific parts. While we are at it let's make mem_cgroup_soft_limit_tree_init void because it doesn't make much sense to report memory failure because if we fail to allocate memory that early during the boot then we are screwed anyway (this saves some code). Signed-off-by: Michal Hocko <mhocko@suse.cz> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Tejun Heo <htejun@gmail.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 3 additions and 16 deletions Side-by-side Diff
mm/memcontrol.c
... | ... | @@ -6052,7 +6052,7 @@ |
6052 | 6052 | } |
6053 | 6053 | EXPORT_SYMBOL(parent_mem_cgroup); |
6054 | 6054 | |
6055 | -static int mem_cgroup_soft_limit_tree_init(void) | |
6055 | +static void __init mem_cgroup_soft_limit_tree_init(void) | |
6056 | 6056 | { |
6057 | 6057 | struct mem_cgroup_tree_per_node *rtpn; |
6058 | 6058 | struct mem_cgroup_tree_per_zone *rtpz; |
... | ... | @@ -6063,8 +6063,7 @@ |
6063 | 6063 | if (!node_state(node, N_NORMAL_MEMORY)) |
6064 | 6064 | tmp = -1; |
6065 | 6065 | rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, tmp); |
6066 | - if (!rtpn) | |
6067 | - goto err_cleanup; | |
6066 | + BUG_ON(!rtpn); | |
6068 | 6067 | |
6069 | 6068 | soft_limit_tree.rb_tree_per_node[node] = rtpn; |
6070 | 6069 | |
... | ... | @@ -6074,17 +6073,6 @@ |
6074 | 6073 | spin_lock_init(&rtpz->lock); |
6075 | 6074 | } |
6076 | 6075 | } |
6077 | - return 0; | |
6078 | - | |
6079 | -err_cleanup: | |
6080 | - for_each_node(node) { | |
6081 | - if (!soft_limit_tree.rb_tree_per_node[node]) | |
6082 | - break; | |
6083 | - kfree(soft_limit_tree.rb_tree_per_node[node]); | |
6084 | - soft_limit_tree.rb_tree_per_node[node] = NULL; | |
6085 | - } | |
6086 | - return 1; | |
6087 | - | |
6088 | 6076 | } |
6089 | 6077 | |
6090 | 6078 | static struct cgroup_subsys_state * __ref |
... | ... | @@ -6106,8 +6094,6 @@ |
6106 | 6094 | if (cont->parent == NULL) { |
6107 | 6095 | int cpu; |
6108 | 6096 | |
6109 | - if (mem_cgroup_soft_limit_tree_init()) | |
6110 | - goto free_out; | |
6111 | 6097 | root_mem_cgroup = memcg; |
6112 | 6098 | for_each_possible_cpu(cpu) { |
6113 | 6099 | struct memcg_stock_pcp *stock = |
... | ... | @@ -6850,6 +6836,7 @@ |
6850 | 6836 | { |
6851 | 6837 | hotcpu_notifier(memcg_cpu_hotplug_callback, 0); |
6852 | 6838 | enable_swap_cgroup(); |
6839 | + mem_cgroup_soft_limit_tree_init(); | |
6853 | 6840 | return 0; |
6854 | 6841 | } |
6855 | 6842 | subsys_initcall(mem_cgroup_init); |