[PATCH] mm, slub: introduce kmem_cache_debug_flags()-fix

From: Vlastimil Babka
Date: Thu Jun 18 2020 - 04:34:53 EST


Change return from int to bool, per Kees.
Add VM_WARN_ON_ONCE() for invalid flags, per Roman.

Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx>
---
mm/slub.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index c8e8b4ae2451..59d19c64069e 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -127,16 +127,17 @@ DEFINE_STATIC_KEY_FALSE(slub_debug_enabled);
* cache. Use only for flags parsed by setup_slub_debug() as it also enables
* the static key.
*/
-static inline int kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t flags)
+static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t flags)
{
+ VM_WARN_ON_ONCE(!(flags & SLAB_DEBUG_FLAGS));
#ifdef CONFIG_SLUB_DEBUG
if (static_branch_unlikely(&slub_debug_enabled))
return s->flags & flags;
#endif
- return 0;
+ return false;
}

-static inline int kmem_cache_debug(struct kmem_cache *s)
+static inline bool kmem_cache_debug(struct kmem_cache *s)
{
return kmem_cache_debug_flags(s, SLAB_DEBUG_FLAGS);
}
--
2.27.0