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

Configure Feed

Select the types of activity you want to include in your feed.

[PATCH] Module per-cpu alignment cannot always be met

The module code assumes noone will ever ask for a per-cpu area more than
SMP_CACHE_BYTES aligned. However, as these cases show, gcc asks sometimes
asks for 32-byte alignment for the per-cpu section on a module, and if
CONFIG_X86_L1_CACHE_SHIFT is 4, we hit that BUG_ON(). This is obviously an
unusual combination, as there have been few reports, but better to warn
than die.

See:
http://www.ussg.iu.edu/hypermail/linux/kernel/0409.0/0768.html

And more recently:
http://bugs.gentoo.org/show_bug.cgi?id=97006

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Rusty Russell and committed by
Linus Torvalds
842bbaaa 561fb765

+11 -4
+11 -4
kernel/module.c
··· 250 250 /* Created by linker magic */ 251 251 extern char __per_cpu_start[], __per_cpu_end[]; 252 252 253 - static void *percpu_modalloc(unsigned long size, unsigned long align) 253 + static void *percpu_modalloc(unsigned long size, unsigned long align, 254 + const char *name) 254 255 { 255 256 unsigned long extra; 256 257 unsigned int i; 257 258 void *ptr; 258 259 259 - BUG_ON(align > SMP_CACHE_BYTES); 260 + if (align > SMP_CACHE_BYTES) { 261 + printk(KERN_WARNING "%s: per-cpu alignment %li > %i\n", 262 + name, align, SMP_CACHE_BYTES); 263 + align = SMP_CACHE_BYTES; 264 + } 260 265 261 266 ptr = __per_cpu_start; 262 267 for (i = 0; i < pcpu_num_used; ptr += block_size(pcpu_size[i]), i++) { ··· 353 348 } 354 349 __initcall(percpu_modinit); 355 350 #else /* ... !CONFIG_SMP */ 356 - static inline void *percpu_modalloc(unsigned long size, unsigned long align) 351 + static inline void *percpu_modalloc(unsigned long size, unsigned long align, 352 + const char *name) 357 353 { 358 354 return NULL; 359 355 } ··· 1650 1644 if (pcpuindex) { 1651 1645 /* We have a special allocation for this section. */ 1652 1646 percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size, 1653 - sechdrs[pcpuindex].sh_addralign); 1647 + sechdrs[pcpuindex].sh_addralign, 1648 + mod->name); 1654 1649 if (!percpu) { 1655 1650 err = -ENOMEM; 1656 1651 goto free_mod;