The cgroup_memory_nokmem is already a global variable, it is unnecessary to define a global function of mem_cgroup_kmem_disabled(). Just move it to memcontrol.h and mark inline on it. slab_common.c already includes memcontrol.h, replace cgroup_memory_nokmem with mem_cgroup_kmem_disabled(). Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> --- include/linux/memcontrol.h | 8 +++++++- mm/internal.h | 5 ----- mm/memcontrol.c | 5 ----- mm/slab_common.c | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 3096c9a0ee01..e194d90aff56 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1639,7 +1639,13 @@ static inline void set_shrinker_bit(struct mem_cgroup *memcg, #endif #ifdef CONFIG_MEMCG_KMEM -bool mem_cgroup_kmem_disabled(void); +extern bool cgroup_memory_nokmem; + +static inline bool mem_cgroup_kmem_disabled(void) +{ + return cgroup_memory_nokmem; +} + int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order); void __memcg_kmem_uncharge_page(struct page *page, int order); diff --git a/mm/internal.h b/mm/internal.h index cf3cb933eba3..649684e20fe4 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -116,11 +116,6 @@ extern void putback_lru_page(struct page *page); extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address); /* - * in mm/memcontrol.c: - */ -extern bool cgroup_memory_nokmem; - -/* * in mm/page_alloc.c */ diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b762215d73eb..528b134ca50c 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -264,11 +264,6 @@ struct mem_cgroup *vmpressure_to_memcg(struct vmpressure *vmpr) #ifdef CONFIG_MEMCG_KMEM extern spinlock_t css_set_lock; -bool mem_cgroup_kmem_disabled(void) -{ - return cgroup_memory_nokmem; -} - static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg, unsigned int nr_pages); diff --git a/mm/slab_common.c b/mm/slab_common.c index ec2bb0beed75..4c0549e0f349 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -857,7 +857,7 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) if (type == KMALLOC_RECLAIM) { flags |= SLAB_RECLAIM_ACCOUNT; } else if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_CGROUP)) { - if (cgroup_memory_nokmem) { + if (mem_cgroup_kmem_disabled()) { kmalloc_caches[type][idx] = kmalloc_caches[KMALLOC_NORMAL][idx]; return; } -- 2.11.0