Is hlt reduces CPU power consumption?
Posted: Tue Feb 09, 2016 9:23 am
When hlt command is executed by CPI, is it reduces power consumption?
The Place to Start for Operating System Developers
http://f.osdev.org/
In theory, PAUSE might make a tiny difference, but not much and it would depend a lot on a large number of things.Geri wrote:but can i use PAUSE instead of HLT as similar ways, to reduce/disable power consumption of the cores?
For this, you'd want to consider MONITOR and MWAIT - it's designed for things like "wait until some other CPU adds a job to the scheduler's queue".Geri wrote: its irrelevant if its yielded at NOP on earlyer cpus, since those will eat the energy aniway, but on newer ones, the energy can be saved.
i want to disable the cores if they dont have jobs to do (SMP) and i dont want to mess with interrupts to awake from HLT.
IIRC in practice the main thing that happens is that the hardware thread gets less dispatch cycles in a hyperthreading configuration.Brendan wrote:In theory, PAUSE might make a tiny difference, but not much and it would depend a lot on a large number of things.
I like to think of it as a kind of "speculative execution barrier" (to wait for a logical CPU's in-flight instructions to retire before starting more instructions from that logical CPU); but it's only a hint and a CPU is free to do whatever it wants (including ignoring it completely).Korona wrote:IIRC in practice the main thing that happens is that the hardware thread gets less dispatch cycles in a hyperthreading configuration.Brendan wrote:In theory, PAUSE might make a tiny difference, but not much and it would depend a lot on a large number of things.
PAUSE can also help to improve "spin loop exit" performance. For example, (without PAUSE) if you're spinning until a variable changes the CPU can have many iterations of the loop "in progress" (hurting performance for other CPUs sharing the core) and when the variable does change there's many iterations of the loop that need to be cleared out before the CPU can exit the loop properly (hurting "spin loop exit" performance).Sik wrote:The only purpose of PAUSE is to prevent the other thread in a core from being starved of resources during a spinlock, isn't it? I doubt it yields any gains in terms of power consumption at all.