ntdll: Don't read current CPU frequency on Linux.

On the Linux boxes I tested, reading scaling_cur_freq usually takes
about 12 ms per core.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47128
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2020-07-24 11:14:05 +02:00 committed by Alexandre Julliard
parent d18b566995
commit b37371bf20
1 changed files with 4 additions and 13 deletions

View File

@ -2907,11 +2907,12 @@ NTSTATUS WINAPI NtPowerInformation( POWER_INFORMATION_LEVEL level, void *input,
FILE* f; FILE* f;
for(i = 0; i < out_cpus; i++) { for(i = 0; i < out_cpus; i++) {
sprintf(filename, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", i); sprintf(filename, "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", i);
f = fopen(filename, "r"); f = fopen(filename, "r");
if (f && (fscanf(f, "%d", &cpu_power[i].CurrentMhz) == 1)) { if (f && (fscanf(f, "%d", &cpu_power[i].MaxMhz) == 1)) {
cpu_power[i].CurrentMhz /= 1000; cpu_power[i].MaxMhz /= 1000;
fclose(f); fclose(f);
cpu_power[i].CurrentMhz = cpu_power[i].MaxMhz;
} }
else { else {
if(i == 0) { if(i == 0) {
@ -2921,16 +2922,6 @@ NTSTATUS WINAPI NtPowerInformation( POWER_INFORMATION_LEVEL level, void *input,
} }
else else
cpu_power[i].CurrentMhz = cpu_power[0].CurrentMhz; cpu_power[i].CurrentMhz = cpu_power[0].CurrentMhz;
if(f) fclose(f);
}
sprintf(filename, "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", i);
f = fopen(filename, "r");
if (f && (fscanf(f, "%d", &cpu_power[i].MaxMhz) == 1)) {
cpu_power[i].MaxMhz /= 1000;
fclose(f);
}
else {
cpu_power[i].MaxMhz = cpu_power[i].CurrentMhz; cpu_power[i].MaxMhz = cpu_power[i].CurrentMhz;
if(f) fclose(f); if(f) fclose(f);
} }