A frequently asked question among users of CMT platforms is "How do I know which CPUs share a core?". For most users, the best answer is, "don't worry about it", because Solaris does a good job of assigning software threads to CPUs and spreading them across cores such that the utilization of hardware resources is maximized. However, knowledge of the mapping is helpful to users who want to explicitly manage the assignment of threads to CPUs and cores, to squeeze out more performance, using techniques such as processor set binding and interrupt fencing.
For some processors and configurations, the core can be computed as a static function of the CPU ID, but this is not a general or easy-to-use solution. Instead, Solaris exposes this in a portable way via the "psrinfo -pv" command, as shown in this example on an M5000 server:
% psrinfo -pv
The physical processor has 2 cores and 4 virtual processors (0-3)
The core has 2 virtual processors (0 1)
The core has 2 virtual processors (2 3)
SPARC64-VI (portid 1024 impl 0x6 ver 0x90 clock 2150 MHz)
The physical processor has 2 cores and 4 virtual processors (40-43)
The core has 2 virtual processors (40 41)
The core has 2 virtual processors (42 43)
SPARC64-VI (portid 1064 impl 0x6 ver 0x90 clock 2150 MHz)
|
The numbers in parenthesis are the CPU IDs, as known to Solaris and used in commands such as mpstat, psradm, etc. At this time, there are no supported programmatic interfaces to get this information.
Now for the confusing part. Unfortunately, "psrinfo -pv" only prints the core information on systems running OpenSolaris or Solaris Express, because psrinfo was enhanced by this CR:
-
6316187 Need interface to determine core sharing by CPUs
#!/bin/ksh
kstat cpu_info | \
egrep "cpu_info |core_id" | \
awk \
'BEGIN { printf "%4s %4s", "CPU", "core" } \
/module/ { printf "\n%4s", $4 } \
/core_id/ { printf "%4s", $2} \
END { printf "\n" }'
|
% showcores CPU core 0 0 1 0 2 2 3 2 40 40 41 40 42 42 43 42 |
The core_id extracted from the kstats is arbitrary, but CPUs with the same core_id share a physical core. Beware that the name and semantics of kstats such as core_id are unstable interfaces, which means they are not documented, not supported, and are subject to change.