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

Alexandre Julliard julliard at winehq.org
Fri Jul 24 17:05:10 CDT 2020


Module: wine
Branch: master
Commit: b37371bf20be58ee7bd0b63dbac15b474873bc86
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b37371bf20be58ee7bd0b63dbac15b474873bc86

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Fri Jul 24 11:14:05 2020 +0200

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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/system.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
index 681d56a869..3756bd7cee 100644
--- a/dlls/ntdll/unix/system.c
+++ b/dlls/ntdll/unix/system.c
@@ -2907,11 +2907,12 @@ NTSTATUS WINAPI NtPowerInformation( POWER_INFORMATION_LEVEL level, void *input,
             FILE* f;
 
             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");
-                if (f && (fscanf(f, "%d", &cpu_power[i].CurrentMhz) == 1)) {
-                    cpu_power[i].CurrentMhz /= 1000;
+                if (f && (fscanf(f, "%d", &cpu_power[i].MaxMhz) == 1)) {
+                    cpu_power[i].MaxMhz /= 1000;
                     fclose(f);
+                    cpu_power[i].CurrentMhz = cpu_power[i].MaxMhz;
                 }
                 else {
                     if(i == 0) {
@@ -2921,16 +2922,6 @@ NTSTATUS WINAPI NtPowerInformation( POWER_INFORMATION_LEVEL level, void *input,
                     }
                     else
                         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;
                     if(f) fclose(f);
                 }




More information about the wine-cvs mailing list