Re: [PATCH 8/8] Convert PDA into the percpu section
From: Rusty Russell
Date: Tue Mar 06 2007 - 19:17:54 EST
On Tue, 2007-03-06 at 14:10 +0100, Ingo Molnar wrote:
> * Rusty Russell <rusty@xxxxxxxxxxxxxxx> wrote:
>
> > Currently x86 (similar to x84-64) has a special per-cpu structure
> > called "i386_pda" which can be easily and efficiently referenced via
> > the %fs register. An ELF section is more flexible than a structure,
> > allowing any piece of code to use this area. Indeed, such a section
> > already exists: the per-cpu area.
> >
> > So this patch
> > (1) Removes the PDA and uses per-cpu variables for each current member.
>
> hmm ... i very much like this, but its needs performance and kernel-size
> testing before it can move from -mm into mainline. We are now exposing
> wide ranges of the kernel to segment prefixes again. (Btw., i'd expect
> there to be a kernel size reduction.)
Hi Ingo,
Thanks! There are some interesting issues. Because __get_cpu_var()
returns an lvalue, we don't use the %fs:value directly, but calculate
offset (%fs:this_cpu_off + &value). So previously there was only a tiny
code reduction.
If we used __thread, then gcc could do this optimization for us when it
knows an rvalue is needed, however:
1) gcc wants to use %gs, not %fs, which is measurably slower for the
kernel,
2) gcc wants to use huge offsets to store the address of the per-cpu
space, and this breaks Xen (and current lguest, but new lguest no longer
uses segments for protection)
One solution would be to expose x86_read_percpu() as read_percpu() and
implement it in asm-generic/percpu.h as well, then use it in places
where only an rvalue is required.
Cheers!
Rusty.
-
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/