[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZdZCDEFX4_UuHSWR@P9FQF9L96D.corp.robot.car>
Date: Wed, 21 Feb 2024 10:33:48 -0800
From: Roman Gushchin <roman.gushchin@...ux.dev>
To: Vlastimil Babka <vbabka@...e.cz>
Cc: Christoph Lameter <cl@...ux.com>, Pekka Enberg <penberg@...nel.org>,
David Rientjes <rientjes@...gle.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Hyeonggon Yoo <42.hyeyoo@...il.com>,
Andrey Ryabinin <ryabinin.a.a@...il.com>,
Alexander Potapenko <glider@...gle.com>,
Andrey Konovalov <andreyknvl@...il.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Vincenzo Frascino <vincenzo.frascino@....com>,
Zheng Yejian <zhengyejian1@...wei.com>,
Xiongwei Song <xiongwei.song@...driver.com>,
Chengming Zhou <chengming.zhou@...ux.dev>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, kasan-dev@...glegroups.com
Subject: Re: [PATCH 2/3] mm, slab: use an enum to define SLAB_ cache creation
flags
On Tue, Feb 20, 2024 at 05:58:26PM +0100, Vlastimil Babka wrote:
> The values of SLAB_ cache creation flagsare defined by hand, which is
> tedious and error-prone. Use an enum to assign the bit number and a
> __SF_BIT() macro to #define the final flags.
>
> This renumbers the flag values, which is OK as they are only used
> internally.
>
> Signed-off-by: Vlastimil Babka <vbabka@...e.cz>
> ---
> include/linux/slab.h | 81 ++++++++++++++++++++++++++++++++++++++--------------
> mm/slub.c | 6 ++--
> 2 files changed, 63 insertions(+), 24 deletions(-)
>
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 6252f44115c2..f893a132dd5a 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -21,29 +21,68 @@
> #include <linux/cleanup.h>
> #include <linux/hash.h>
>
> +enum _slab_flag_bits {
> + _SLAB_CONSISTENCY_CHECKS,
> + _SLAB_RED_ZONE,
> + _SLAB_POISON,
> + _SLAB_KMALLOC,
> + _SLAB_HWCACHE_ALIGN,
> + _SLAB_CACHE_DMA,
> + _SLAB_CACHE_DMA32,
> + _SLAB_STORE_USER,
> + _SLAB_PANIC,
> + _SLAB_TYPESAFE_BY_RCU,
> + _SLAB_TRACE,
> +#ifdef CONFIG_DEBUG_OBJECTS
> + _SLAB_DEBUG_OBJECTS,
> +#endif
> + _SLAB_NOLEAKTRACE,
> + _SLAB_NO_MERGE,
> +#ifdef CONFIG_FAILSLAB
> + _SLAB_FAILSLAB,
> +#endif
> +#ifdef CONFIG_MEMCG_KMEM
> + _SLAB_ACCOUNT,
> +#endif
> +#ifdef CONFIG_KASAN_GENERIC
> + _SLAB_KASAN,
> +#endif
> + _SLAB_NO_USER_FLAGS,
> +#ifdef CONFIG_KFENCE
> + _SLAB_SKIP_KFENCE,
> +#endif
> +#ifndef CONFIG_SLUB_TINY
> + _SLAB_RECLAIM_ACCOUNT,
> +#endif
> + _SLAB_OBJECT_POISON,
> + _SLAB_CMPXCHG_DOUBLE,
> + _SLAB_FLAGS_LAST_BIT
> +};
> +
> +#define __SF_BIT(nr) ((slab_flags_t __force)(1U << (nr)))
I'd rename it to (__)SLAB_FLAG_BIT(), as SF is a bit cryptic, but not a strong
preference. Otherwise looks really good to me, nice cleanup.
Reviewed-by: Roman Gushchin <roman.gushchin@...ux.dev>
Thanks!
Powered by blists - more mailing lists