[Top] [All Lists]

Re: [PATCH 00/05] robust per_cpu allocation for modules

To: Steven Rostedt <>
Subject: Re: [PATCH 00/05] robust per_cpu allocation for modules
From: Rusty Russell <>
Date: Mon, 17 Apr 2006 16:47:24 +1000
Cc: Paul Mackerras <>, Nick Piggin <>, LKML <>, Andrew Morton <>, Linus Torvalds <>, Ingo Molnar <>, Thomas Gleixner <>, Andi Kleen <>, Martin Mares <>,,,,, Chris Zankel <>, Marc Gauthier <>, Joe Taylor <>, David Mosberger-Tang <>,,,,,,,,,,,,
In-reply-to: <1145194804.27407.103.camel@localhost.localdomain>
Original-recipient: rfc822;
References: <1145049535.1336.128.camel@localhost.localdomain> <> <> <> <> <> <1145194804.27407.103.camel@localhost.localdomain>
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!

<Prev in Thread] Current Thread [Next in Thread>