16

Occasionally my machine will have a kernel_task instance max out the CPU:

high kernel_task CPU usage

This can last from minutes to sometimes hours. The machine is effectively unusable in this state. Restarting doesn't help; a new kernel_task pops up again until it finishes whatever it's doing.

How can I find out what this process is doing?

  • Woah, this just got much more interesting. Any chance we can get both snapshots updated a second time - same all process CPU sorted and the detailed power measure? – bmike Jul 1 at 22:41
  • @bmike I managed to both reproduce the issue and fix it at will. iStatMenus graphs confirm, the cause in my case is high chassis temperature from charging and peripherals plugged in to the left TB ports. – Adam Jul 6 at 1:42
  • Yes - that temperature sensor does have the ability to cause this precisely. Thanks for the edit - that helps clarify greatly the situation for the record. – bmike Jul 6 at 13:12
18

High kernel_task CPU Usage is due to high chassis temperature caused by charging. In particular Left Thunderbolt port usage.

Solutions include:

  • Move charging from the left to the right side. If you have a second charger then plug it in on the right side. Avoid plugging everything on the right side (see last paragraph below).
  • Unplug something from the left side. Either power or another accessory until the battery is full.
  • Force fans to max before plugging in. iStatMenus has an easy Sensors -> Fans menu item to do so. This only helps in marginal conditions.
  • Move to a cooler room.

Proof:

Actual CPU temperature or application CPU usage is uncorrelated with kernel_task. A hot CPU is throttled by reducing its clock speed, not by scheduling fake no-op load.

The graphs below are from iStatMenus. The machine had been used on battery then plugged in.

State A a USB-C hub (a mouse and keyboard, plus power) and a USB-C HDMI 2.0 adapter, both on the left side. You can see the Thunderbolt Left Proximity temperature sensor rise quickly. About 3-4 minutes later the dreaded kernel_task high CPU usage starts.

State B cures the kernel_task problem by moving power from the left ports to the right. The left side temperature drops and the kernel_task goes away within about 15 seconds.

This is causal. Moving power back to the left side, restoring State A, quickly restores the temperatures and kernel_task again comes back after 3-4 minutes. Again moving power back to the right side, restoring State B, resolves the problem immediately.

State C shows that simply having stuff plugged in to TB ports raises their temperature significantly. Both the hub (mouse and keyboard ONLY) and HDMI adapter individually raise the temperature about 10 degrees, and 15 degrees together.

CPU usage and temperature graphs

(all other temperatures were both low and flat. Under 55 degrees.)

Note that high temperature on the right side appears to be ignored by the OS. Plugging everything into the two right ports instead of the left raised the Right temperatures to over 100 degrees, without the fans coming on. No kernel_task either, but the machine becomes unusable from something throttling.

Ergo, high CPU usage by kernel_task is caused by high Thunderbolt Left Proximity temperature, which is caused by charging and having normal peripherals plugged in at the same time.

2017 15" Macbook Pro, MacOS 10.14.5


To actually answer the question:

How can I find out what this process is doing?

The only way to actually ask the kernel what it's doing is to attach a kernel debugger. That means getting a debug kernel from Apple, rebooting, then using a second Mac to attach to the debugged machine. You can then examine stack traces and guess what they mean.

Otherwise guessing and testing is the only way. Of course that leads to false conclusions more often than not.

  • Problem is for me, once Kernel_task and window server show up, NOTHING I can do will get rid of them or the bloat on the system. I used the system (and pushed it) for weeks and even on heavy use, kerneltask & windowserver didn't show up at all, until they did, and are stuck using 10-30% even after letting the system cool down and with nothing running. Etrecheck reports high I/O usage when those two processes are present, even on a cool, idle system. Do you have ANY thoughts on how to get those processes back in line once they are acting up? I'm pulling my hair out- this is a real nightmare! – Ellis Edwards Jul 6 at 3:04
  • 1
    this exact problem has been plaguing me to the brink of insanity for months, and I've tried everything to stop it. Recently, rolling back to HS from Mojave "solved" it, but it came back tonight out of the blue a week later, with seemingly no event triggering it again. I've don't about 30 different steps that I've found in forums over probably 40 hours since starting to troubleshoot. A new user on the same system seems to start fresh, but inevitably the problem comes back. I too feel like it has something to do with power/thunderbolt/heat. – Ellis Edwards Jul 6 at 3:04
  • 1
    For me it's not what you're doing with the machine, it's what's plugged in to it. Charging raises temperature by about 40 degrees, peripherals by about 15. For me kernel_task goes away when charging is done. Similarly using ports on both sides of the machine evens out the load and also solves the problem. – Adam Jul 6 at 3:21
  • Does kernel task go away entirely for you after charging or does it still hang out with low % in activity monitor? – Ellis Edwards Jul 6 at 4:56
4

As it persists for a very long time, and it persists across restarts, it seems likely that your problem is caused by a hardware problem - namely lack of cooling. You do not describe which type of computer you have, but try looking at its cooling to see if it's working as intended. You might have a broken fan, lots of dust or similar.

The kernel_task virtual process does, amongst other things, throttle CPU usage in order to keep the CPU below its maximum operating temperature. The purpose is to keep the CPU from shutting down unexpectedly. kernel_task does this by ensuring that the CPU is doing nothing for long periods of time - essentially making sure the CPU uses as little power as possible, which means that it gives off less heat. This makes it seem like kernel_task is using a lot of CPU, but in reality it is not.

  • You might be right that it's temperature related, but it's definitely not CPU temperature related. Your post made me enable iStat Menus' temperate sensor monitoring, and when this problem happened again the CPU was quite cool. See screenshot in edited OP. – Adam Jul 1 at 22:02
  • If you start in Recovery mode, do you still have high kernel_task CPU "usage"? – jksoegaard Jul 1 at 22:08
  • I anecdotally noticed that the kernel_task went away when the left thunderbolt temperature dropped below 70 degrees. I also noticed that plugging in a charger raises the temperature on the charging side by about 20-30 degrees. This means the effect is testable, and I'll confirm next time this problem happens. – Adam Jul 1 at 22:08
  • I only tried recovery mode once and it made no difference. I haven't been able to reliably reproduce this. – Adam Jul 1 at 22:09
  • "no difference" - does that mean that you also had high kernel_task usage there? – jksoegaard Jul 1 at 22:10
0

First measure the temperature around the Mac and then see if cooler air reduces this.

In your case, Skype and Firefox are getting all the cycles left over due to running hot. Windowserver and kernel just do the bidding of the other programs. Also, for a longer term view of what the CPU is doing, watch the energy tab in activity monitor.

By closing the apps that take CPU, you can “let the system run cool”. Running like this won’t hurt things, just there are thermal limits so more efficient apps or less demanding tabs / video / content lets you get more work done before the system protects itself.

  • The CPU temperature is quite low when this problem happens. If anything, it might be due to chassis temperature, in my case hot thunderbolt ports due to charging. If that's true then apple should have throttled charging not the CPU. – Adam Jul 1 at 22:04
  • You’re right. This isn’t the most obvious case and I’ll need to ponder the new data. Excellent edits @Adam I wonder if your circuitry is out of Spec if Apple runs diagnostics or this is just in spec (but unwanted) head generation from the power running through the power and data ASIC. – bmike Jul 1 at 22:39
0

Running spindump and or sample process from the activity monitor may help provide you with more information about what’s going on. Try to keep notice of when the CPU usage climbs and then look at the CPU Time on the other items listed in activity Monitor. You may notice a certain process starting up around the same time. Looking into threads in/out can help diagnose too. The issue could be either a bug within the kernel itself or whatever is requesting CPU time. It’s okay to have the CPU jump up every now and then if you don’t notice any system performance or temperature issues. Macs are built with their CPUs to withstand very high temps.

If you download a lot of apps the Launch Daemons, Launch Agents, and startup apps can add up quickly, possibly consuming CPU. It seems your system is having a lot of wake ups. Something could be hung up? You could also run “top” and “lsof” to get an idea of what the kernel is talking to. Also opening console and checking out the logs for any repeating errors helps. Testing a new user account will isolate any user related issues.

Look at you kernel panics and logs to see if there any reoccurring issues.
Make sure your fan starts spinning up when the computer gets warm. If not it could be a SMC issue. You can download software to control the speed of the fans to see if it reduces the CPU %.

The instruments app that comes with Xcode has some debugging and tracking features that also can help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .