1

I am using Debian 10 (buster), 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux on my Lenovo T530 laptop which has a i7-3630QM. It has been many years since I bothered with frequency scaling and temperature but as of late it has become a bit of a problem.

When I try to run CPU intensive applications the CPU can get very hot for longer periods of time, I am talking above 100°C. Now this laptop is more than eight years old and I'm not sure how much longer it's going to last so I want to

  1. Have it last as long as possible and
  2. Reduce the noise pollution since the fan gets rather loud at high loads and temperatures.

Years ago there were several governors that could be used to do this so I was surprised that now there is only powersave and performance. I tried to use cpupower to set a maximum frequency of e.g. 2.4GHz: cpufreq-set -u 2.4GHz.

Unfortunately that does not seem to really work. cpupower frequency-info reports

  current policy: frequency should be within 1.20 GHz and 2.40 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.

but when I start a CPU intensive applications (especially one that is in need of 3D graphics acceleration), in my case the game "Stellaris", the CPU gets really hot nevertheless, which is not surprising since cpupower frequency-info reports

  hardware limits: 1.20 GHz - 3.40 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 1.20 GHz and 2.40 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 3.30 GHz (asserted by call to kernel)

which actually contradicts itself.

Now this issue has been discussed e.g. in this issue and the author resolves it in his answer. However, some people have commented that this does not work. In my case it does not work either. Another poster in this issue writes in his answer that this does not work either and actually links to a kernel document where it states that it is actually not possible to reliably set the frequency.

The fans of my laptop have been cleaned recently and new thermal paste has been applied but as I stated this machine is old and gets hot nevertheless. A different poster suggested setting the maximum load to a lower percentage, which actually works but does not rectify my problem since the CPU gets really hot nevertheless.

Does anyone know of a different, reliable way to limit the CPU frequency? In the aforementioned example, Stellaris, I think I noticed that the CPU tried to limit the frequency to the set value of 2.4GHz while the game was loading and while I was in the main menu. Once I loaded a save file and was in the game itself it spiked to its maximum frequency. Is it possible that the application itself overrides these values?

Does anyone know of any other way to throttle the CPU from reaching such high temperatures? E.g. is it possible to set a lower temperature threshold for when the CPU starts throttling itself?

muru
  • 72,889
crow
  • 51
  • 1
    Please try this script: https://github.com/birdie-github/useful-scripts/blob/master/cpumode via cpumode -s It's written by me, it's safe to use. – Artem S. Tashkinov May 22 '21 at 12:53
  • 1
    If you don't mind installing an extra package, I can recommend corectrl. – telometto May 22 '21 at 18:34
  • @ArtemS.Tashkinov thanks for the script. I tried using it but it seems I run into the same problem i.e. I can set a frequency but when loading an application that places a heavy load on the CPU/GPU the frequency limit is disregarded and the CPU runs hot anyway. @telometto I don't mind installing an extra package. Unfortunately corectrl is not available in Debian. I downloaded the source and compiled it (that step worked) but when I try to start the application nothing happens. I get kf5.kauth: Tried to start an invalid action and nothing more. Thanks for your sugestions, though! – crow May 24 '21 at 15:24
  • 1
    Try using acpi-cpufreq intead of intel_pstate : https://silvae86.github.io/2020/06/13/switching-to-acpi-power/ – Artem S. Tashkinov May 24 '21 at 18:46
  • @ArtemS.Tashkinov Thanks, I think this did work. Strange that the intel_pstate driver is so weird. – crow May 25 '21 at 17:07
  • 1
    You may want to file a bug report against intel_pstate along with the steps to repro the issue: https://bugzilla.kernel.org/enter_bug.cgi?product=Power%20Management Other users of similar CPUs will be grateful. Either the driver is not compatible with your IvyBridge CPU or it's missing something to support it. In any case, a bug report is really important. – Artem S. Tashkinov May 25 '21 at 17:50
  • @ArtemS.Tashkinov Do you want to write that as the answer to the question? I am not yet very familiar with StackOverflow. Do you really think I should file the bug report. The kernel documentation even states that the intel pstate driver does not necessarily does what the user wants. I probably should, though. – crow May 25 '21 at 18:16
  • 1
    Intel claims the intel_pstate driver supports all Intel Core CPUs starting with Sandy Bridge which is clearly not the case for you. A bug report could be useful. – Artem S. Tashkinov May 25 '21 at 20:28
  • @ArtemS.Tashkinov I'm not sure. I mean the kernel module did load and cpupower said that the driver used was intel_pstate. It's just that the behaviour of the driver was either misleading or maybe I just expected something that it didn't support. cpupower claimed you could set the maximum frequency to a certain value and that was true - just at some point the driver decided it knew better what to do. I am not defending intel_pstate, though. It's really strange behaviour and I'm going to go with acpi_cpufreq now, I just didn't know there was this possibility. – crow May 25 '21 at 20:32
  • 1
    From https://www.kernel.org/doc/html/v5.12/admin-guide/pm/intel_pstate.html : "intel_pstate is a part of the CPU performance scaling subsystem in the Linux kernel (CPUFreq). It is a scaling driver for the Sandy Bridge and later generations of Intel processors. Note, however, that some of those processors may not be supported. [To understand intel_pstate it is necessary to know how CPUFreq works in general, so this is the time to read CPU Performance Scaling if you have not done that yet.]" – Artem S. Tashkinov May 26 '21 at 01:56

1 Answers1

2

Thanks to Artem S. Tashkinov I was able to resolve the problem. He wrote in a comment

Try using acpi-cpufreq intead of intel_pstate : https://silvae86.github.io/2020/06/13/switching-to-acpi-power

and that did the trick.

I had to install the acpi_cpufreq driver (in my case it was already installed) via apt-get

apt-get install acpi-support acpid acpi

and edit /etc/default/grub by adding intel_pstate=disable to GRUB_CMDLINE_LINUX_DEFAULT, like so (in my case):

GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash debug intel_pstate=disable"

Then run update-grub and restart the machine. Consequently the intel_pstate driver is not used anymore and acpi_cpufreq is used in its stead. Apart from having many more governors to chose from (you can read here about them) and most of all I can now turn on the ondemand governor and set a minimum and maximum frequency. And it is kept that way. In my case I used

cpupower frequency-set -g ondemand -d 1.2GHz -u 2.0GHz

and so far the machine hasn't gotten too hot.

[edit] After still experiencing temperature problems I figured out what the problem is. It's the GPU frequency and the fact that this problem still occurred when using 3D applications. In /sys/kernel/debug/dri/0/i915_ring_freq_table you can see the max frequency the GPU can run at corresponding to a max CPU frequency. After setting the CPU frequency the GPU frequency has to be adjusted as well in /sys/class/drm/card0/gt_max_freq_mhz and in /sys/class/drm/card0/gt_boost_freq_mhz.

crow
  • 51
  • 1
    I'm still looking forward to a bug report from you :-) – Artem S. Tashkinov May 27 '21 at 15:55
  • Unfortunately it looks like switching to acpi_cpufreq did not solve this problem. I now upgraded to Debian testing where I have also access to cpupower-gui and the system just disregards what I choose. I can switch to powersave, 1.2 GHz to 2.0 GHz and it does not work. The CPU still clocks at maximum. – crow Jun 03 '21 at 16:37
  • I think I finally found the problem. This behaviour occurs when using 3D applications, i.e. when the internal GPU is being used. The problem was the GPU frequency. In /sys/kernel/debug/dri/0/i915_ring_freq_table you can see the max frequency the GPU can run at corresponding to a max CPU frequency. After setting the CPU frequency the GPU frequency has to be adjusted as well in /sys/class/drm/card0/gt_max_freq_mhz and in /sys/class/drm/card0/gt_boost_freq_mhz. – crow Jun 07 '21 at 06:46
  • 1
    This sounds quite ... unusual. I've had lots of laptops and PCs with Intel integrated graphics and CPU frequency could always be regulated independently from iGPU frequency. – Artem S. Tashkinov Jun 07 '21 at 08:54
  • I agree, it's quaint. The CPU freq I set is considered when not running 3D applications that use the video card. That is what lead me to this issue and this link as well as this issue. GPU clock is tied to CPU for some reason and certain GPU clocks can be only achieved by a min. CPU clock. Is that a bug/feature? Shall I still file that bug report? – crow Jun 07 '21 at 12:26
  • I would still file a bug report. Maybe it's a known issue but in this case documentation has to be updated and the driver has to issue a warning which is definitely not the case for you. – Artem S. Tashkinov Jun 07 '21 at 16:32