Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b15aac11 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds
Browse files

mm: memcontrol: remove double kmem page_counter init



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: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Cc: Tejun Heo <tj@kernel.org>
Acked-by: default avatarVladimir Davydov <vdavydov@virtuozzo.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6d378dac
Loading
Loading
Loading
Loading
+10 −14
Original line number Original line Diff line number Diff line
@@ -2861,8 +2861,7 @@ static u64 mem_cgroup_read_u64(struct cgroup_subsys_state *css,
}
}


#ifdef CONFIG_MEMCG_KMEM
#ifdef CONFIG_MEMCG_KMEM
static int memcg_activate_kmem(struct mem_cgroup *memcg,
static int memcg_activate_kmem(struct mem_cgroup *memcg)
			       unsigned long nr_pages)
{
{
	int err = 0;
	int err = 0;
	int memcg_id;
	int memcg_id;
@@ -2897,13 +2896,6 @@ static int memcg_activate_kmem(struct mem_cgroup *memcg,
		goto out;
		goto out;
	}
	}


	/*
	 * 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);
	static_branch_inc(&memcg_kmem_enabled_key);
	/*
	/*
	 * A memory cgroup is considered kmem-active as soon as it gets
	 * A memory cgroup is considered kmem-active as soon as it gets
@@ -2924,10 +2916,14 @@ static int memcg_update_kmem_limit(struct mem_cgroup *memcg,
	int ret;
	int ret;


	mutex_lock(&memcg_limit_mutex);
	mutex_lock(&memcg_limit_mutex);
	if (!memcg_kmem_is_active(memcg))
	/* Top-level cgroup doesn't propagate from root */
		ret = memcg_activate_kmem(memcg, limit);
	if (!memcg_kmem_is_active(memcg)) {
	else
		ret = memcg_activate_kmem(memcg);
		if (ret)
			goto out;
	}
	ret = page_counter_limit(&memcg->kmem, limit);
	ret = page_counter_limit(&memcg->kmem, limit);
out:
	mutex_unlock(&memcg_limit_mutex);
	mutex_unlock(&memcg_limit_mutex);
	return ret;
	return ret;
}
}
@@ -2946,7 +2942,7 @@ static int memcg_propagate_kmem(struct mem_cgroup *memcg)
	 * after this point, because it has at least one child already.
	 * after this point, because it has at least one child already.
	 */
	 */
	if (memcg_kmem_is_active(parent))
	if (memcg_kmem_is_active(parent))
		ret = memcg_activate_kmem(memcg, PAGE_COUNTER_MAX);
		ret = memcg_activate_kmem(memcg);
	mutex_unlock(&memcg_limit_mutex);
	mutex_unlock(&memcg_limit_mutex);
	return ret;
	return ret;
}
}