aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1f14a430c656..f009a14918d2 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6007,7 +6007,6 @@ static struct cftype mem_cgroup_files[] = {
6007 }, 6007 },
6008 { 6008 {
6009 .name = "use_hierarchy", 6009 .name = "use_hierarchy",
6010 .flags = CFTYPE_INSANE,
6011 .write_u64 = mem_cgroup_hierarchy_write, 6010 .write_u64 = mem_cgroup_hierarchy_write,
6012 .read_u64 = mem_cgroup_hierarchy_read, 6011 .read_u64 = mem_cgroup_hierarchy_read,
6013 }, 6012 },
@@ -6411,6 +6410,29 @@ static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
6411 __mem_cgroup_free(memcg); 6410 __mem_cgroup_free(memcg);
6412} 6411}
6413 6412
6413/**
6414 * mem_cgroup_css_reset - reset the states of a mem_cgroup
6415 * @css: the target css
6416 *
6417 * Reset the states of the mem_cgroup associated with @css. This is
6418 * invoked when the userland requests disabling on the default hierarchy
6419 * but the memcg is pinned through dependency. The memcg should stop
6420 * applying policies and should revert to the vanilla state as it may be
6421 * made visible again.
6422 *
6423 * The current implementation only resets the essential configurations.
6424 * This needs to be expanded to cover all the visible parts.
6425 */
6426static void mem_cgroup_css_reset(struct cgroup_subsys_state *css)
6427{
6428 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
6429
6430 mem_cgroup_resize_limit(memcg, ULLONG_MAX);
6431 mem_cgroup_resize_memsw_limit(memcg, ULLONG_MAX);
6432 memcg_update_kmem_limit(memcg, ULLONG_MAX);
6433 res_counter_set_soft_limit(&memcg->res, ULLONG_MAX);
6434}
6435
6414#ifdef CONFIG_MMU 6436#ifdef CONFIG_MMU
6415/* Handlers for move charge at task migration. */ 6437/* Handlers for move charge at task migration. */
6416#define PRECHARGE_COUNT_AT_ONCE 256 6438#define PRECHARGE_COUNT_AT_ONCE 256
@@ -7005,16 +7027,17 @@ static void mem_cgroup_move_task(struct cgroup_subsys_state *css,
7005 7027
7006/* 7028/*
7007 * Cgroup retains root cgroups across [un]mount cycles making it necessary 7029 * Cgroup retains root cgroups across [un]mount cycles making it necessary
7008 * to verify sane_behavior flag on each mount attempt. 7030 * to verify whether we're attached to the default hierarchy on each mount
7031 * attempt.
7009 */ 7032 */
7010static void mem_cgroup_bind(struct cgroup_subsys_state *root_css) 7033static void mem_cgroup_bind(struct cgroup_subsys_state *root_css)
7011{ 7034{
7012 /* 7035 /*
7013 * use_hierarchy is forced with sane_behavior. cgroup core 7036 * use_hierarchy is forced on the default hierarchy. cgroup core
7014 * guarantees that @root doesn't have any children, so turning it 7037 * guarantees that @root doesn't have any children, so turning it
7015 * on for the root memcg is enough. 7038 * on for the root memcg is enough.
7016 */ 7039 */
7017 if (cgroup_sane_behavior(root_css->cgroup)) 7040 if (cgroup_on_dfl(root_css->cgroup))
7018 mem_cgroup_from_css(root_css)->use_hierarchy = true; 7041 mem_cgroup_from_css(root_css)->use_hierarchy = true;
7019} 7042}
7020 7043
@@ -7023,11 +7046,12 @@ struct cgroup_subsys memory_cgrp_subsys = {
7023 .css_online = mem_cgroup_css_online, 7046 .css_online = mem_cgroup_css_online,
7024 .css_offline = mem_cgroup_css_offline, 7047 .css_offline = mem_cgroup_css_offline,
7025 .css_free = mem_cgroup_css_free, 7048 .css_free = mem_cgroup_css_free,
7049 .css_reset = mem_cgroup_css_reset,
7026 .can_attach = mem_cgroup_can_attach, 7050 .can_attach = mem_cgroup_can_attach,
7027 .cancel_attach = mem_cgroup_cancel_attach, 7051 .cancel_attach = mem_cgroup_cancel_attach,
7028 .attach = mem_cgroup_move_task, 7052 .attach = mem_cgroup_move_task,
7029 .bind = mem_cgroup_bind, 7053 .bind = mem_cgroup_bind,
7030 .base_cftypes = mem_cgroup_files, 7054 .legacy_cftypes = mem_cgroup_files,
7031 .early_init = 0, 7055 .early_init = 0,
7032}; 7056};
7033 7057
@@ -7044,7 +7068,8 @@ __setup("swapaccount=", enable_swap_account);
7044 7068
7045static void __init memsw_file_init(void) 7069static void __init memsw_file_init(void)
7046{ 7070{
7047 WARN_ON(cgroup_add_cftypes(&memory_cgrp_subsys, memsw_cgroup_files)); 7071 WARN_ON(cgroup_add_legacy_cftypes(&memory_cgrp_subsys,
7072 memsw_cgroup_files));
7048} 7073}
7049 7074
7050static void __init enable_swap_cgroup(void) 7075static void __init enable_swap_cgroup(void)