intelcpu-architecturemicro-architecture

How to figure out disabled cores in a CPU?


I need to find out which cores are disabled on a CPU. How can I do this in C/C++ way? I know that reading CAPID6 register is one of the ways, but I am not sure about how to get it done. Is there any system calls or tricks that I need to be aware of?

My OS is Ubuntu. I have Xeon Skylake CPU. I can see if a particular core is offline or online by checking /sys/devices/system/cpu/cpu*/online to see if the file contains 0 or 1 which means offline or online respectively.

And also I checked link below:

https://community.intel.com/t5/Software-Tuning-Performance/Understanding-PCICFG-space-information/td-p/1138820

And I understood John McCalpin's answer, but again, I am looking for a C/C++ way of doing this.


Solution

  • The supported way to do it on Linux is simply to read those same files. You can open them with fopen, read with fscanf, etc.