Deferrable Timers
[Posted March, 2007 by Corbet]
The dynamic tick code featured in the upcoming 2.6.21 kernel seeks to avoid processor wakeups by turning off the period Ti Mer tick when it is happening. Before stopping the clock, the kernel must decide when it should to wake up again; This decision involves looking in the timer queue to the next timer expires. In the absence of "other events" (Hardware interrupts, for example), the system'll sleep until the nearest timer is due.
Many of these are timers should, in fact, run as soon as the requested period has. Others, however, are less important-to the point this they are not worth to the up the waking. These non-critical timeouts can run some fraction to a second later (when the processor is up to other wakes) and no Body would notice the difference. So it would is nice if there were a way to tell the kernel this a specific timer does not require immediate action on EXPI Ration and that's processor should not wake up for the sole purpose of handling it.
Venki Pallipadi has created such a way with the deferrable timers. There is just one new function added to the internal kernel API:
void init_timer_deferrable (struct timer_list *timer);
Timers which are initialized in this fashion would be recognized as deferrable by the kernel. They'll is considered when the kernel makes its ' when should the ' next timer interrupt be? ' decision. When the "system is" busy these timers'll fire at the scheduled time. When things are idle, instead, they'll simply wait until something more important the wakes.
Venki appears to have gone to great length to minimize the changes required from this patch. So, in particular, the "timer_list structure does not" change at all. Instead, the Low-order bit on a internal pointer (which are known to always do Zero) is repurposed as a "deferrable" flag. The ' result ' is ' that ' timer_list structure does not grow to support this new functionality, at the $ requiring all The code using the internal base pointer to mask out the "deferrable" bit.
The patch, as presented, only affects timers used within the kernel; No code has been changed to actually use DEFERRABL e timers yet. There could is potential in extending this interface to the user space. Our user spaces remains full of applications which feel the need to wake up frequently to check the "state" of the world; These are applications are a real problem for power-limited systems. If Those applications truly cannot be fixed, perhaps they could in least indicate a willingness to Tant is going on.