From owner-freebsd-current@FreeBSD.ORG Tue Oct 25 19:15:08 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 410A8106566B for ; Tue, 25 Oct 2011 19:15:08 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email2.allantgroup.com (email2.emsphone.com [199.67.51.116]) by mx1.freebsd.org (Postfix) with ESMTP id 9542D8FC12 for ; Tue, 25 Oct 2011 19:15:07 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email2.allantgroup.com (8.14.4/8.14.4) with ESMTP id p9PJ3beH096992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 25 Oct 2011 14:03:38 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.5/8.14.5) with ESMTP id p9PJ3bcX092540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 25 Oct 2011 14:03:37 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.5/8.14.5/Submit) id p9PIhOLr011636; Tue, 25 Oct 2011 13:43:24 -0500 (CDT) (envelope-from dan) Date: Tue, 25 Oct 2011 13:43:24 -0500 From: Dan Nelson To: Poul-Henning Kamp Message-ID: <20111025184323.GH93709@dan.emsphone.com> References: <201110251342.45194.jhb@freebsd.org> <99483.1319566152@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99483.1319566152@critter.freebsd.dk> X-OS: FreeBSD 8.2-STABLE User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.97.2 at email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.6 (email2.allantgroup.com [199.67.51.78]); Tue, 25 Oct 2011 14:03:38 -0500 (CDT) X-Scanned-By: MIMEDefang 2.68 on 199.67.51.78 Cc: freebsd-current@freebsd.org, Luigi Rizzo Subject: Re: getting the cpuid for a userspace process ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Oct 2011 19:15:08 -0000 In the last episode (Oct 25), Poul-Henning Kamp said: > In message <201110251342.45194.jhb@freebsd.org>, John Baldwin writes: > >On Tuesday, October 25, 2011 11:06:22 am Luigi Rizzo wrote: > >> as the subject says... is there any way to get the current CPU id for a > >> userspace process (of course, valid only at the time the function is > >> called as the process might be arbitrarily moved while it runs) > > > >Not from userland, no. On x86 you can use cpuid to fetch the APIC ID, > >but that does not map 1:1 to FreeBSD cpu IDs. > > How does JEmalloc do it ? Looking at the source, it just determines the number of CPUs, creates a number of arenas proportional to that, and assigns threads to an arena. If contention on a particular arena gets bad, the thread gets moved to another areana (see everything inside "#ifdef MALLOC_BALANCE" blocks). -- Dan Nelson dnelson@allantgroup.com