blog/Why is My Laptop CPU So Slow

    Recently, my laptop, with an Intel i7-4700MQ CPU running Debian Linux began running very slowly (very is largely relative, I didn’t notice for months…) when I changed from the current stable Debian Linux kernel 3.16 to the 4.4 kernel available in Debian backports. I investigated and noticed that the CPU was often running at only 600-700Mhz! A simple command to show the speed of all of your cores is watch -n 1 'for i in /sys/devices/system/cpu/cpu?/cpufreq/cpuinfo_cur_freq ; do cat $i ; done'. Initially I assumed there was some misconfiguration of cpufreq, the Linux system which manages CPU speed. However, changing cpufreq settings, such as changing the governor to performance, changing the minimum speed, etc., had no effect at all. There are several other systems which may slow down the CPU:

    In the end, I discovered that on Linux 4.4 the /sys/devices/virtual/thermal/cooling_device0/cur_state would end up being set by something unknown to 4 when plugging or unplugging the power cable to my laptop resulting in 600-700Mhz operation. At the same time, the CPU reports seeing the PROCHOT or FORCEPR lines asserted as the power cable is plugged/unplugged. It’s my guess that this is the result of some interaction between the kernel, ACPI, and an external chip on the system. This hasn’t occurred since upgrading to Linux 4.5, but the behavior can be half-reproduced by writing 4 to /sys/devices/virtual/thermal/cooling_device0/cur_state.

    I have developed a script to detect some possible reasons why my CPU might be running slowly, it’s available at: https://github.com/orezpraw/scripts/blob/master/whyslow.pl.