Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()

From: Pekka Enberg
Date: Wed Apr 24 2013 - 03:31:46 EST


Hello,

On Tue, Apr 23, 2013 at 12:16 AM, Andrew Morton
<akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> The patch made index_of() weaker!
>
> It's probably all a bit academic, given that linux-next does
>
> -/*
> - * This function must be completely optimized away if a constant is passed to
> - * it. Mostly the same as what is in linux/slab.h except it returns an index.
> - */
> -static __always_inline int index_of(const size_t size)
> -{
> - extern void __bad_size(void);
> -
> - if (__builtin_constant_p(size)) {
> - int i = 0;
> -
> -#define CACHE(x) \
> - if (size <=x) \
> - return i; \
> - else \
> - i++;
> -#include <linux/kmalloc_sizes.h>
> -#undef CACHE
> - __bad_size();
> - } else
> - __bad_size();
> - return 0;
> -}
> -

Yup, Christoph nuked it in the following commit:

https://git.kernel.org/cgit/linux/kernel/git/penberg/linux.git/commit/?h=slab/next&id=2c59dd6544212faa5ce761920d2251f4152f408d

Pekka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/