Re: [PATCH 00/05] robust per_cpu allocation for modules
From: Rusty Russell
Date: Mon Apr 17 2006 - 02:51:49 EST
On Sun, 2006-04-16 at 09:40 -0400, Steven Rostedt wrote:
> The reason that this is done, is that the per_cpu macro cant know
> whether or not the per_cpu variable was declared in a kernel or in a
> module. So the __pre_cpu_offset array offset can't be used if the
> module allocation is in its own separate area. Remember that this offset
> array stores the difference from where the variable originally was and
> where it is now for each cpu.
Actually, the reason this is done is because the per_cpu_offset is
designed to be replaced by a register or an expression on archs which
care, and this is simple. The main problem is that so many archs want
different things, it's a very UN task to build infrastructure.
I have always recommended using the same scheme to implement real
dynamic per-cpu allocation (which would then replace the mini-allocator
inside the module code). In fact, I had such an implementation which I
reduced to the module case (dynamic per-cpu was too far-out at the
The arch would allocate a virtual memory hole for each CPU, and map
pages as required (this is the simplest of several potential schemes).
This gives the "same space between CPUs" property which is required for
the ptr + per-cpu-offset scheme. An arch would supply functions like:
/* Returns address of new memory chunk(s)
* (add __per_cpu_offset to get virtual addresses). */
unsigned long alloc_percpu_memory(unsigned long *size);
/* Set by ia64 to reserve the first chunk for percpu vars
* in modules only.
And an allocator would work on top of these.
I'm glad someone is looking at this again!
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/