summaryrefslogtreecommitdiff
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorRoman Gushchin <guro@fb.com>2021-06-03 04:09:30 +0300
committerDennis Zhou <dennis@kernel.org>2021-06-05 23:41:14 +0300
commit4d5c8aedc8aa6a1f5d1b06eb4f5517dc60dd9440 (patch)
tree73d4b3c792664e007496ef6a5463b2aec1af6fe3 /mm/memcontrol.c
parent0f0cace35fa655d383b64b4fce83a44d530c9aaf (diff)
downloadlinux-4d5c8aedc8aa6a1f5d1b06eb4f5517dc60dd9440.tar.xz
mm, memcg: introduce mem_cgroup_kmem_disabled()
Introduce a new mem_cgroup_kmem_disabled() helper, similar to mem_cgroup_disabled(), to check whether the kernel memory accounting is off. A user could disable it using a boot option to eliminate some associated costs. The helper can be used outside of memcontrol.c to dynamically disable the kmem-related code. The returned value is stable after the kernel initialization is finished. Signed-off-by: Roman Gushchin <guro@fb.com> Signed-off-by: Dennis Zhou <dennis@kernel.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e6203ee24a11..1fa9b00ec71d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -255,6 +255,11 @@ struct cgroup_subsys_state *vmpressure_to_css(struct vmpressure *vmpr)
#ifdef CONFIG_MEMCG_KMEM
extern spinlock_t css_set_lock;
+bool mem_cgroup_kmem_disabled(void)
+{
+ return cgroup_memory_nokmem;
+}
+
static int __memcg_kmem_charge(struct mem_cgroup *memcg, gfp_t gfp,
unsigned int nr_pages);
static void __memcg_kmem_uncharge(struct mem_cgroup *memcg,