From owner-freebsd-arch@FreeBSD.ORG Thu Jun 4 06:50:18 2009 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 947BA106566B for ; Thu, 4 Jun 2009 06:50:18 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from mail-px0-f199.google.com (mail-px0-f199.google.com [209.85.216.199]) by mx1.freebsd.org (Postfix) with ESMTP id 7551B8FC15 for ; Thu, 4 Jun 2009 06:50:18 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: by pxi37 with SMTP id 37so568716pxi.3 for ; Wed, 03 Jun 2009 23:50:18 -0700 (PDT) Received: by 10.114.200.2 with SMTP id x2mr3041191waf.83.1244098217936; Wed, 03 Jun 2009 23:50:17 -0700 (PDT) Received: from ?10.0.1.198? (udp016664uds.hawaiiantel.net [72.235.41.117]) by mx.google.com with ESMTPS id j15sm10512711waf.51.2009.06.03.23.50.15 (version=SSLv3 cipher=RC4-MD5); Wed, 03 Jun 2009 23:50:17 -0700 (PDT) Date: Wed, 3 Jun 2009 20:55:39 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: arch@freebsd.org Message-ID: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Cc: Subject: Dynamic pcpu, arm, mips, powerpc, sun, etc. help needed X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2009 06:50:18 -0000 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