diff options
author | Michal Hocko <mhocko@suse.cz> | 2013-02-22 19:34:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-23 20:50:17 -0500 |
commit | 6acc8b02517d7063b25490b26215834bd2f363c8 (patch) | |
tree | 41838cd43aaae8b75cee1ccb073a4d8620104018 /mm/memcontrol.c | |
parent | 2d11085e404f7b45ac4de60db2c9685e349c172d (diff) |
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>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 30 |
1 files changed, 12 insertions, 18 deletions
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) | |||
6046 | } | 6046 | } |
6047 | EXPORT_SYMBOL(parent_mem_cgroup); | 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 | static int mem_cgroup_soft_limit_tree_init(void) | 6049 | static int mem_cgroup_soft_limit_tree_init(void) |
6062 | { | 6050 | { |
6063 | struct mem_cgroup_tree_per_node *rtpn; | 6051 | struct mem_cgroup_tree_per_node *rtpn; |
@@ -6111,7 +6099,6 @@ mem_cgroup_css_alloc(struct cgroup *cont) | |||
6111 | /* root ? */ | 6099 | /* root ? */ |
6112 | if (cont->parent == NULL) { | 6100 | if (cont->parent == NULL) { |
6113 | int cpu; | 6101 | int cpu; |
6114 | enable_swap_cgroup(); | ||
6115 | parent = NULL; | 6102 | parent = NULL; |
6116 | if (mem_cgroup_soft_limit_tree_init()) | 6103 | if (mem_cgroup_soft_limit_tree_init()) |
6117 | goto free_out; | 6104 | goto free_out; |
@@ -6800,12 +6787,19 @@ __setup("swapaccount=", enable_swap_account); | |||
6800 | 6787 | ||
6801 | static void __init memsw_file_init(void) | 6788 | static void __init memsw_file_init(void) |
6802 | { | 6789 | { |
6803 | if (really_do_swap_account) | 6790 | WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, memsw_cgroup_files)); |
6804 | WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, | 6791 | } |
6805 | memsw_cgroup_files)); | 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 | } | ||
6806 | } | 6799 | } |
6800 | |||
6807 | #else | 6801 | #else |
6808 | static void __init memsw_file_init(void) | 6802 | static void __init enable_swap_cgroup(void) |
6809 | { | 6803 | { |
6810 | } | 6804 | } |
6811 | #endif | 6805 | #endif |
@@ -6819,7 +6813,7 @@ static void __init memsw_file_init(void) | |||
6819 | static int __init mem_cgroup_init(void) | 6813 | static int __init mem_cgroup_init(void) |
6820 | { | 6814 | { |
6821 | hotcpu_notifier(memcg_cpu_hotplug_callback, 0); | 6815 | hotcpu_notifier(memcg_cpu_hotplug_callback, 0); |
6822 | memsw_file_init(); | 6816 | enable_swap_cgroup(); |
6823 | return 0; | 6817 | return 0; |
6824 | } | 6818 | } |
6825 | subsys_initcall(mem_cgroup_init); | 6819 | subsys_initcall(mem_cgroup_init); |