georgewhewell / undervolt

Undervolt Intel CPUs under Linux
Other
1.55k stars 107 forks source link

[Feature] Dynamic undervolt based on frequency #133

Open UnicodeMan opened 3 years ago

UnicodeMan commented 3 years ago

Hi. I have this idea. I have noticed that my Intel CPU (core+cache) can tolerate quite a huge undervolt (~-150mV), but only on a high frequency. Lets say, I start a CPU miner, then I undervolt my CPU. Miner runs well for any amount of time, but when I close it and CPU frequency dips, system freezes. I confirmed this by increasing minimum frequency to a higher value. I've seen similar stories in a few forums, too.

So in theory, there could be some kind of undervolting curve instead of a static undervolt value that is applied for all and any frequency, resulting in greater undervolt when it matters the most - at high load. In practice this may seem daunting as the drivers in the Linux kernel as well as the hardware itself are responsible for CPU frequency changes, not this tool.

I am not sure how implementation would come about (if it is at all possible), or if simplier workarounds would have to suffice (changing min frequency when game/something-that-eats-cpu starts, then undervolting, reverting both on game/something-that-eats-cpu exit)...

Is this something you would consider, or maybe thought about it already?

georgewhewell commented 3 years ago

It's an interesting idea for sure.. as you say, we need to supply some curve instead of fixed offset but Intel CPU don't seem to expose this functionality, i think. Possibly it could be implemented as kernel module to change offset when frequency changes, but i think at a minimum it would require disabling intel_pstate HWP- i understand this feature gives performance/power improvements itself, so setting frequency manually with increased undervolt may not even perform better. i think implementing in userspace (this tool) is pretty much impossible.. i checked and can replicate your result (can undervolt greater amounts under load), but cpu crashes as soon as load is removed, no time to increase voltage again

UnicodeMan commented 3 years ago

It may be quite a trivial fix from Intels' side (firmware+driver update), so quite possibly enthusiasts may have to nag Intel. Unless they manage voltages linearly (in some unchangeable hardware level), with initial min-max values. I mean their, "autonomous" mode (probably ME or ME + something). I may have misspoken here (somewhat ignorant, as I have never read Intel documentation, so I am "assuming" how the voltage/frequency control is handled in accelerated way)

Recently I have stumbled upon a less promising test result. Could you try reproducing this scenario: set minimum frequency of your device same as maximum, launch CPU-intense application, undervolt, run for a while, then kill the application. My laptop, dunno why, still hangs after removing load even though the frequency shouldn't dip. If that scenario is reproduceable, I am not sure this improvement should be pursued. It may be useful to test this on a larger sample size and variety (different architectures, form-factors, etc).

I kinda anticipated userspace implementation with everything as-is would not be plausible, so no surprise there.