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

From: Andrew Morton
Date: Wed May 12 2021 - 20:37:01 EST


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?