CPU Frequency Scaling is stuck at 800 MHz

NixOS unstable
Laptop: Macbook Pro 11,1
Processor: Intel(R) Core™ i5-4258U CPU @ 2.40GHz (Can turbo up to 2.9GHz)

I’ve been having a problem with CPU frequency scaling: it is almost always at 800 MHz.
This started some time after I first installed NixOS a few months ago, but it went away after a few days. It started again a few weeks ago, and hasn’t gone away.

This happens at all battery levels and all temperatures. Plugging into AC doesn’t help, even when the battery is full it doesn’t change clock speed, the CPU temperature isn’t that high (50-60C).

When looking at watch -pn 0.1 cat /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq, and using the performance governor the clock speed sometimes on one core briefly jumps up to 2.9 GHz, but when at least one processor is under constant load (opening a new browser tab, nixos-rebuild, loading a web page or program, etc.), it doesn’t do the brief jumps at all and just stays at ~800000.
With tbe schedutil governor, the frequency often jumps down to 768000, and occasionally up to the 1-2 GHz range. This happens with both intel_pstate and acpi_cpufreq.

A very odd thing is that when booting into MacOS, the exact same issue occurs - MacOS takes several minutes to load completely and also doesn’t do frequency scaling. Resetting the NVRAM with Option+Command+P+R doesn’t help.

With the default intel_pstate driver:

$ cpupower frequency-info -n:

analyzing CPU 0:
  driver: intel_cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 20.000 us
  hardware limits: 800.000 MHz - 2.900000 GHz
  available cpufreq governors: userspace performance schedutil
  current policy: frequency should be within 800.000 MHz and 2.900000 GHz.
                  The governor "userspace" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 800.021 MHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes

/sys/devices/system/cpu/cpufreq/policy*/cpuinfo_min/max_freq: 800000/2900000

/sys/devices/system/cpu/cpufreq/policy*/scaling_available_governors: userspace performance schedutil
At boot, userspace doesn’t show up but if you write that to scaling_governor it gets added to the list.
/sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq: ~800000
/sys/devices/system/cpu/cpufreq/policy*/scaling_min/max_freq: 800000/2900000
/sys/devices/system/cpu/cpufreq/policy*/scaling_setspeed: 2900000
Setting this to lower non-boost values also doesn’t work.

With acpi_cpufreq and intel_pstate=disable kernelParam:

Right after opening from suspend or reboot, it briefly goes to a speed of 2.4 GHz, and ocasionally does 2.9 GHz (and actually does feel fast), after gradually going back down to 800 MHz after around 10 seconds. (I think this effect only happens when TLP is installed. I’ve tried with and without TLP installed)

$ cpupower frequency-info -n:

analyzing CPU 1:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 10.000 us
  hardware limits: 768.000 MHz - 2.401000 GHz
  available frequency steps:  2.401000 GHz, 2.400000 GHz, 2.300000 GHz, 2.000000 GHz, 1.800000 GHz, 1.500000 GHz, 1.300000 GHz, 1.100000 GHz, 900.000 MHz, 768.000 MHz
  available cpufreq governors: performance schedutil
  current policy: frequency should be within 768.000 MHz and 768.000 MHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 800.020 MHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes

/sys/devices/system/cpu/cpufreq/policy*:
/sys/devices/system/cpu/cpufreq/policy*/bios_limit: 768000
When writing to bios_limit, I get Permission denied even when using sudo and setting /sys/module/processor/parameters/ignore_ppc to 1

/sys/devices/system/cpu/cpufreq/policy*/cpuinfo_cur_freq: 2401000

/sys/devices/system/cpu/cpufreq/policy*/cpuinfo_min/max_freq: 768000/2401000

/sys/devices/system/cpu/cpufreq/policy*/scaling_available_frequencies: 2401000 2400000 2300000 2000000 1800000 1500000 1300000 1100000 900000 768000

/sys/devices/system/cpu/cpufreq/policy*/scaling_available_governors: performance schedutil

/sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq: ~800000

/sys/devices/system/cpu/cpufreq/policy*/scaling_driver: acpi-cpufreq

/sys/devices/system/cpu/cpufreq/policy*/scaling_governor: performance
Setting this to schedutil doesn’t change anything

/sys/devices/system/cpu/cpufreq/policy*/scaling_min/max_freq:
768000/768000
This is what cpupower also displays, though the actual frequency is 800000 for some reason. Changing max_freq doesn’t give an error, but doesn’t change it.

/sys/devices/system/cpu/cpufreq/policy*/scaling_setspeed: <unsupported>


I’ve tried a lot of things and nothing works.

I’m not an expert on cpu scheduling, but I’m using tlp to set a governor and leave the frequencies to that daemon using governors of choice for AC and battery power. Maybe that is a good place to start.

I’ve tried that, it doesn’t help. I assume that it’s using the same sysfs interfaces as I showed, which don’t work.

The symptoms you are describing are pretty similar to what I had solved by enabling intel_pstate=active 2 years ago.

Maybe you suffer from the same problem?