11 ms·
Fix Intel CPU Throttling on Linux
- wetpaws 4y agoWhy is intel like this =\
- brianwawok 4y agoThe laptop builder likely didn’t spend the extra $2 to properly cool the CPU, so the CPU slows down to prevent burning out or burning your lap? The CPU being smart about its own temp is a good thing.
- wmf 4y agoThat's not what's happening in this case. Linux is getting much lower performance than Windows on the same laptop due to a firmware bug.
- mjg59 4y agoNo, Linux is getting lower performance than Windows because distributions aren't shipping the tooling needed to inform the firmware that the OS can manage platform thermals, and so the firmware is defaulting to a safe state. Of course, the reason they're failing to do so is because Intel never publicly documented any of this.
- ladyanita22 4y agoI don't understand what's so difficult about this. Why is Intel not providing the documentation? And what is it so difficult to reverse engineer? Is this tool correctly reading the DPTF data and correcting for it?
- mjg59 4y ago> I don't understand what's so difficult about this. It requires parsing multiple undocumented binary file formats, making sense of how the information in each is interlinked, and writing code that keeps track of system state, compares it against the firmware policy, and then imposes the appropriate constraints. > Why is Intel not providing the documentation? I have no idea. > And what is it so difficult to reverse engineer? https://github.com/mjg59/thermal_daemon/compare/028bde5bf0f14982cc23382cba41345a3b3e007c..HEAD https://github.com/mjg59/thermal_daemon/compare/028bde5bf0f1... was my initial implementation of this (remember to click "Load diff" for anything that's too large for github to display by default). There's a fair amount of complexity here! > Is this tool correctly reading the DPTF data and correcting for it? Thermald reads the DPTF data, throttled doesn't. I can't promise that thermald reads it correctly given the lack of a spec, but to the best of my knowledge it does.
- wmf 4y agoWhy does Intel allow firmware to control power management? That's a long story but it's very boring and hardly evil.
- mjg59 4y agoManufacturers (rightly or wrongly) believe users want machines that are as thin and light as possible. This makes a bunch of things more complicated, including managing system thermals. Heat generated from the CPU has to go somewhere. As you get thinner, it's hard to get as much airflow and so fans are less effective. As you reduce the amount of material in the chassis, the less heat can be dumped in there without it heating up enough to potentially be uncomfortable for the user. Larger internal batteries become another source of heat while charging. Handling all of this safely becomes difficult, especially because there isn't necessarily a policy that satisfies all your users. But you can't leave it purely up to the OS either, because the OS has no idea of what the thermal characteristics of the platform are. So rather than attempting to encode all of this policy directly into firmware, Intel wrote the Dynamic Power and Thermal Framework (DPTF) spec, providing a mechanism for the firmware to share information about thermal control interfaces, interactions, and desired temperature bounds, and then let the OS make policy control decisions around that. Until the OS indicates it's ready to take over, the firmware imposes a default safe policy that's guaranteed to avoid any thermal issues, albeit at the cost of performance. Of course, this only works if the OS knows how to do this, and Intel never publicly documented it so I had to reverse engineer it instead.
- ladyanita22 4y agoIs Linux taking a conservative approach because they're ignoring the DPTF? Why is this not a problem on Windows?
- mjg59 4y agoBy default Linux is taking no approach at all, which means the thermal policy is the most conservative the firmware can configure. If you install thermald then Linux will implement the same policy that Windows does and should have the same performance.
- pjmlp 4y agoAnother example of how being open source friendly boils down to "it depends on the green paper" even for the companies that do market themselves as such. This is not the only area where Intel doesn't really support Linux, some of their GPU models also come to mind, like the PowerVR based ones in the past.
- userbinator 4y agoThis isn't Intel's fault... unless you consider them providing things like adjustable power limits a problem. Its CPUs have had automatic thermal throttling and will shutdown on catastrophic overheating ever since the Pentium II. It's all the fault of manufacturers who want to both save cost with inadequate heatsinks and impose arbitrary restrictions on their products. The software in this article looks like the Linux equivalent of ThrottleStop, a Windows application that was the first to expose the truth behind it all.
- mjg59 4y agoI'm not sure how failing to publicly document the DPTF specification is anything other than Intel's fault. The CPUs are not running in such a constrained configuration under Windows, for example, because Intel supply drivers to configure them appropriately.
- userbinator 4y agoWindows doesn't need DPTF either --- a quick search online shows just how many others are getting much better performance after applying NoDPTF.reg and similar fixes.
- mjg59 4y agoYou're being weirdly obtuse here. Yes, you can make hardware perform faster by running it outside its design limits. That doesn't mean it's a good idea in the general case, even if the tradeoffs make sense for you as an individual.
- userbinator 4y ago"design limits", more like "marketing limits". It's certainly a good idea if you realise just how much they're fleecing you.
- ladyanita22 4y agoExactly, the CPUs run much more loosely on Windows than on Linux. It shouldn't be too difficult to correct this...
- scruple 4y agoI was very surprised by some of the thermal characteristics of my i7-13700k. My previous build was an i7-4790k, so it's been a minute. I had to undervolt this thing and cap it's max TDP (disable boost modes -- it has boost modes which are very thirsty) to get it to complete benchmarks while staying under 90* C (with a top of the line case, very good fans / circulation, and a large AIO). It's great now but undertuning the thing is a total departure from what I recall from '00s and '10s gaming machines.
- csdvrx 4y agoI wish I could undervolt my laptop. As noted by the author: > ===== Notice that undervolt is typically locked from 10th gen onwards! ===== I can't even modify the BIOS due to BootGuard and the keys burned into the CPU. Hopefully there will be a way to leak/extract the keys someday, as this create real e-waste for fake security.
- mjg59 4y agoBoot Guard is based on RSA signatures, so the private key material isn't present on the device
- csdvrx 4y agoI was thinking more about the recent Alder Lake Lenovo leaks :) Right now I'm fighting with nohz_full and rcu_nocbs to limit the wakes per second, with irqaffinity on top to isolate to one core what must happen so that the others can stay in PC8 when I'm not compiling. I'm down to about 350 on a 12th gen Alder Lake with E and P cores running Wayland with a few terminals, Thunderbird and Edge) but I wish I had the ability to also undervolt to go beyond 4W
- NavinF 4y ago> i7-13700k 253 W max turbo power is not that crazy by today's standards. > top of the line case, very good fans / circulation, and a large AIO I think you'll find that what people consider good cooling for a desktop has changed somewhat in the last decade. My first GPU didn't even have a fan, but today it's fairly common for enthusiast builds to have an external radiator. I dunno what you consider large, but most AIOs only have slightly more surface area than large air coolers so they really aren't worth it for sustained workloads like gaming or ML training. Custom loops have always been the go-to solution.
- moffkalast 4y agoConsumers: keep buying whatever garbage Intel puts out each year Consumers: "Why would Intel do this?"
- mjg59 4y agoThis is really not the correct approach. https://github.com/intel/thermal_daemon https://github.com/intel/thermal_daemon ought to do a better job without ignoring manufacturer thermal limits (I reverse engineered Intel's Dynamic Power and Thermal Framework a few years back, and upstream kernels should have everything needed now: https://mjg59.dreamwidth.org/54923.html https://mjg59.dreamwidth.org/54923.html)
- userbinator 4y agowithout ignoring manufacturer thermal limits The whole point is to ignore them because they're horrible and hold back what these CPUs can really do. Fuck the manufacturers playing these stupid marketing games. Intel warrants their CPUs at TjMax 24/7, they'll automatically throttle when they hit that limit, and disabling all this other throttling crap makes them run that way for full performance.
- rincebrain 4y agoFWIW, I've managed to make multiple X1C6s thermally trip and shut off without changing from the safe configuration, which rather impressed me because I didn't know that was feasible these days. Mostly I mention it to say that there's not _no_ reason for thermal limits in modern setups...
- userbinator 4y agoI believe that's called a defective product --- and reminds me of a certain somewhat infamous series of Toshiba laptops which would overheat and shutdown if you spent too long in BIOS setup, because the fans were entirely software controlled. There's zero reason for all this extra "thermal management" crap beyond corporate greed.
- mjg59 4y agoYou can design hardware that's capable of dissipating the maximum heat output of every component simultaneously, but you'll end up with hardware that's significantly larger, heavier, and costs more to manufacture. Or you can design hardware that's capable of dissipating the expected heat output under a range of use-cases, and devolve policy management to the OS so it can (based on user preference) prioritise appropriately, allowing you to produce smaller, lighter machines that either cost less or generate more profit. Even if the motivation for cutting costs is to increase profit margins, users generally still seem to prefer the smaller, lighter hardware that works just fine under most circumstances.
- jeffbee 4y agoIt seems there is an endless supply of people who know just enough to write some system programs but not enough to learn basic energy accounting. You cannot simply make a CPU run faster by writing MSRs. The current goes in and the heat goes out and the temperature goes up. You can't make it just work under arbitrary parameters.
- userbinator 4y agoYou can, because they come crippled by default now. The benchmarks do not lie.
- deleted 4y ago[deleted]
- dur-randir 4y ago>You cannot simply make a CPU run faster by writing MSRs I like such generalised statements. You can read about xeon v3 hack and ThrottleStop PowerCut. Each is just "writing MSRs" with a funny side-effect of your CPU taking more current in.
- jusssi 4y agoSure you can. It just makes the cooling fan to actually start spinning and do its job. Yeah. It's that bad. I have a Thinkpad P14s.
- Avamander 4y agoCan concur, the defaults cause throttling before fans start spinning properly. What's worse, these things have an accelerometer that causes the same type of throttling if you move your laptop. Fuck Intel-based clothes-iron laptops so hard.
- Valmar 4y agoThe real solution for laptops ~ just disable boost! (Granted, you might have to disable it via /sys every boot, but that can be scripted...) Laptops shouldn't be using boost anyways, because their form factors and CPU coolers just can't handle the heat output.
- userbinator 4y agoIf you want really long battery life and no heat at all, you can downclock all the way to something like 200-400MHz. A recent CPU at that speed is actually quite usable for things like text editing and reading documentation. Laptops shouldn't be using boost anyways, because their form factors and CPU coolers just can't handle the heat output. On the other hand, if it's plugged in much of the time, then let it boost as much as it can, with speed only thermally limited. Otherwise you're not getting the true performance you paid for.
- Valmar 4y ago> If you want really long battery life and no heat at all, you can downclock all the way to something like 200-400MHz. A recent CPU at that speed is actually quite usable for things like text editing and reading documentation. Linux does grant the user that flexibility, so if someone actually wants that, they can have it. The max non-boost frequency is usually the sweet spot for performance and efficiency. > On the other hand, if it's plugged in much of the time, then let it boost as much as it can, with speed only thermally limited. Otherwise you're not getting the true performance you paid for. If the user wants to live with a potentially reduced laptop lifespan, sure thing. But it's just not worth it for a laptop, frankly, given their limited thermal cooling capacities. That CPU will degrade over time when run at that level of heat.
- userbinator 4y agoThat CPU will degrade over time when run at that level of heat. If Intel warrants their CPUs to be at TjMax 24/7, it's a good sign that it shouldn't be a problem. I have not heard of overheating killing CPUs since the days when AMD's didn't have any thermal protection[1], and I've cleaned out machines which were heavily clogged with dust and thermally throttling all the time for many years (the service prompted by their owners complaining about their computers being slow.) In one memorable case the push-in heatsink pins must've been originally not fully inserted, since they came out at some point and the heatsink was not even touching the CPU anymore, yet the CPU kept running for years in that state. [1] There's a famous TomsHardware video about that: https://www.youtube.com/watch?v=y39D4529FM4 https://www.youtube.com/watch?v=y39D4529FM4
- rowanG077 4y agoIt's honestly so frustrating. I bought an XPS 13 two and a half years ago and it's been a nightmare getting it to perform. I had to do the following things to make it run on non-turbo boosted clockspeeds without throttling: - Liquid metal TIM - Thermal pads + heat pipes connected to chassis to dissipate heat (Yes this means the bottom chassis heats up a lot) - Disable the intel_rapl_msr linux driver + disable BD_RPOCHOT via MSR Laptop has worked like a charm since. I really don't want a super thin laptop. I want a small laptop. I wouldn't mind 2 cm thick 13 inch laptop. But I can't handle a 15 inch laptop. I just find it way to large to be seriously portable.
- quesomaster9000 4y ago14 inch laptops are the sweet spot for me, easily fit in a backpack with a protective travel case and support larger memory & more performant CPUs. e.g. ThinkPad T14 Gen 3 AMD, Ryzen 7 pro 6850U, 32 gb LPDDR5-6400MHz for around 1000 EUR Having used an XPS 13 and XPS 15 I was underwhelmed and none of Dell's laptops hit the sweet spot for me.
- jeroenhd 4y agoThis looks like an excellent tool for people repurposing old laptops as servers by putting their motherboard in a different chassis and adding some proper cooling of their own to the board. May need to cool parts close to the CPU as well if the board wasn't designed to transport that much heat. If you try to do this to your laptop, well... there's a reason you can't legally sell laptops that heat up beyond 40-45℃. Expose yourself to that all you want, but be prepared for hardware damage, overheated skin, or decreased sperm count due to putting an overheated laptop in your lap. I wouldn't call this a fix in the same way I wouldn't call throwing out your smoke alarm a fix for the constant flat battery beeping.
- hazaskull 4y ago...and then there is me using echo "75000000" | sudo tee /sys/class/powercap/intel-rapl/intel-rapl\:0/constraint_1_power_limit_uw to cap my i7-10700 to prevent it from overpowering the system fan by peaking to 200+ watts.
- SpacePortKnight 4y agoI want my laptop to be more predictable and reliable and with great battery life instead of having more performance. But thanks to turbo boost, sometimes my laptop is hot playing a youtube video but cool when compiling code or the other way around. There is no predictability on how long a compilation will take or how long the battery will last, since it would depend on N thermal and power factors. At least to me, this feels like when marketing designs products instead of product managers. I recently bought an Intel 12th gen i5-1240p laptop (asus zenbook) and this processor boosts from 1.7Ghz to 4.4Ghz i.e. more than twice the base frequency. That's absurd? I rather have a stable ~2Ghz than have the processor boost up to ~4Ghz while surfing the web. Hence we wouldn't need tools like this if at-least on laptop, Intel released chips with no or smaller turbo boost range.
- winrid 4y agoWe'll probably see physical "turbo" switches on laptops at some point as a gimmic, but that would honestly be ideal at this point.
- 0x6862 4y agoThrottled is great for undervolting your CPU
- akeck 4y agoWhat tools can do the opposite? I have a refurb Thinkpad X1 Carbon, running Deb 11 w/ i3, I use for creative writing (vim/markdown/pandoc). I'd like the battery to last as long as possible.
- mjg59 4y agoCheck /sys/class/powercap - if you have some RAPL entries there you can set the maximum power draw of the CPU. But in general if you have a fixed workload (ie, your system wants to do a certain amount of work, not use a certain percentage of CPU) then reducing CPU power limits will result in the CPU slowing down enough that it has to stay awake for longer to do that work, and will (counter-intuitively) actually consume more power to do the same amount of work. Running the CPU fast to get the work done quickly means the CPU can then put itself in a low-power state that shuts down a lot of ancillary components, saving more power than running the CPU at half the speed for twice as long.