The kmem page_counter's limit is initialized to PAGE_COUNTER_MAX inside
mem_cgroup_css_online(). There is no need to repeat this from
memcg_propagate_kmem().
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Tejun Heo <tj@kernel.org>
Acked-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
}
#ifdef CONFIG_MEMCG_KMEM
}
#ifdef CONFIG_MEMCG_KMEM
-static int memcg_activate_kmem(struct mem_cgroup *memcg,
- unsigned long nr_pages)
+static int memcg_activate_kmem(struct mem_cgroup *memcg)
{
int err = 0;
int memcg_id;
{
int err = 0;
int memcg_id;
- /*
- * We couldn't have accounted to this cgroup, because it hasn't got
- * activated yet, so this should succeed.
- */
- err = page_counter_limit(&memcg->kmem, nr_pages);
- VM_BUG_ON(err);
-
static_branch_inc(&memcg_kmem_enabled_key);
/*
* A memory cgroup is considered kmem-active as soon as it gets
static_branch_inc(&memcg_kmem_enabled_key);
/*
* A memory cgroup is considered kmem-active as soon as it gets
int ret;
mutex_lock(&memcg_limit_mutex);
int ret;
mutex_lock(&memcg_limit_mutex);
- if (!memcg_kmem_is_active(memcg))
- ret = memcg_activate_kmem(memcg, limit);
- else
- ret = page_counter_limit(&memcg->kmem, limit);
+ /* Top-level cgroup doesn't propagate from root */
+ if (!memcg_kmem_is_active(memcg)) {
+ ret = memcg_activate_kmem(memcg);
+ if (ret)
+ goto out;
+ }
+ ret = page_counter_limit(&memcg->kmem, limit);
+out:
mutex_unlock(&memcg_limit_mutex);
return ret;
}
mutex_unlock(&memcg_limit_mutex);
return ret;
}
* after this point, because it has at least one child already.
*/
if (memcg_kmem_is_active(parent))
* after this point, because it has at least one child already.
*/
if (memcg_kmem_is_active(parent))
- ret = memcg_activate_kmem(memcg, PAGE_COUNTER_MAX);
+ ret = memcg_activate_kmem(memcg);
mutex_unlock(&memcg_limit_mutex);
return ret;
}
mutex_unlock(&memcg_limit_mutex);
return ret;
}