Linux Tickless Kernel NO_HZ Power Saving Explained
The Linux tickless kernel, designated by the configuration option
NO_HZ, significantly improves energy efficiency by
eliminating periodic timer interrupts when a CPU is idle. In standard
kernels, periodic hardware interrupts wake processors at fixed intervals
regardless of system load, which prevents hardware from remaining in
low-power states. By replacing fixed-rate ticks with on-demand, dynamic
timers, the tickless infrastructure allows idle CPU cores to enter and
maintain deep sleep states for longer durations, dramatically lowering
overall power consumption in both mobile devices and data centers.
The Problem with Periodic Timer Ticks
Historically, Unix-like operating systems rely on a periodic timer
tick—typically firing at frequencies like 100 Hz, 250 Hz, or 1000 Hz
(defined by CONFIG_HZ). Every time the tick fires, an
interrupt is raised to:
- Update system time and process accounting.
- Check if the currently running task has exceeded its time slice.
- Trigger software interrupts and evaluate timers.
While this mechanism ensures fairness in multi-tasking environments, it forces the CPU to wake up continuously—often hundreds or thousands of times per second—even when no user or kernel tasks require execution.
How the Tickless (NO_HZ) Architecture Works
The tickless design replaces repetitive periodic interrupts with
dynamic, single-shot timers powered by the kernel's high-resolution
timer (hrtimer) subsystem.
- Entering the Idle State: When a CPU has no runnable tasks in its runqueue, the operating system executes the idle task.
- Calculating the Next Event: Instead of waiting for the next periodic tick, the kernel inspects the timer queue to identify the earliest scheduled event or deadline across all active processes and hardware drivers.
- Reprogramming the Clock: The kernel reprograms the local CPU timer hardware to trigger a single interrupt at that specific future timestamp.
- Stopping the Tick: The regular, repetitive tick is
disabled (
CONFIG_NO_HZ_IDLE). The CPU remains inactive until that programmed deadline arrives or an external hardware interrupt (such as an incoming network packet or peripheral event) forces it to wake.
Prolonging Deep CPU Sleep States (C-States)
Modern processors save power through sleep states, known as C-states.
While C0 is the operational state where the CPU executes
instructions, states from C1 upward (e.g.,
C1E, C3, C6, C8)
progressively turn off internal clocks, flush caches, and reduce core
voltages.
Deeper C-states yield massive energy savings, but they come with a transition latency penalty—the CPU takes time and energy to enter and exit these states. If a CPU is interrupted every millisecond by a 1000 Hz periodic tick:
- It cannot remain idle long enough to satisfy the "target residency" of deep C-states.
- Entering deep C-states becomes counterproductive because the CPU would waste energy constantly transitioning between sleep and wake cycles.
By using NO_HZ, the Linux kernel extends contiguous idle
durations from milliseconds to hundreds of milliseconds or even seconds.
This enables power management subsystems like CPUIdle to
safely place cores into their deepest low-power states, minimizing
active power draw and heat generation.
NO_HZ Configuration Modes
Linux provides different levels of tickless operation depending on the workload and power profile:
CONFIG_NO_HZ_IDLE(Standard Dynamic Ticks): The default configuration on modern desktop, mobile, and server distributions. It disables the tick solely when the processor core is idle and resumes ticks as soon as a task begins execution.CONFIG_NO_HZ_FULL(Full Tickless): Extends the tickless mechanism by stopping the timer tick even when a user task is running, provided that exactly one task is pinned to that isolated CPU core. While primarily designed to reduce jitter in real-time computing and high-performance computing (HPC), it also avoids unnecessary context-switching overhead.CONFIG_HZ_PERIODIC: Disables tickless functionality entirely, maintaining fixed periodic interrupts regardless of CPU activity.
Impact on Battery Life and Thermal Efficiency
By allowing hardware to remain in low-power idle states
uninterrupted, the NO_HZ subsystem delivers measurable
efficiency improvements. On battery-powered systems like laptops,
tablets, and smartphones, the reduction in baseline idle power
significantly extends battery endurance. In multi-socket enterprise
servers, prolonged deep C-states lower idle power draw across dozens of
physical cores, reducing both electricity consumption and cooling
requirements in data centers.