Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove LXC special handling for the CPU count #1197

Merged
merged 1 commit into from
Feb 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions linux/LinuxProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,28 +210,6 @@ static void LinuxProcessList_initNetlinkSocket(LinuxProcessList* this) {

#endif

static unsigned int scanAvailableCPUsFromCPUinfo(LinuxProcessList* this) {
FILE* file = fopen(PROCCPUINFOFILE, "r");
if (file == NULL)
return this->super.existingCPUs;

unsigned int availableCPUs = 0;

while (!feof(file)) {
char buffer[PROC_LINE_LENGTH];

if (fgets(buffer, PROC_LINE_LENGTH, file) == NULL)
break;

if (String_startsWith(buffer, "processor"))
availableCPUs++;
}

fclose(file);

return availableCPUs ? availableCPUs : 1;
}

static void LinuxProcessList_updateCPUcount(ProcessList* super) {
/* Similar to get_nprocs_conf(3) / _SC_NPROCESSORS_CONF
* https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/getsysstats.c;hb=HEAD
Expand Down Expand Up @@ -306,12 +284,6 @@ static void LinuxProcessList_updateCPUcount(ProcessList* super) {
if (existing < 1)
return;

if (Running_containerized) {
/* LXC munges /proc/cpuinfo but not the /sys/devices/system/cpu/ files,
* so limit the visible CPUs to what the guest has been configured to see: */
currExisting = active = scanAvailableCPUsFromCPUinfo(this);
}

#ifdef HAVE_SENSORS_SENSORS_H
/* When started with offline CPUs, libsensors does not monitor those,
* even when they become online. */
Expand All @@ -320,7 +292,7 @@ static void LinuxProcessList_updateCPUcount(ProcessList* super) {
#endif

super->activeCPUs = active;
assert(Running_containerized || (existing == currExisting));
assert(existing == currExisting);
super->existingCPUs = currExisting;
}

Expand Down