Re: getting the cpuid for a userspace process ?

From: Dan Nelson <dnelson_at_allantgroup.com>
Date: Tue, 25 Oct 2011 13:43:24 -0500
In the last episode (Oct 25), Poul-Henning Kamp said:
> In message <201110251342.45194.jhb_at_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_at_allantgroup.com
Received on Tue Oct 25 2011 - 17:15:08 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:19 UTC