Skip to content

Commit

Permalink
Fixed: Number of cores wrongly detected for Ryzen in rare cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
aristocratos committed Oct 7, 2022
1 parent 7a2556e commit e5cc895
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/linux/btop_collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ tab-size = 4
#include <netdb.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <thread>

#if !(defined(STATIC_BUILD) && defined(__GLIBC__))
#include <pwd.h>
Expand Down Expand Up @@ -106,10 +107,13 @@ namespace Shared {
if (passwd_path.empty())
Logger::warning("Could not read /etc/passwd, will show UID instead of username.");

coreCount = sysconf(_SC_NPROCESSORS_CONF);
coreCount = std::thread::hardware_concurrency();
if (coreCount < 1) {
coreCount = 1;
Logger::warning("Could not determine number of cores, defaulting to 1.");
coreCount = sysconf(_SC_NPROCESSORS_CONF);
if (coreCount < 1) {
coreCount = 1;
Logger::warning("Could not determine number of cores, defaulting to 1.");
}
}

pageSize = sysconf(_SC_PAGE_SIZE);
Expand Down

0 comments on commit e5cc895

Please sign in to comment.