From: Michal Hocko Date: Sat, 23 Feb 2013 00:34:45 +0000 (-0800) Subject: memcg: clean up swap accounting initialization code X-Git-Tag: firefly_0821_release~3680^2~1052^2~62 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6acc8b02517d7063b25490b26215834bd2f363c8;p=firefly-linux-kernel-4.4.55.git memcg: clean up swap accounting initialization code Memcg swap accounting is currently enabled by enable_swap_cgroup when the root cgroup is created. mem_cgroup_init acts as a memcg subsystem initializer which sounds like a much better place for enable_swap_cgroup as well. We already register memsw files from there so it makes a lot of sense to merge those two into a single enable_swap_cgroup function. This patch doesn't introduce any semantic changes. Signed-off-by: Michal Hocko Cc: Zhouping Liu Cc: Kamezawa Hiroyuki Cc: David Rientjes Cc: Li Zefan Cc: CAI Qian Cc: Tejun Heo Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 00ce03e8a277..972f822b142b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6046,18 +6046,6 @@ struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg) } EXPORT_SYMBOL(parent_mem_cgroup); -#ifdef CONFIG_MEMCG_SWAP -static void __init enable_swap_cgroup(void) -{ - if (!mem_cgroup_disabled() && really_do_swap_account) - do_swap_account = 1; -} -#else -static void __init enable_swap_cgroup(void) -{ -} -#endif - static int mem_cgroup_soft_limit_tree_init(void) { struct mem_cgroup_tree_per_node *rtpn; @@ -6111,7 +6099,6 @@ mem_cgroup_css_alloc(struct cgroup *cont) /* root ? */ if (cont->parent == NULL) { int cpu; - enable_swap_cgroup(); parent = NULL; if (mem_cgroup_soft_limit_tree_init()) goto free_out; @@ -6800,12 +6787,19 @@ __setup("swapaccount=", enable_swap_account); static void __init memsw_file_init(void) { - if (really_do_swap_account) - WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, - memsw_cgroup_files)); + WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, memsw_cgroup_files)); +} + +static void __init enable_swap_cgroup(void) +{ + if (!mem_cgroup_disabled() && really_do_swap_account) { + do_swap_account = 1; + memsw_file_init(); + } } + #else -static void __init memsw_file_init(void) +static void __init enable_swap_cgroup(void) { } #endif @@ -6819,7 +6813,7 @@ static void __init memsw_file_init(void) static int __init mem_cgroup_init(void) { hotcpu_notifier(memcg_cpu_hotplug_callback, 0); - memsw_file_init(); + enable_swap_cgroup(); return 0; } subsys_initcall(mem_cgroup_init);