Commit 6acc8b02517d7063b25490b26215834bd2f363c8
Committed by
Linus Torvalds
1 parent
2d11085e40
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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 <mhocko@suse.cz> Cc: Zhouping Liu <zliu@redhat.com> Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: David Rientjes <rientjes@google.com> Cc: Li Zefan <lizefan@huawei.com> Cc: CAI Qian <caiqian@redhat.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 12 additions and 18 deletions Side-by-side Diff
mm/memcontrol.c
... | ... | @@ -6046,18 +6046,6 @@ |
6046 | 6046 | } |
6047 | 6047 | EXPORT_SYMBOL(parent_mem_cgroup); |
6048 | 6048 | |
6049 | -#ifdef CONFIG_MEMCG_SWAP | |
6050 | -static void __init enable_swap_cgroup(void) | |
6051 | -{ | |
6052 | - if (!mem_cgroup_disabled() && really_do_swap_account) | |
6053 | - do_swap_account = 1; | |
6054 | -} | |
6055 | -#else | |
6056 | -static void __init enable_swap_cgroup(void) | |
6057 | -{ | |
6058 | -} | |
6059 | -#endif | |
6060 | - | |
6061 | 6049 | static int mem_cgroup_soft_limit_tree_init(void) |
6062 | 6050 | { |
6063 | 6051 | struct mem_cgroup_tree_per_node *rtpn; |
... | ... | @@ -6111,7 +6099,6 @@ |
6111 | 6099 | /* root ? */ |
6112 | 6100 | if (cont->parent == NULL) { |
6113 | 6101 | int cpu; |
6114 | - enable_swap_cgroup(); | |
6115 | 6102 | parent = NULL; |
6116 | 6103 | if (mem_cgroup_soft_limit_tree_init()) |
6117 | 6104 | goto free_out; |
6118 | 6105 | |
6119 | 6106 | |
... | ... | @@ -6800,12 +6787,19 @@ |
6800 | 6787 | |
6801 | 6788 | static void __init memsw_file_init(void) |
6802 | 6789 | { |
6803 | - if (really_do_swap_account) | |
6804 | - WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, | |
6805 | - memsw_cgroup_files)); | |
6790 | + WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, memsw_cgroup_files)); | |
6806 | 6791 | } |
6792 | + | |
6793 | +static void __init enable_swap_cgroup(void) | |
6794 | +{ | |
6795 | + if (!mem_cgroup_disabled() && really_do_swap_account) { | |
6796 | + do_swap_account = 1; | |
6797 | + memsw_file_init(); | |
6798 | + } | |
6799 | +} | |
6800 | + | |
6807 | 6801 | #else |
6808 | -static void __init memsw_file_init(void) | |
6802 | +static void __init enable_swap_cgroup(void) | |
6809 | 6803 | { |
6810 | 6804 | } |
6811 | 6805 | #endif |
... | ... | @@ -6819,7 +6813,7 @@ |
6819 | 6813 | static int __init mem_cgroup_init(void) |
6820 | 6814 | { |
6821 | 6815 | hotcpu_notifier(memcg_cpu_hotplug_callback, 0); |
6822 | - memsw_file_init(); | |
6816 | + enable_swap_cgroup(); | |
6823 | 6817 | return 0; |
6824 | 6818 | } |
6825 | 6819 | subsys_initcall(mem_cgroup_init); |