Dynamic pcpu, arm, mips, powerpc, sun, etc. help needed (fwd)

Jeff Roberson jroberson at jroberson.net
Thu Jun 4 07:12:45 UTC 2009


Hi Folks,

I'm forwarding this in case you don't see it.  Please help test and 
implement the remaining change to machdep.c

Thanks,
Jeff

---------- Forwarded message ----------
Date: Wed, 3 Jun 2009 20:55:39 -1000 (HST)
From: Jeff Roberson <jroberson at jroberson.net>
To: arch at freebsd.org
Subject: Dynamic pcpu, arm, mips, powerpc, sun, etc. help needed

http://people.freebsd.org/~jeff/dpcpu.diff

This patch implements dynamic per-cpu areas such that kernel code can do the 
following in a header:

DPCPU_DECLARE(uint64_t, foo);

and this in source:

DPCPU_DEFINE(uint64_t, foo) = 10;

local = DPCPU_GET(foo);
DPCPU_SET(foo, 11);

The dynamic per-cpu area of non-local cpus is accessable via 
DPCPU_ID_{GET,SET,PTR}.

If you provide an initializer as I used above that will be the default value 
when all cpus come up.  Otherwise it defaults to zero.  This is presently 
slightly more expensive than PCPU but much more flexible. Things like id and 
curthread should stay in PCPU forever.

I had to change the pcpu_init() call on every architecture to pass in storage 
for the dynamic area.  I didn't change the following three calls because it 
wasn't immediately obvious how to allocate the memory:

./powerpc/booke/machdep.c:      pcpu_init(pc, 0, sizeof(struct pcpu));
./mips/mips/machdep.c:  pcpu_init(&__pcpu[0], 0, sizeof(struct pcpu));
./mips/mips/machdep.c:  pcpu_init(pcpup, 0, sizeof(struct pcpu));


I have not tested anything other than amd64.  If you have a !amd64 
architecture, in particular any of the embedded architectures, I would really 
appreciate it.  Some of the arm boards postincrement the end address to 
allocate early memory and some pre-decriment.  Hopefully I got it right.

Thanks,
Jeff


More information about the freebsd-mips mailing list