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

[PATCH] x86-64: Account for module percpu space separately from kernel percpu

Rather than using a single constant PERCPU_ENOUGH_ROOM, compute it as
the sum of kernel_percpu + PERCPU_MODULE_RESERVE. This is now common
to all architectures; if an architecture wants to set
PERCPU_ENOUGH_ROOM to something special, then it may do so (ia64 is
the only one which does).

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Andi Kleen <ak@suse.de>

authored by

Jeremy Fitzhardinge and committed by
Andi Kleen
b00742d3 bbba11c3

+9 -36
-14
include/asm-alpha/percpu.h
··· 1 1 #ifndef __ALPHA_PERCPU_H 2 2 #define __ALPHA_PERCPU_H 3 3 4 - /* 5 - * Increase the per cpu area for Alpha so that 6 - * modules using percpu area can load. 7 - */ 8 - #ifdef CONFIG_MODULES 9 - # define PERCPU_MODULE_RESERVE 8192 10 - #else 11 - # define PERCPU_MODULE_RESERVE 0 12 - #endif 13 - 14 - #define PERCPU_ENOUGH_ROOM \ 15 - (ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES) + \ 16 - PERCPU_MODULE_RESERVE) 17 - 18 4 #include <asm-generic/percpu.h> 19 5 20 6 #endif /* __ALPHA_PERCPU_H */
-10
include/asm-sparc64/percpu.h
··· 5 5 6 6 #ifdef CONFIG_SMP 7 7 8 - #ifdef CONFIG_MODULES 9 - # define PERCPU_MODULE_RESERVE 8192 10 - #else 11 - # define PERCPU_MODULE_RESERVE 0 12 - #endif 13 - 14 - #define PERCPU_ENOUGH_ROOM \ 15 - (ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES) + \ 16 - PERCPU_MODULE_RESERVE) 17 - 18 8 extern void setup_per_cpu_areas(void); 19 9 20 10 extern unsigned long __per_cpu_base;
-10
include/asm-x86_64/percpu.h
··· 11 11 12 12 #include <asm/pda.h> 13 13 14 - #ifdef CONFIG_MODULES 15 - # define PERCPU_MODULE_RESERVE 8192 16 - #else 17 - # define PERCPU_MODULE_RESERVE 0 18 - #endif 19 - 20 - #define PERCPU_ENOUGH_ROOM \ 21 - (ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES) + \ 22 - PERCPU_MODULE_RESERVE) 23 - 24 14 #define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset) 25 15 #define __my_cpu_offset() read_pda(data_offset) 26 16
+8 -1
include/linux/percpu.h
··· 11 11 12 12 /* Enough to cover all DEFINE_PER_CPUs in kernel, including modules. */ 13 13 #ifndef PERCPU_ENOUGH_ROOM 14 - #define PERCPU_ENOUGH_ROOM 32768 14 + #ifdef CONFIG_MODULES 15 + #define PERCPU_MODULE_RESERVE 8192 16 + #else 17 + #define PERCPU_MODULE_RESERVE 0 15 18 #endif 19 + 20 + #define PERCPU_ENOUGH_ROOM \ 21 + (__per_cpu_end - __per_cpu_start + PERCPU_MODULE_RESERVE) 22 + #endif /* PERCPU_ENOUGH_ROOM */ 16 23 17 24 /* 18 25 * Must be an lvalue. Since @var must be a simple identifier,
+1 -1
kernel/module.c
··· 430 430 pcpu_size = kmalloc(sizeof(pcpu_size[0]) * pcpu_num_allocated, 431 431 GFP_KERNEL); 432 432 /* Static in-kernel percpu data (used). */ 433 - pcpu_size[0] = -ALIGN(__per_cpu_end-__per_cpu_start, SMP_CACHE_BYTES); 433 + pcpu_size[0] = -(__per_cpu_end-__per_cpu_start); 434 434 /* Free room. */ 435 435 pcpu_size[1] = PERCPU_ENOUGH_ROOM + pcpu_size[0]; 436 436 if (pcpu_size[1] < 0) {