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

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: NMichal 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 2d11085e
...@@ -6046,18 +6046,6 @@ struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg) ...@@ -6046,18 +6046,6 @@ struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg)
} }
EXPORT_SYMBOL(parent_mem_cgroup); 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) static int mem_cgroup_soft_limit_tree_init(void)
{ {
struct mem_cgroup_tree_per_node *rtpn; struct mem_cgroup_tree_per_node *rtpn;
...@@ -6111,7 +6099,6 @@ mem_cgroup_css_alloc(struct cgroup *cont) ...@@ -6111,7 +6099,6 @@ mem_cgroup_css_alloc(struct cgroup *cont)
/* root ? */ /* root ? */
if (cont->parent == NULL) { if (cont->parent == NULL) {
int cpu; int cpu;
enable_swap_cgroup();
parent = NULL; parent = NULL;
if (mem_cgroup_soft_limit_tree_init()) if (mem_cgroup_soft_limit_tree_init())
goto free_out; goto free_out;
...@@ -6800,12 +6787,19 @@ __setup("swapaccount=", enable_swap_account); ...@@ -6800,12 +6787,19 @@ __setup("swapaccount=", enable_swap_account);
static void __init memsw_file_init(void) 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 #else
static void __init memsw_file_init(void) static void __init enable_swap_cgroup(void)
{ {
} }
#endif #endif
...@@ -6819,7 +6813,7 @@ static void __init memsw_file_init(void) ...@@ -6819,7 +6813,7 @@ static void __init memsw_file_init(void)
static int __init mem_cgroup_init(void) static int __init mem_cgroup_init(void)
{ {
hotcpu_notifier(memcg_cpu_hotplug_callback, 0); hotcpu_notifier(memcg_cpu_hotplug_callback, 0);
memsw_file_init(); enable_swap_cgroup();
return 0; return 0;
} }
subsys_initcall(mem_cgroup_init); subsys_initcall(mem_cgroup_init);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册