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

David Miller
2009-03-10T10:59:39Z

From: Tejun Heo <tj@kernel.org>
Date: Tue, 10 Mar 2009 16:53:46 +0900

> 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
...
> 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.

The one thing sparc64 does is calculate the base of the per-cpu
area using a base (contained in a fixed global register) a shift.

>From arch/sparc/include/asm/percpu_64.h

register unsigned long __local_per_cpu_offset asm("g5");
extern unsigned long __per_cpu_base;
extern unsigned long __per_cpu_shift;
#define __per_cpu_offset(__cpu) \
(__per_cpu_base + ((unsigned long)(__cpu) << __per_cpu_shift))
#define per_cpu_offset(x) (__per_cpu_offset(x))
#define __my_cpu_offset __local_per_cpu_offset

I hope this won't cause problems for what you're trying to accomplish.