Skip to content

Commit

Permalink
Detect cores actual present.
Browse files Browse the repository at this point in the history
according to man page of sysconf,

_SC_NPROCESSORS_CONF will report core count that kernel ready to setup
  (including cores not enabled/hot-plugged in),
  which may report more than actual exist.

use _SC_NPROCESSORS_ONLN instead.
  • Loading branch information
NightFeather committed Sep 12, 2022
1 parent be91f8f commit 1501607
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion amdctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void getCpuInfo() {
}

// Check for dual or quad CPU motherboards.
unsigned short testcores = (unsigned short) sysconf(_SC_NPROCESSORS_CONF);
unsigned short testcores = (unsigned short) sysconf(_SC_NPROCESSORS_ONLN);
if (testcores > cores) {
if (!quiet) {
printf("Multi-CPU motherboard detected: CPU has %d cores, but there is a total %d cores in %d CPU sockets.\n", cores, testcores, testcores / cores);
Expand Down

0 comments on commit 1501607

Please sign in to comment.