From 194241c5a3b6900bf2e0e6ae50e6bc9321e110c5 Mon Sep 17 00:00:00 2001 From: Quantum Date: Fri, 7 Jan 2022 03:06:17 -0500 Subject: [PATCH] [common] cpuinfo: add sockets to interface --- common/include/common/cpuinfo.h | 3 ++- common/src/cpuinfo.c | 5 +++-- common/src/platform/linux/cpuinfo.c | 6 +++++- common/src/platform/windows/cpuinfo.c | 6 +++++- host/src/app.c | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/common/include/common/cpuinfo.h b/common/include/common/cpuinfo.h index 836e0615..38c9847e 100644 --- a/common/include/common/cpuinfo.h +++ b/common/include/common/cpuinfo.h @@ -24,7 +24,8 @@ #include #include -bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores); +bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores, + int * sockets); void lgDebugCPU(void); #endif diff --git a/common/src/cpuinfo.c b/common/src/cpuinfo.c index 5cdfa627..53162c02 100644 --- a/common/src/cpuinfo.c +++ b/common/src/cpuinfo.c @@ -26,13 +26,14 @@ void lgDebugCPU(void) char model[1024]; int procs; int cores; + int sockets; - if (!lgCPUInfo(model, sizeof model, &procs, &cores)) + if (!lgCPUInfo(model, sizeof model, &procs, &cores, &sockets)) { DEBUG_WARN("Failed to get CPU information"); return; } DEBUG_INFO("CPU Model: %s", model); - DEBUG_INFO("CPU: %d cores, %d threads", cores, procs); + DEBUG_INFO("CPU: %d sockets, %d cores, %d threads", sockets, cores, procs); } diff --git a/common/src/platform/linux/cpuinfo.c b/common/src/platform/linux/cpuinfo.c index 1c0ead69..67fdccac 100644 --- a/common/src/platform/linux/cpuinfo.c +++ b/common/src/platform/linux/cpuinfo.c @@ -27,7 +27,8 @@ #include #include -bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores) +bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores, + int * sockets) { FILE * cpuinfo = fopen("/proc/cpuinfo", "r"); if (!cpuinfo) @@ -42,6 +43,9 @@ bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores) if (cores) *cores = 0; + if (sockets) + *sockets = 1; + char buffer[1024]; while (fgets(buffer, sizeof(buffer), cpuinfo)) { diff --git a/common/src/platform/windows/cpuinfo.c b/common/src/platform/windows/cpuinfo.c index 3f288658..d95cb06c 100644 --- a/common/src/platform/windows/cpuinfo.c +++ b/common/src/platform/windows/cpuinfo.c @@ -95,7 +95,11 @@ static bool getCoreCount(int * cores, int * procs) return true; } -bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores) +bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores, + int * sockets) { + if (sockets) + *sockets = 1; + return getCPUModel(model, modelSize) && getCoreCount(cores, procs); } diff --git a/host/src/app.c b/host/src/app.c index 79d21996..e54a229f 100644 --- a/host/src/app.c +++ b/host/src/app.c @@ -613,7 +613,7 @@ static bool newKVMFRData(KVMFRUserData * dst) return false; int cpus, cores; - if (lgCPUInfo(model, 1024, &cpus, &cores)) + if (lgCPUInfo(model, 1024, &cpus, &cores, NULL)) { vmInfo->cpus = cpus; vmInfo->cores = cores;