Skip to content

Commit a424839

Browse files
committed
CPU (Linux): remove bios_limit detection
1 parent acd5d4a commit a424839

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# 2.26.0
22

3+
Changes:
4+
* To be consistent to other platforms, CPU frequency detection on Linux no longer checks `bios_limit`
5+
36
Features:
47
* Detect GPU index (#1267, GPU)
58
* Count Flatpak runtime packages (#1085, Packages, Linux)

src/detection/cpu/cpu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ typedef struct FFCPUResult
2121

2222
uint32_t frequencyBase; // GHz
2323
uint32_t frequencyMax; // GHz
24-
uint32_t frequencyBiosLimit; // GHz
2524

2625
FFCPUCore coreTypes[16]; // number of P cores, E cores, etc.
2726

src/detection/cpu/cpu_linux.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,18 +325,25 @@ static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options)
325325
if (ffStrStartsWith(entry->d_name, "policy") && ffCharIsDigit(entry->d_name[strlen("policy")]))
326326
{
327327
ffStrbufAppendS(&path, entry->d_name);
328+
329+
uint32_t fmax = getFrequency(&path, "/cpuinfo_max_freq", "/scaling_max_freq", &buffer);
330+
if (fmax == 0) continue;
331+
332+
if (cpu->frequencyMax >= fmax)
333+
{
334+
if (!options->showPeCoreCount)
335+
{
336+
ffStrbufSubstrBefore(&path, baseLen);
337+
continue;
338+
}
339+
}
340+
else
341+
cpu->frequencyMax = fmax;
342+
328343
uint32_t fbase = getFrequency(&path, "/base_frequency", NULL, &buffer);
329344
if (fbase > 0)
330345
cpu->frequencyBase = cpu->frequencyBase > fbase ? cpu->frequencyBase : fbase;
331346

332-
uint32_t fbioslimit = getFrequency(&path, "/bios_limit", NULL, &buffer);
333-
if (fbioslimit > 0)
334-
cpu->frequencyBiosLimit = cpu->frequencyBiosLimit > fbioslimit ? cpu->frequencyBiosLimit : fbioslimit;
335-
336-
uint32_t fmax = getFrequency(&path, "/cpuinfo_max_freq", "/scaling_max_freq", &buffer);
337-
if (fmax > 0)
338-
cpu->frequencyMax = cpu->frequencyMax > fmax ? cpu->frequencyMax : fmax;
339-
340347
if (options->showPeCoreCount)
341348
{
342349
uint32_t freq = fbase == 0 ? fmax : fbase; // seems base frequencies are more stable

src/modules/cpu/cpu.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "modules/cpu/cpu.h"
77
#include "util/stringUtils.h"
88

9-
#define FF_CPU_NUM_FORMAT_ARGS 10
9+
#define FF_CPU_NUM_FORMAT_ARGS 9
1010

1111
static int sortCores(const FFCPUCore* a, const FFCPUCore* b)
1212
{
@@ -19,7 +19,6 @@ void ffPrintCPU(FFCPUOptions* options)
1919
.temperature = FF_CPU_TEMP_UNSET,
2020
.frequencyMax = 0,
2121
.frequencyBase = 0,
22-
.frequencyBiosLimit = 0,
2322
.name = ffStrbufCreate(),
2423
.vendor = ffStrbufCreate(),
2524
};
@@ -71,9 +70,7 @@ void ffPrintCPU(FFCPUOptions* options)
7170
else if(cpu.coresOnline > 1)
7271
ffStrbufAppendF(&str, " (%u)", cpu.coresOnline);
7372

74-
uint32_t freq = cpu.frequencyBiosLimit;
75-
if(freq == 0)
76-
freq = cpu.frequencyMax;
73+
uint32_t freq = cpu.frequencyMax;
7774
if(freq == 0)
7875
freq = cpu.frequencyBase;
7976
if(freq > 0)
@@ -96,8 +93,6 @@ void ffPrintCPU(FFCPUOptions* options)
9693
ffParseFrequency(cpu.frequencyBase, &freqBase);
9794
FF_STRBUF_AUTO_DESTROY freqMax = ffStrbufCreate();
9895
ffParseFrequency(cpu.frequencyMax, &freqMax);
99-
FF_STRBUF_AUTO_DESTROY freqBioslimit = ffStrbufCreate();
100-
ffParseFrequency(cpu.frequencyBiosLimit, &freqBioslimit);
10196

10297
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
10398
ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig, &options->moduleArgs);
@@ -111,7 +106,6 @@ void ffPrintCPU(FFCPUOptions* options)
111106
FF_FORMAT_ARG(freqMax, "freq-max"),
112107
FF_FORMAT_ARG(tempStr, "temperature"),
113108
FF_FORMAT_ARG(coreTypes, "core-types"),
114-
FF_FORMAT_ARG(freqBioslimit, "freq-bios-limit"),
115109
}));
116110
}
117111
}
@@ -190,7 +184,6 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
190184
.temperature = FF_CPU_TEMP_UNSET,
191185
.frequencyMax = 0,
192186
.frequencyBase = 0,
193-
.frequencyBiosLimit = 0,
194187
.name = ffStrbufCreate(),
195188
.vendor = ffStrbufCreate(),
196189
};
@@ -219,7 +212,6 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
219212
yyjson_mut_val* frequency = yyjson_mut_obj_add_obj(doc, obj, "frequency");
220213
yyjson_mut_obj_add_uint(doc, frequency, "base", cpu.frequencyBase);
221214
yyjson_mut_obj_add_uint(doc, frequency, "max", cpu.frequencyMax);
222-
yyjson_mut_obj_add_uint(doc, frequency, "biosLimit", cpu.frequencyBiosLimit);
223215

224216
yyjson_mut_val* coreTypes = yyjson_mut_obj_add_arr(doc, obj, "coreTypes");
225217
for (uint32_t i = 0; i < sizeof (cpu.coreTypes) / sizeof (cpu.coreTypes[0]) && cpu.coreTypes[i].count > 0; i++)
@@ -248,7 +240,6 @@ void ffPrintCPUHelpFormat(void)
248240
"Max frequency (formatted) - freq-max",
249241
"Temperature (formatted) - temperature",
250242
"Logical core count grouped by frequency - core-types",
251-
"Bios limited frequency (formatted) - freq-bios-limit",
252243
}));
253244
}
254245

src/modules/loadavg/loadavg.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ void ffPrintLoadavg(FFLoadavgOptions* options)
3232
.temperature = FF_CPU_TEMP_UNSET,
3333
.frequencyMax = 0,
3434
.frequencyBase = 0,
35-
.frequencyBiosLimit = 0,
3635
.name = ffStrbufCreate(),
3736
.vendor = ffStrbufCreate(),
3837
};

0 commit comments

Comments
 (0)