Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jun 2009 20:56:11 -1000 (HST)
From:      Jeff Roberson <jroberson@jroberson.net>
To:        arm@freebsd.org
Subject:   Dynamic pcpu, arm, mips, powerpc, sun, etc. help needed (fwd)
Message-ID:  <alpine.BSF.2.00.0906032055510.981@desktop>

next in thread | raw e-mail | index | archive | help
Hi Folks,

I'm forwarding this in case you don't see it.  Please help test.

Thanks,
Jeff

---------- Forwarded message ----------
Date: Wed, 3 Jun 2009 20:55:39 -1000 (HST)
From: Jeff Roberson <jroberson@jroberson.net>
To: arch@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.0906032055510.981>