diff options
author | Roman Gushchin <guro@fb.com> | 2021-06-03 04:09:30 +0300 |
---|---|---|
committer | Dennis Zhou <dennis@kernel.org> | 2021-06-05 23:41:14 +0300 |
commit | 4d5c8aedc8aa6a1f5d1b06eb4f5517dc60dd9440 (patch) | |
tree | 73d4b3c792664e007496ef6a5463b2aec1af6fe3 /include/linux/memcontrol.h | |
parent | 0f0cace35fa655d383b64b4fce83a44d530c9aaf (diff) | |
download | linux-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 'include/linux/memcontrol.h')
-rw-r--r-- | include/linux/memcontrol.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 0c04d39a7967..8ef51c58f470 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1583,6 +1583,7 @@ static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg, #endif #ifdef CONFIG_MEMCG_KMEM +bool mem_cgroup_kmem_disabled(void); int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order); void __memcg_kmem_uncharge_page(struct page *page, int order); @@ -1636,6 +1637,10 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg) struct mem_cgroup *mem_cgroup_from_obj(void *p); #else +static inline bool mem_cgroup_kmem_disabled(void) +{ + return true; +} static inline int memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order) |