mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 23:07:18 +00:00
[common] cpuinfo: add sockets to interface
This commit is contained in:
parent
32134b33ea
commit
194241c5a3
@ -24,7 +24,8 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
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);
|
void lgDebugCPU(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,13 +26,14 @@ void lgDebugCPU(void)
|
|||||||
char model[1024];
|
char model[1024];
|
||||||
int procs;
|
int procs;
|
||||||
int cores;
|
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");
|
DEBUG_WARN("Failed to get CPU information");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_INFO("CPU Model: %s", model);
|
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);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
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");
|
FILE * cpuinfo = fopen("/proc/cpuinfo", "r");
|
||||||
if (!cpuinfo)
|
if (!cpuinfo)
|
||||||
@ -42,6 +43,9 @@ bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores)
|
|||||||
if (cores)
|
if (cores)
|
||||||
*cores = 0;
|
*cores = 0;
|
||||||
|
|
||||||
|
if (sockets)
|
||||||
|
*sockets = 1;
|
||||||
|
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
while (fgets(buffer, sizeof(buffer), cpuinfo))
|
while (fgets(buffer, sizeof(buffer), cpuinfo))
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,11 @@ static bool getCoreCount(int * cores, int * procs)
|
|||||||
return true;
|
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);
|
return getCPUModel(model, modelSize) && getCoreCount(cores, procs);
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ static bool newKVMFRData(KVMFRUserData * dst)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
int cpus, cores;
|
int cpus, cores;
|
||||||
if (lgCPUInfo(model, 1024, &cpus, &cores))
|
if (lgCPUInfo(model, 1024, &cpus, &cores, NULL))
|
||||||
{
|
{
|
||||||
vmInfo->cpus = cpus;
|
vmInfo->cpus = cpus;
|
||||||
vmInfo->cores = cores;
|
vmInfo->cores = cores;
|
||||||
|
Loading…
Reference in New Issue
Block a user