Re: [patch 05/14] percpu: Use a Kconfig variable to configure arch specific percpu setup

Christoph Lameter
2007-11-28T23:36:20Z

On Thu, 29 Nov 2007, Rusty Russell wrote:

> But the PDA itself is silly (Jeremy ported it to i386 and I balked). We have
> a generic one: it's called the per-cpu data. Having a completely separate
> per-cpu structure for x86-64 is a mistake.

Yes ultimately the pda can be dissolved. However, the stack canary
probably has to be kept for backward compatibility.

> Setting up gs as the per-cpu offset has lovely properties and avoids YA
> arch-specific concept; see the i386 code. Introducing a generic
> read_percpu()/write_percpu() would even make it optimal.

The code becomes much simpler if gs would point to the beginning of the
per cpu area and if the __per_cpu_offset[i] would do the same. No weird
__per_cpu_start offsetting anymore.

The offsets are smaller if they are relative to the per cpu areas which
will make more compact instructions possible.

The generic write/readpercpu functionality introduced by the cpu_alloc
patchset works best with offsets relative to an arch dependent
register. All per cpu data (pda, percpu and allocpercpu) is handles as an
offset relative to the start of the per cpu data.

If the current offset by __per_cpu_start is kept then a per cpu allocator
may have to dish out addresses that go beyond __per_cpu_end.

I think dealing with a per cpu variable as if it would be an offset
relative to a base is natural for the typical addressing of cpus based on
an offset relative to some register.