Re: [PATCH v5 2/3] mm: memcg/slab: Create a new set of kmalloc-cg-<n> caches

From: Waiman Long
Date: Thu May 13 2021 - 12:22:35 EST


On 5/12/21 8:32 PM, Andrew Morton wrote:
On Wed, 12 May 2021 10:54:19 -0400 Waiman Long <llong@xxxxxxxxxx> wrote:

include/linux/slab.h | 42 +++++++++++++++++++++++++++++++++---------
mm/slab_common.c | 25 +++++++++++++++++--------
2 files changed, 50 insertions(+), 17 deletions(-)
The following are the diff's from previous version. It turns out that
the previous patch doesn't work if CONFIG_ZONE_DMA isn't defined.

diff --git a/include/linux/slab.h b/include/linux/slab.h
index a51cad5f561c..aa7f6c222a60 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -312,16 +312,17 @@ static inline void __check_heap_object(const void
*ptr, un
signed long n,
  */
 enum kmalloc_cache_type {
     KMALLOC_NORMAL = 0,
-#ifdef CONFIG_MEMCG_KMEM
-    KMALLOC_CGROUP,
-#else
+#ifndef CONFIG_ZONE_DMA
+    KMALLOC_DMA = KMALLOC_NORMAL,
+#endif
+#ifndef CONFIG_MEMCG_KMEM
     KMALLOC_CGROUP = KMALLOC_NORMAL,
+#else
+    KMALLOC_CGROUP,
 #endif
     KMALLOC_RECLAIM,
 #ifdef CONFIG_ZONE_DMA
     KMALLOC_DMA,
-#else
-    KMALLOC_DMA = KMALLOC_NORMAL,
 #endif
     NR_KMALLOC_TYPES
 };
I assume this fixes
https://lkml.kernel.org/r/20210512152806.2492ca42@xxxxxxxxxxxxxxxx?

Yes.

Cheers,
Longman