@@ -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);
@@ -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
*/
@@ -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);
@@ -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;
}
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@bytedance.com> --- 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(-)