[GIT RFC] percpu: use dynamic percpu allocator as the default percpu allocator

From: Tejun Heo
Date: Tue Mar 10 2009 - 03:56:39 EST



Hello, all.

This patchset converts all SMP-capable arches other than three
non-trivial ones - powerpc64, sparc64 and ia64 - to use dynamic percpu
allocator. The affected archs are

* sh
* arm
* cris
* mips
* sparc(32)
* blackfin
* avr32
* parisc
* m32r
* powerpc(32)
* alpha
* s390

The x86 embedding first chunk allocator is generalized and used as the
default first chunk allocator. This first chunk allocator makes the
dynamic percpu allocator behave mostly identically to the previous
generic percpu allocator. Percpu memory is allocated using
alloc_bootmem_pages() and module static percpu variables are allocated
right after core percpu variables.

The only differences are 1. there can be more space between percpu
areas for each cpu to accomodate minimum allocation size and first
chunk dynamic reserve and 2. dynamic percpu variables use the same
address translation mechanism as static ones.

#1 shouldn't cause any trouble and #2 shouldn't too because the
offsets for dynamic percpu variables are carried in full pointer-width
variables, so as long as the calculations don't make wrong assumptions
(should be masked by RELOC_HIDE), it should be okay, but if your arch
has addressing limitations (alpha, s390), please take a second look.

I really wanted to test it on an architecture which is actually
affected by this change but my powerstation wouldn't boot 32bit
kernel, qemu-system-sparc doesn't like SMP kernels and I don't have
access to a sparc, alpha or SMP arm, so I could only tested it on
x86_32 with a patch to use the generic default allocator. It works
fine there and compiles fine for sparc(32), powerpc(32), alpha and
arm. If you have an access to one of the affected archs, please test
and report the result. I'll send a test module as a reply to this
message. If you can boot and load/unload the module, it should be
working fine.

This patchset is on top of the current x86/core/percpu[1] and contains
the following patches.

0001-linker-script-define-__per_cpu_load-on-all-SMP-capa.patch
0002-percpu-make-x86-addr-pcpu-ptr-conversion-macros.patch
0003-percpu-more-flexibility-for-dyn_size-of-pcpu_setup.patch
0004-percpu-generalize-embedding-first-chunk-setup-helpe.patch
0005-percpu-use-dynamic-percpu-allocator-as-the-default.patch

0001-0004 preps. 0005 does the conversion.

This patchset is available in the following git tree.

git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git tj-percpu

Ingo, I think it would be best to delay pulling till at least some of
the archs have been confirmed.

Diffstat follows.

arch/arm/kernel/vmlinux.lds.S | 1
arch/ia64/Kconfig | 3
arch/ia64/kernel/vmlinux.lds.S | 12 --
arch/powerpc/Kconfig | 3
arch/powerpc/kernel/vmlinux.lds.S | 9 --
arch/sparc/Kconfig | 3
arch/x86/Kconfig | 3
arch/x86/include/asm/percpu.h | 8 -
arch/x86/kernel/setup_percpu.c | 63 ++------------
include/linux/percpu.h | 18 +++-
init/main.c | 24 -----
kernel/module.c | 6 -
mm/Makefile | 2
mm/percpu.c | 170 ++++++++++++++++++++++++++++++++++----
14 files changed, 195 insertions(+), 130 deletions(-)

Thanks.

--
tejun

[1] 3a450de1365d20afde406f0d9b2931a5e4a4fd6a
--
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/