kernel_task Is Protective, not Problematic

Originally published at: https://tidbits.com/2019/02/22/kernel_task-is-protective-not-problematic/

Who knew? Howard Oakley reveals an Apple support note that explains that the kernel_task process monopolizes your Mac’s CPU to protect it from overheating and isn’t itself causing the problem.

1 Like

This is the most jaw-droppingly useful information I’ve read in a year. I’ve been trying to troubleshoot this for months—I thought I had rogue background processes in my kernel.

I have known that for a long time now. Sorry haven’t shared, but I never noticed it coming up here.

Of course, Apple could try not being obscure, and instead of kernel_task, which sounds like “hi, system here, I’ve got housekeeping to do, even though you’re desperate for every cycle you can grab right now, I’m going to tidy up right now; you can have your system back whenever I’m done.”; as opposed to, say, ‘CPU_overheat_protection’. If, indeed, that is its only purpose, its just another example of engineers living in another world. They may as well call it ‘goad_user’.

1 Like

My understanding is that kernel_task was the system doing things, specifically it was “top” or Activity Monitor’s way of showing system calls like file and networking activities. User level applications do not have permission to hardware and other kernel tasks so what kernel_task represents is the system API’s that bridge between user level stuff and stuff that requires kernel level permissions.

I heard this at a WWDC years ago and the presenter was basically saying that kernel debugging was extremely difficult because it’s so hard to see what the kernel is actually doing. Dtrace was suppose to help with this. It’s been a long time since I’ve been to WWDC so I don’t know what the current status is but kernel_task is still there so…

That was always what I thought too, but Apple is very clear in that support note about how at least some of kernel_task’s function is to protect against CPU overheating.

My guess is what they really mean is that a process is calling system API’s aggressively and kernel_task throttles itself instead of doing things as quickly as it’s being asked. It seems like bad design to have kernel_task ramp up it’s usage so that the cpu scheduling favors kernel_task instead of other processes. In fact, nice already can slow down greedy processes. I really think Apple means that the kernel_task is just throttling how fast it performs system API’s. I don’t know much about kernels so I could be wrong though.

1 Like

Maybe my understanding of physics is off, but if kernel_task is using more CPU than any other task, how is that reducing energy use (protecting from overheating)?

Agree that better naming of the process would be helpful.

1 Like

All I can assume is that kernel_task, by virtue of being Apple’s own low-level code, can block other processes from using the CPU without itself using the kind of behavior that causes overheating.

To be clear, kernel_task is the bootstrap and is always doing useful things; IIRC, it’s always PID 1 and has a nice value of -10, so it pre-empts all other usage. Ramping up its apparent usage is an elegant way of telling the rest of the system to fight over a smaller portion of CPU pie. In theory, if it claimed 400% on a four-core system, everything else would beachball.

I wonder: is there also an ambient temperature sensor that causes this protective behaviour? It has been record-breaking hot in the UK this last couple of days, and I reckon the temperature in my garden office (basically a glorified shed) has been hovering around 38ºC. Doesn’t bother me after years living and working in the tropics. But it sure as heck seems to bother my MacBook Pro. Every day this week it has become virtually unusable, as kernel_task has been using nearly all my CPU capacity. I have not been using any processor-intensive apps—mainly just Mail, Safari, WhatsApp.

Today I carried out an experiment and moved to the relative cool of the study in my house. It’s not air conditioned (it is the UK after all) but the house is materially cooler—maybe 25º. Instantly the fans spun down, and kernel_task ceased. So instantly I can’t believe in walking 10 metres the CPUs cooled that much.

Checking the CPU temperature in unusable-in-the-shed mode and back-to-normal-in-the-study mode it seems to be around 60º in both cases. (I use iStat Menus)

I hope this pops up in front of someone—the thread is five months old. I’d love to know the explanation of the behaviour I’m describing.

Apple recommends that Macs (and iPhones) not be operated at temperatures over 35º C (95º F) or even stored at temperatures above 45º C (113 º F). And you can actually hurt your electronics by doing so, because of the increased thermal expansion and the shortened battery life due to increased chemical reactions. It’s even possible for there to be a higher error rate in the chips which could lead to instability.

Plus, you don’t want to sweat into the keyboard. :slight_smile:

Thanks Adam. Fair enough. It’s never before been an issue in the UK —but surely temperatures regularly exceed 35º in many places in the States? As in other countries. So does that mean that you can only use a Mac in an air-conditioned environment? Who knew!

The Mac sits on a shelf raised above my desk and I use a remote keyboard—an ancient Microsoft one that has I suspect had worse than sweat dripped on it over the years!

I’m sure there’s some margin for error there, but the simple fact is that most people wouldn’t be comfortable working on a computer for any amount of time at those temperatures. The real thing to watch out for is leaving a Mac or iPhone in a car in the sun, where temperatures can go well above 45º C (113 º F).

I learned to take my case off my iPhone and put it in a shaded spot in my car. The iPhone is busy being charged, directing my driving and playing a podcast or music. One sunny day it go so hot that it shut down.

I suspect you can leave your case on, that it’s the shade that matters. It’s not super scientific but this video found that having a case on didn’t hurt performance due to thermal throttling: Does a Case Make Your Phone Slower?. If the case doesn’t insulate the phone enough to cause throttling under load at room temperature, my guess is it won’t cause the phone to shut down in a shaded spot in the car.