diff --git a/mm/slab.h b/mm/slab.h index 29300d7f042e..5274d6af7e58 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -242,10 +242,18 @@ extern unsigned long get_each_object_track(struct kmem_cache *s, int (*fn)(const struct kmem_cache *, const void *, const struct track *, void *), void *private); extern slab_flags_t slub_debug; +static inline bool __slub_debug_enabled(void) +{ + return static_branch_unlikely(&slub_debug_enabled); +} #else static inline void print_tracking(struct kmem_cache *s, void *object) { } +static inline bool __slub_debug_enabled(void) +{ + return false; +} #ifdef CONFIG_SLUB static inline unsigned long get_each_object_track(struct kmem_cache *s, struct page *page, enum track_item alloc, @@ -264,11 +272,10 @@ static inline unsigned long get_each_object_track(struct kmem_cache *s, */ static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t flags) { -#ifdef CONFIG_SLUB_DEBUG - VM_WARN_ON_ONCE(!(flags & SLAB_DEBUG_FLAGS)); - if (static_branch_unlikely(&slub_debug_enabled)) + if (IS_ENABLED(CONFIG_SLUB_DEBUG)) + VM_WARN_ON_ONCE(!(flags & SLAB_DEBUG_FLAGS)); + if (__slub_debug_enabled()) return s->flags & flags; -#endif return false; }