Rate This Document
Findability
Accuracy
Completeness
Readability

Hard Coding the Number of Cores

Symptom

The number of CPU cores on a Kunpeng server is different from that on the x86 server. If the module code is hardcoded based on the number of CPU cores, the system capability cannot be fully used. For example, the CPU core usage varies greatly, or cores are bound to different NUMA nodes.

Procedure

You can search for the core binding interface (sched_setaffinity) in the code to check whether the number of CPU cores is hardcoded.

If yes, change the number of cores based on the actual number of cores on the Kunpeng server to eliminate hardcoding. You can obtain the actual number of cores by calling (sysconf(_SC_NPROCESSORS_CONF)) and then bind the cores.