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

Commit 04823c83 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Linus Torvalds
Browse files

mm: memcontrol: allow to disable kmem accounting for cgroup2



Kmem accounting might incur overhead that some users can't put up with.
Besides, the implementation is still considered unstable.  So let's
provide a way to disable it for those users who aren't happy with it.

To disable kmem accounting for cgroup2, pass cgroup.memory=nokmem at
boot time.

Signed-off-by: default avatarVladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 52c29b04
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -611,6 +611,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
	cgroup.memory=	[KNL] Pass options to the cgroup memory controller.
	cgroup.memory=	[KNL] Pass options to the cgroup memory controller.
			Format: <string>
			Format: <string>
			nosocket -- Disable socket memory accounting.
			nosocket -- Disable socket memory accounting.
			nokmem -- Disable kernel memory accounting.


	checkreqprot	[SELINUX] Set initial checkreqprot flag value.
	checkreqprot	[SELINUX] Set initial checkreqprot flag value.
			Format: { "0" | "1" }
			Format: { "0" | "1" }
+7 −2
Original line number Original line Diff line number Diff line
@@ -83,6 +83,9 @@ struct mem_cgroup *root_mem_cgroup __read_mostly;
/* Socket memory accounting disabled? */
/* Socket memory accounting disabled? */
static bool cgroup_memory_nosocket;
static bool cgroup_memory_nosocket;


/* Kernel memory accounting disabled? */
static bool cgroup_memory_nokmem;

/* Whether the swap controller is active */
/* Whether the swap controller is active */
#ifdef CONFIG_MEMCG_SWAP
#ifdef CONFIG_MEMCG_SWAP
int do_swap_account __read_mostly;
int do_swap_account __read_mostly;
@@ -2925,8 +2928,8 @@ static int memcg_propagate_kmem(struct mem_cgroup *memcg)
	 * onlined after this point, because it has at least one child
	 * onlined after this point, because it has at least one child
	 * already.
	 * already.
	 */
	 */
	if (cgroup_subsys_on_dfl(memory_cgrp_subsys) ||
	if (memcg_kmem_online(parent) ||
	    memcg_kmem_online(parent))
	    (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nokmem))
		ret = memcg_online_kmem(memcg);
		ret = memcg_online_kmem(memcg);
	mutex_unlock(&memcg_limit_mutex);
	mutex_unlock(&memcg_limit_mutex);
	return ret;
	return ret;
@@ -5638,6 +5641,8 @@ static int __init cgroup_memory(char *s)
			continue;
			continue;
		if (!strcmp(token, "nosocket"))
		if (!strcmp(token, "nosocket"))
			cgroup_memory_nosocket = true;
			cgroup_memory_nosocket = true;
		if (!strcmp(token, "nokmem"))
			cgroup_memory_nokmem = true;
	}
	}
	return 0;
	return 0;
}
}