Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

slub: fix handling of oversized slabs

I'm getting zillions of undefined references to __kmalloc_size_too_large on
alpha. For some reason alpha is building out-of-line copies of kmalloc_slab()
into lots of compilation units.

It turns out that gcc just isn't smart enough to work out that
__builtin_contant_p(size)==true implies that __builtin_contant_p(index)==true.

So let's give it a bit of help.

Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andrew Morton and committed by
Linus Torvalds
ade3aff2 0b44f7a5

+6 -1
+6 -1
include/linux/slub_def.h
··· 145 145 if (index == 0) 146 146 return NULL; 147 147 148 - if (index < 0) { 148 + /* 149 + * This function only gets expanded if __builtin_constant_p(size), so 150 + * testing it here shouldn't be needed. But some versions of gcc need 151 + * help. 152 + */ 153 + if (__builtin_constant_p(size) && index < 0) { 149 154 /* 150 155 * Generate a link failure. Would be great if we could 151 156 * do something to stop the compile here.