[PATCH -mmotm] mm: slab: exclude slabinfo dump for slob

From: Yang Shi
Date: Sun Oct 08 2017 - 15:48:24 EST


CONFIG_SLABINFO is removed, but slabinfo dump is not applicable to slob,
protect slbinfo stats from !CONFIG_SLOB to avoid the below compile
error reported by 0-DAY kernel test:

mm/slab_common.o: In function `dump_unreclaimable_slab':
>> mm/slab_common.c:1298: undefined reference to `get_slabinfo'

Signed-off-by: Yang Shi <yang.s@xxxxxxxxxxxxxxx>
---
Andrew,
This should be able to be fold into mm-oom-show-unreclaimable-slab-info-when-unreclaimable-slabs-user-memory.patch in -mm tree.

mm/slab.h | 6 ++++++
mm/slab_common.c | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/mm/slab.h b/mm/slab.h
index 6fc4d5d..8dc504a 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -505,7 +505,13 @@ static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node)
void memcg_slab_stop(struct seq_file *m, void *p);
int memcg_slab_show(struct seq_file *m, void *p);

+#ifdef CONFIG_SLOB
+static void inline dump_unreclaimable_slab(void)
+{
+}
+#else
void dump_unreclaimable_slab(void);
+#endif

void ___cache_free(struct kmem_cache *cache, void *x, unsigned long addr);

diff --git a/mm/slab_common.c b/mm/slab_common.c
index 5c8fac5..edc5f5f 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -1183,6 +1183,7 @@ void cache_random_seq_destroy(struct kmem_cache *cachep)
}
#endif /* CONFIG_SLAB_FREELIST_RANDOM */

+#ifndef CONFIG_SLOB
#ifdef CONFIG_SLAB
#define SLABINFO_RIGHTS (S_IWUSR | S_IRUSR)
#else
@@ -1313,7 +1314,7 @@ void dump_unreclaimable_slab(void)
mutex_unlock(&slab_mutex);
}

-#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
+#if defined(CONFIG_MEMCG)
void *memcg_slab_start(struct seq_file *m, loff_t *pos)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));
@@ -1387,6 +1388,7 @@ static int __init slab_proc_init(void)
return 0;
}
module_init(slab_proc_init);
+#endif /* !CONFIG_SLOB */

static __always_inline void *__do_krealloc(const void *p, size_t new_size,
gfp_t flags)
--
1.8.3.1