mate-desktop / mate-applets

Applets for use with the MATE panel
http://www.mate-desktop.org
GNU General Public License v2.0
78 stars 65 forks source link

Cpufreq doesn't show correct CPU frequency with intel_pstate #173

Open zaps166 opened 8 years ago

zaps166 commented 8 years ago

I've got i7 3770k CPU and intel_pstate driver at powersave governor. The cpufreq applet shows always 1.6GHz, but the CPU frequency is changing during CPU load.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/29460444-cpufreq-doesn-t-show-correct-cpu-frequency-with-intel_pstate?utm_campaign=plugin&utm_content=tracker%2F517519&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F517519&utm_medium=issues&utm_source=github).
monsta commented 8 years ago

Please file separate bug reports about each issue - makes it easier for us to track and handle.

zaps166 commented 8 years ago

Ok, this is done.

paraboul commented 8 years ago

Same issue here. Stuck at 500mhz (for every CPU) while cpupower freauency-info shows the correct value.

monsta commented 8 years ago

I can't reproduce this - but I have an old CPU, Core 2 Duo...

zaps166 commented 8 years ago

Ok, I know what is wrong! "intel_pstate" is not supported by this applet, so that why it doesn't work. I switched to "acpi-cpufreq" (intel_pstate=disable in kernel command line) and it works properly (but it should really be able to show entire CPU in one, especially if you want to change governor... https://github.com/mate-desktop/mate-applets/issues/174). @monsta: hmm, C2D is too old for this driver, so it will be difficult to fix it without testing...

raveit65 commented 8 years ago

found a kernel doc about intel_pstate https://www.kernel.org/doc/Documentation/cpu-freq/intel-pstate.txt Looks like SandyBridge procs support intel_pstate.

zaps166 commented 8 years ago

@raveit65: Yes, Sandy Bridge and newer CPUs.

monsta commented 8 years ago

Ok, I suspected that... so I need to upgrade my system or buy some modern laptop :smile:

zaps166 commented 8 years ago

I looked here: https://github.com/mate-desktop/mate-applets/blob/master/cpufreq/src/cpufreq-monitor-sysfs.c#L67

and I looked also to this virtual directory, e.g. into "scaling_cur_freq" file - the value changes while I'm pressing "F5" in text editor (intel_pstate), but applet shows only 1,60 (without unit). Maybe this is a simple bug to fix?

monsta commented 8 years ago

Interesting. But is 1.60 a valid value for that processor (e.g. for minimum frequency)?

monsta commented 8 years ago

Also check what's in this file:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

My system has ondemand setting there. It's also displayed in the tooltip of the applet.

zaps166 commented 8 years ago

In:

/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

I have powersave or performance (depending on chosen governor).

On Powersave the applet shows 1.6GHz, on Performance - 4.1GHz (Turbo + OC in UEFI/BIOS). But both of them dynamically changes the clock in range 1.6GHz - 4.1GHz. On performance the time/threshold is lower than powersave - that is the difference on "intel_pstate" (AFAIK). Applet shows only one value (the lowest for powersave, the highest for performance). I can change the governor by applet in "intel_pstate" - so this works properly.

monsta commented 8 years ago

Ok, thanks, it's more clear to me now. So, the code does the same thing it always did before:

    if (g_ascii_strcasecmp (governor, "userspace") == 0) {
        path = g_strdup_printf (CPUFREQ_SYSFS_BASE_PATH,
                    cpu, monitor_sysfs_files[SCALING_SETSPEED]);
    } else if (g_ascii_strcasecmp (governor, "powersave") == 0) {
        path = g_strdup_printf (CPUFREQ_SYSFS_BASE_PATH,
                    cpu, monitor_sysfs_files[SCALING_MIN]);
    } else if (g_ascii_strcasecmp (governor, "performance") == 0) {
        path = g_strdup_printf (CPUFREQ_SYSFS_BASE_PATH,
                    cpu, monitor_sysfs_files[SCALING_MAX]);
    } else { /* Ondemand, Conservative, ... */
        path = g_strdup_printf (CPUFREQ_SYSFS_BASE_PATH,
                    cpu, monitor_sysfs_files[SCALING_CUR_FREQ]);
    }

Basically, it only reads scaling_cur_freq file when the governor is set to ondemand (to be precise, when it's not userspace or powersave or performance). I've looked upstream (in gnome-applets) - the code is the same there too.

zaps166 commented 8 years ago

As far as I can remember performance runs at max. speed, powersave runs at min. speed and ondemand(and similar) dynamically scales the CPU on acpi-cpufreq. Modern governors can dynamically change the CPU frequency and them may have different names. For me it should do an update on every governor or leave it as is for acpi-cpufreq and for other - always read current frequency.

skoehler commented 8 years ago

intel_pstate doesn't allow the ondemand governor. It only allows powersave and performance. Yet, even if powersave is active, intel_pstate will still allow the CPU to run at max speed (even turbo).

I'd also like to see the cpufreq applet to work with intel pstate. That driver will be active on all modern systems (like my laptop). Also, the cpupower command is able to show correct CPU frequencies.

monsta commented 8 years ago

Ok, I see the problem. Looks like the logic in the code needs to be adjusted for pstate.

skoehler commented 8 years ago

I noticed that the cpufreq applet works with intel_pstate in Ubuntu 15.10 (MATE 1.12) but not on my Gentoo (MATE 1.13).

monsta commented 8 years ago

Not sure if it might be related, but Debian/Ubuntu builds use cpufreq library as cpupower library isn't available...

lucasmr commented 8 years ago

Running mate-applets 1.14.0 on gentoo, using an Ivy Bridge processor with intel_pstate powersave governor. It always shows the cores at 1.6GHz, when the cores vary from 1.6-3.8 depending on load according to cpupower frequency-info.

emanuele-f commented 7 years ago

It works for me with latest git version.

monsta commented 7 years ago

Works with which Intel CPU?

emanuele-f commented 7 years ago

Yes I have an i3-5010U. Previously I was using my distro package which didn't work, then I've tried the github version and it works. The applet seem to correctly show frequency changes, I've compared them with those reported by /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq and they seem ok.

Output of cpupower frequency-info:


  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 500 MHz - 2.00 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 500 MHz and 2.00 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: 800 MHz (asserted by call to hardware)
  boost state support:
    Supported: no
    Active: no```
monsta commented 7 years ago

Maybe a different value for --with-cpufreq-lib option is used now?

ericfont commented 6 years ago

I'm on Intel Core i7-6500U and I experience the same problem: I'm only able to set govenor to either "performance" or "powersave" and in either case the applet only displays max or min frequency, respectively.

It seems to me that the solution should be rather simple: always read SCALING_CUR_FREQ instead of having special cases for "performance", "powersave", nor even for "userspace" like:

https://github.com/ericfont/mate-applets/commit/29d6e2309c394ee222f5d115b10463e07e0e2ac7

apaan commented 5 years ago

I experience the same problem: using intel_pstate driver, with "powersave" governor it always shows the minimum CPU Frequency, and with "performance" the applet will display max Frequency.

Maybe this is the problem:

$ cpupower frequency-info
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 500 MHz - 1.90 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 500 MHz and 1.90 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 891 MHz (asserted by call to kernel)
  boost state support:
    Supported: no
    Active: no

but if i grep from /proc/cpuinfo, the correct CPU Mhz is there;

$ grep "cpu MHz" /proc/cpuinfo
cpu MHz     : 1599.576
cpu MHz     : 1707.923
cpu MHz     : 1694.300
cpu MHz     : 1528.936