Skip to content

Commit c9dd858

Browse files
committed
CPU (Linux): bing cpuMHz back
It's used in WSL
1 parent 2e201ea commit c9dd858

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/detection/cpu/cpu_linux.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static void detectAndroid(FFCPUResult* cpu)
2626
}
2727
#endif
2828

29-
static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrbuf* cpuIsa, FFstrbuf* cpuUarch)
29+
static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrbuf* cpuMHz, FFstrbuf* cpuIsa, FFstrbuf* cpuUarch)
3030
{
3131
FF_AUTO_CLOSE_FILE FILE* cpuinfo = fopen("/proc/cpuinfo", "r");
3232
if(cpuinfo == NULL)
@@ -49,6 +49,7 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer,
4949
ffParsePropLine(line, "model name :", &cpu->name) ||
5050
ffParsePropLine(line, "vendor_id :", &cpu->vendor) ||
5151
ffParsePropLine(line, "cpu cores :", physicalCoresBuffer) ||
52+
ffParsePropLine(line, "cpu MHz :", cpuMHz) ||
5253
ffParsePropLine(line, "isa :", cpuIsa) ||
5354
ffParsePropLine(line, "uarch :", cpuUarch) ||
5455

@@ -232,18 +233,19 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
232233
cpu->temperature = options->temp ? detectCPUTemp() : FF_CPU_TEMP_UNSET;
233234

234235
FF_STRBUF_AUTO_DESTROY physicalCoresBuffer = ffStrbufCreate();
236+
FF_STRBUF_AUTO_DESTROY cpuMHz = ffStrbufCreate();
235237
FF_STRBUF_AUTO_DESTROY cpuIsa = ffStrbufCreate();
236238
FF_STRBUF_AUTO_DESTROY cpuUarch = ffStrbufCreate();
237239

238-
const char* error = parseCpuInfo(cpu, &physicalCoresBuffer, &cpuIsa, &cpuUarch);
240+
const char* error = parseCpuInfo(cpu, &physicalCoresBuffer, &cpuMHz, &cpuIsa, &cpuUarch);
239241
if (error) return error;
240242

241243
cpu->coresLogical = (uint16_t) get_nprocs_conf();
242244
cpu->coresOnline = (uint16_t) get_nprocs();
243245
cpu->coresPhysical = (uint16_t) ffStrbufToUInt(&physicalCoresBuffer, cpu->coresLogical);
244246

245-
detectFrequency(cpu);
246-
// cpu MHz is current frequency, not max or base
247+
if (!detectFrequency(cpu) || cpu->frequencyBase != cpu->frequencyBase)
248+
cpu->frequencyBase = ffStrbufToDouble(&cpuMHz) / 1000;
247249

248250
if(cpuUarch.length > 0)
249251
{

0 commit comments

Comments
 (0)