Re: [PATCH -next 1/2] mm/slab: add is_kmalloc_cache() helper macro

From: Andrew Morton
Date: Tue Nov 22 2022 - 18:17:24 EST


On Tue, 22 Nov 2022 13:30:19 +0800 Feng Tang <feng.tang@xxxxxxxxx> wrote:

> > If so, that's always best. For (silly) example, consider the behaviour
> > of
> >
> > x = is_kmalloc_cache(s++);
> >
> > with and without CONFIG_SLOB.
>
> Another solution I can think of is putting the implementation into
> slab_common.c, like the below?

I'm not sure that's much of an improvement on the macro :(

How about we go with the macro and avoid the
expression-with-side-effects gotcha (and the potential CONFIG_SLOB=n
unused-variable gotcha)? That would involve evaluating the arg within
the CONFIG_SLOB=y version of the macro.