linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [Patch v3 -mm 1/2] mm/slab: add is_kmalloc_cache() helper function
@ 2023-01-04  6:06 Feng Tang
  2023-01-04  6:06 ` [Patch v3 -mm 2/2] mm/kasan: simplify and refine kasan_cache code Feng Tang
  2023-01-05  1:41 ` [Patch v3 -mm 1/2] mm/slab: add is_kmalloc_cache() helper function David Rientjes
  0 siblings, 2 replies; 5+ messages in thread
From: Feng Tang @ 2023-01-04  6:06 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, Christoph Lameter, Pekka Enberg,
	David Rientjes, Joonsoo Kim, Roman Gushchin, Hyeonggon Yoo,
	Andrey Konovalov, Dmitry Vyukov, Andrey Ryabinin,
	Alexander Potapenko, Vincenzo Frascino
  Cc: linux-mm, kasan-dev, linux-kernel, Feng Tang

commit 6edf2576a6cc ("mm/slub: enable debugging memory wasting of
kmalloc") introduces 'SLAB_KMALLOC' bit specifying whether a
kmem_cache is a kmalloc cache for slab/slub (slob doesn't have
dedicated kmalloc caches).

Add a helper inline function for other components like kasan to
simplify code.

Signed-off-by: Feng Tang <feng.tang@intel.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
---
changlog:

  since v2:
  * fix type in subject(Vlastimil Babka)
  * collect Acked-by tag
  
  since v1:
  * don't use macro for the helper (Andrew Morton)
  * place the inline function in mm/slab.h to solve data structure
    definition issue (Vlastimil Babka)

 mm/slab.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/mm/slab.h b/mm/slab.h
index 7cc432969945..63fb4c00d529 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -323,6 +323,14 @@ static inline slab_flags_t kmem_cache_flags(unsigned int object_size,
 }
 #endif
 
+static inline bool is_kmalloc_cache(struct kmem_cache *s)
+{
+#ifndef CONFIG_SLOB
+	return (s->flags & SLAB_KMALLOC);
+#else
+	return false;
+#endif
+}
 
 /* Legal flag mask for kmem_cache_create(), for various configurations */
 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | \
-- 
2.34.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-05  1:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04  6:06 [Patch v3 -mm 1/2] mm/slab: add is_kmalloc_cache() helper function Feng Tang
2023-01-04  6:06 ` [Patch v3 -mm 2/2] mm/kasan: simplify and refine kasan_cache code Feng Tang
2023-01-04 13:48   ` Vlastimil Babka
2023-01-05  1:42   ` David Rientjes
2023-01-05  1:41 ` [Patch v3 -mm 1/2] mm/slab: add is_kmalloc_cache() helper function David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox