mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
CPU: adds NUMA node detection
This commit is contained in:
@@ -21,6 +21,7 @@ typedef struct FFCPUResult
|
||||
uint16_t coresPhysical;
|
||||
uint16_t coresLogical;
|
||||
uint16_t coresOnline;
|
||||
uint16_t numaNodes;
|
||||
|
||||
uint32_t frequencyBase; // GHz
|
||||
uint32_t frequencyMax; // GHz
|
||||
|
||||
@@ -100,5 +100,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
detectThermalTemp(&cpu->temperature);
|
||||
}
|
||||
|
||||
cpu->numaNodes = (uint16_t) ffSysctlGetInt("vm.ndomains", 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -138,6 +138,21 @@ static double detectCPUTemp(void)
|
||||
return FF_CPU_TEMP_UNSET;
|
||||
}
|
||||
|
||||
static void detectNumaNodes(FFCPUResult* cpu)
|
||||
{
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir("/sys/devices/system/node/");
|
||||
if (!dir) return;
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if (entry->d_type != DT_DIR && entry->d_type != DT_UNKNOWN)
|
||||
continue;
|
||||
if (ffStrStartsWith(entry->d_name, "node") && ffCharIsDigit(entry->d_name[strlen("node")]))
|
||||
cpu->numaNodes++;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "common/settings.h"
|
||||
|
||||
@@ -568,6 +583,8 @@ FF_MAYBE_UNUSED static const char* detectCPUX86(const FFCPUOptions* options, FFC
|
||||
if (!detectFrequency(cpu, options) || cpu->frequencyBase == 0)
|
||||
cpu->frequencyBase = (uint32_t) ffStrbufToUInt(&cpuMHz, 0);
|
||||
|
||||
detectNumaNodes(cpu);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -877,6 +894,7 @@ FF_MAYBE_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options,
|
||||
detectPhysicalCores(cpu);
|
||||
|
||||
ffCPUDetectByCpuid(cpu);
|
||||
detectNumaNodes(cpu);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -230,6 +230,8 @@ static const char* detectNCores(FFCPUResult* cpu)
|
||||
++cpu->coresPhysical;
|
||||
else if (ptr->Relationship == RelationProcessorPackage)
|
||||
++cpu->packages;
|
||||
else if (ptr->Relationship == RelationNumaNode)
|
||||
++cpu->numaNodes;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -217,6 +217,11 @@ bool ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "march");
|
||||
|
||||
if (cpu.numaNodes > 0)
|
||||
yyjson_mut_obj_add_uint(doc, obj, "numaNodes", cpu.numaNodes);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "numaNodes");
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
||||
@@ -259,6 +264,6 @@ FFModuleBaseInfo ffCPUModuleInfo = {
|
||||
{"Temperature (formatted)", "temperature"},
|
||||
{"Logical core count grouped by frequency", "core-types"},
|
||||
{"Processor package count", "packages"},
|
||||
{"X86-64 CPU microarchitecture", "march"},
|
||||
{"CPU microarchitecture", "march"},
|
||||
}))
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user