How to not let kernel_task take too much CPU when the machine is hot?

https://grafxflow.co.uk/blog/mac-os-x/delete-ioplatformpluginfamilykext-macos-big-sur

The above instruction is based on an assumption.

Does anybody know a general solution to the problem (for example, for a new machine)? Thanks.


Solution 1:

It is correct that macOS kernel when sensing too high temperatures will try to lower temperature by effectively idling the CPU. This shows up in Activity Monitor as the kernel_task process using a lot of CPU time - which is actually not really the case, but that CPU time is not available to other processes either.

I would not attempt to disable this mechanism in macOS when faced with this issue. Instead you should treat the root cause - i.e. why is the system sensing too high temperatures.

This could be due to the system actually being too hot (clean fans, replace thermal paste, etc.) or it could be sensor error (recalibrate sensor, replace sensor).

If you absolutely need to disable the mechanism, look at a guide such as this. It basically instructs you to disable the IOPlatformPluginFamily kernel extension - which is nearly always a very bad idea.

Also you should always remember to recheck your assumptions. Could it be that kernel_task is not seemingly using lots of CPU time because of the machine being hot, but rather that you have a very special workload or hit a bug that caused kernel_task to actually consume lots of CPU time. It would be a good idea to ensure that this is not the case, if you haven't done so already.

Depending on the version of macOS you're running, you can gather more information by running these commands in the Terminal:

ioreg -l | grep ForcedIdle
ioreg -l | grep IdlePLimit

Look for "IdlePLimitRegistered".

Solution 2:

To build on @jksoegaard's excellent answer:

In order to rule out the possibility of this being caused by a viral workload or a bug in the kernel or a kernel extension, we need to see what the kernel is doing when it's consuming excess CPU. The way to do this is by collecting and analyzing a spindump. To do this:

  1. Run the following Terminal command to enable kernel symbolication:

     sudo nvram boot-args="keepsyms=1"
    

    Make sure to copy-paste this so that you're entering straight quotes rather than curly/“smart” quotes. (If you get a general error, you will first need to disable System Integrity Protection. You can re-enable it after you're done with this investigation.)

  2. Reboot your machine and don’t open any apps except for Terminal.

  3. In Terminal, enter the following command, press Return, type in your password, but do not press Return again yet:

     sudo spindump -reveal -noProcessingWhileSampling
    
  4. Perform the minimum actions that are necessary in order to put the system into its high-CPU usage state.

  5. As soon as you begin to feel the slowness, go to the Terminal window where you entered your password and press Return so that the command begins to execute. Do not do anything else on the computer while it's running, otherwise you will distort the data collection.

  6. After waiting for >10 seconds to collect a sample and another minute or two to symbolicate and format, you’ll get a file in /tmp/spindump.txt that contains a stackshot of every process.

  7. Upload the file to PasteBin or some equivalent place and add the link to it to your original question. We can take a look at it and come up with next steps for the investigation.