What is DVFS (Dynamic Voltage and Frequency Scaling)?
Learn what DVFS is — P-states, CPU governors, and the power/voltage relationship — with an OS interview question answered in depth.
Expected Interview Answer
DVFS is a power-management technique where the OS or firmware dynamically lowers or raises a CPU's clock frequency and supply voltage based on current workload, since dynamic power scales roughly with frequency times voltage squared, so small voltage drops yield large energy savings.
A frequency governor in the kernel — such as Linux's “ondemand”, "schedutil", or “powersave” governors — samples CPU utilization and picks an operating point, called a P-state, that balances performance against power draw; low utilization triggers a lower P-state, while a burst of load triggers a fast ramp to a higher one. Because dynamic power is approximately proportional to frequency multiplied by voltage squared, and voltage must rise to support higher frequencies reliably, even a modest frequency cut combined with the resulting voltage cut can cut power draw dramatically for workloads that do not need peak speed. DVFS interacts closely with the scheduler: modern governors like schedutil take utilization signals directly from the scheduler rather than sampling independently, enabling faster and more accurate transitions. The trade-off is transition latency — switching P-states is not instantaneous — so overly frequent switching for bursty workloads can itself waste time and energy, which is why governors use hysteresis or utilization averaging before scaling down.
- Cuts power quadratically via voltage reduction, not just frequency
- Adapts continuously to real workload intensity rather than static settings
- Works closely with the scheduler for fast, accurate ramp-up under load
- Extends battery life and reduces datacenter cooling costs
AI Mentor Explanation
DVFS is like a bowler adjusting run-up length and effort based on the situation: a full sprint run-up with maximum effort is reserved for a wicket-taking ball, while a shorter, gentler run-up is used for a defensive over, saving energy across a long spell. The bowler does not sprint in on every single ball regardless of need, just as DVFS does not run the CPU at peak voltage for every instruction. Switching between full sprint and gentle pace too rapidly, ball to ball, would itself tire the bowler out — mirroring the transition cost of switching P-states too often.
Step-by-Step Explanation
Step 1
Sample utilization
The governor (e.g. schedutil) reads scheduler or hardware utilization signals for the CPU.
Step 2
Select a P-state
It maps utilization to an operating point balancing frequency and the minimum voltage needed to sustain it reliably.
Step 3
Apply the transition
Voltage and frequency are changed via the platform's power controller, which takes nonzero transition time.
Step 4
React to new demand
On a load spike, the governor ramps up quickly; on sustained idle, it settles to a low P-state to save power.
What Interviewer Expects
- Understanding that power scales with frequency times voltage squared
- Knowledge of Linux CPU frequency governors (ondemand, schedutil, powersave)
- Awareness of P-state transition latency as a real cost
- Distinction between DVFS and simple CPU idle/sleep states (C-states)
Common Mistakes
- Saying DVFS only changes frequency, forgetting the voltage component
- Confusing DVFS (active power scaling) with C-states (idle sleep states)
- Assuming faster P-state switching is always free/instantaneous
- Not knowing that schedutil integrates directly with the scheduler
Best Answer (HR Friendly)
“DVFS is the technique that lets a chip run slower and at lower voltage when there is not much work to do, and ramp up to full speed and voltage only when it is genuinely needed. Because power draw drops sharply when voltage is lowered, this is one of the biggest levers for battery life and datacenter energy costs, and the operating system's job is to make that scaling decision quickly and accurately as workload changes.”
Code Example
struct pstate {
unsigned freq_mhz;
unsigned voltage_mv;
};
/* ascending order of frequency/voltage */
struct pstate table[] = {
{ 600, 700 },
{ 1200, 850 },
{ 1800, 1000 },
{ 2400, 1150 },
};
#define N_PSTATES 4
int choose_pstate(unsigned util_percent) {
if (util_percent > 85) return N_PSTATES - 1; /* peak */
if (util_percent > 60) return 2;
if (util_percent > 30) return 1;
return 0; /* lowest power */
}Follow-up Questions
- Why does dropping voltage save more power than dropping frequency alone?
- How does the schedutil governor differ from the older ondemand governor?
- What is the cost of switching P-states too frequently?
- How do DVFS and CPU idle states (C-states) complement each other?
MCQ Practice
1. Dynamic power draw in a CPU scales approximately with?
The standard dynamic power model is P ~ f * V^2, which is why lowering voltage yields outsized power savings.
2. What does the Linux schedutil governor use to make scaling decisions?
schedutil integrates with the scheduler to react to utilization changes faster and more accurately than periodic sampling.
3. What is a real cost of switching P-states too frequently?
P-state transitions take nonzero time and energy, so overly aggressive switching for bursty loads can waste more than it saves.
Flash Cards
What does DVFS stand for? — Dynamic Voltage and Frequency Scaling.
Why does lowering voltage save so much power? — Because dynamic power scales with frequency times voltage squared.
What is a P-state? — An operating point combining a specific frequency and the minimum voltage needed to sustain it.
What is a downside of aggressive DVFS switching? — Transition latency between P-states can itself waste time and energy.