From owner-freebsd-arm@FreeBSD.ORG Thu Jun 4 07:21:51 2009 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24E37106564A for ; Thu, 4 Jun 2009 07:21:51 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.225]) by mx1.freebsd.org (Postfix) with ESMTP id 05C748FC1C for ; Thu, 4 Jun 2009 07:21:50 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: by rv-out-0506.google.com with SMTP id k40so217234rvb.51 for ; Thu, 04 Jun 2009 00:21:50 -0700 (PDT) Received: by 10.141.2.18 with SMTP id e18mr1552272rvi.140.1244098249900; Wed, 03 Jun 2009 23:50:49 -0700 (PDT) Received: from ?10.0.1.198? (udp016664uds.hawaiiantel.net [72.235.41.117]) by mx.google.com with ESMTPS id f42sm26703490rvb.31.2009.06.03.23.50.47 (version=SSLv3 cipher=RC4-MD5); Wed, 03 Jun 2009 23:50:49 -0700 (PDT) Date: Wed, 3 Jun 2009 20:56:11 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: arm@freebsd.org Message-ID: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Subject: Dynamic pcpu, arm, mips, powerpc, sun, etc. help needed (fwd) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2009 07:21:51 -0000 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 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