RFR: 8224816: Provide os::processor_id() implementation for Mac OS

Erik Österlund erik.osterlund at oracle.com
Mon May 27 10:05:13 UTC 2019


Hi,

In order to port ZGC to Mac OS, we need to implement os::processor_id(), 
due to the use of CPU locals in ZGC.
I built an implementation that uses CPUID to get the APIC id, and from 
that determine a unique CPU id.
Note though that the APIC ids are split over a potentially larger number 
space than the number of processors.
In order to reliably translate APIC ids to CPU ids, I first use CPUID to 
query how many bits are being used
for APIC ids, and then create an array of integers covering that space. 
The array maps possible APIC id positions
to a unique processor id. The array is lazily populated with APIC id -> 
processor id mappings.
The specific CPUID leaf used to query this topology information is 
intel-specific, but that should be okay as all macs are Intel based.
I have tried this out on a number of macs with a mac port of ZGC (to be 
upstreamed soon), and it worked well.

Bug:
https://bugs.openjdk.java.net/browse/JDK-8224816

Webrev:
http://cr.openjdk.java.net/~eosterlund/8224816/webrev.00/

Thanks,
/Erik


More information about the hotspot-runtime-dev mailing list