Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 15: Time Management


value stored inidle_tickas basis. A sufficient number of tick intervals are added to obtain the
expiration time for the next tick.
❑ tick_stoppedis 1 if periodic ticks are stopped, that is, if there is nothing tick-based currently to
do.Otherwise,thevalueis0.

The remaining fields are used for bookkeeping:

❑ idle_jiffiesstores the value of jiffies when periodic ticks were disabled.
❑ idle_callscounts how often the kernel has tried to deactivate periodic ticks.idle_sleeps
counts how often this actually succeeded. The values differ because the kernel does not deac-
tivate ticks if the next tick is only one jiffy away.
❑ idle_sleeptimestores the exact time (with the best current resolution) when periodic ticks were
last disabled.
❑ sleep_lengthstores how long the periodic tick will remain disabled, that is, the difference
between the time the tick was disabled and when the next tick is scheduled to happen.
❑ idle_sleeptimeaccumulates the total time spent with ticks deactivated.
❑ next_jiffiesstores the jiffy value at which the next timer will expire.
❑ idle_expiresstores when the next classical timer is due to expire. In contrast to the value above,
the resolution of the value is as good as possible and not in jiffies.

The statistical information gathered intick_schedis exported to userland via/proc/timer_list.

tick_cpu_schedis a global per-CPU variable that provides an instance ofstruct tick_sched.Thisis
required because disabling ticks naturally works per CPU, not globally for the whole system.

15.5.2 Dynamic Ticks for Low-Resolution Systems


Consider the situation in which the kernel does not use high-resolution timers and provides only low res-
olution. How are dynamic ticks implemented in thisscenario? Recall from above that the timer softIRQ
callshrtimer_run_queuesto process the high-resolution timer queue, even if only low resolution is avail-
able in the underlying clock event device. Again, I emphasize that this does not provide better resolution
for timers, but makes it possible to use the existing framework independent of the clock resolution.

Switchingto DynamicTicks


hrtimer_run_queuescallstick_check_oneshot_changeto decide if high-resolution timers can be acti-
vated. Additionally, the function checks if dynamic ticks can be enabled on low-resolution systems. This
is possible under two conditions:


  1. A clock event device that supports one-shot mode is available.

  2. high-resolution is not enabled.


If both are fulfilled, thentick_nohz_switch_to_nohzis called to activate dynamic ticks. However, this
does not ultimately enable dynamic ticks. If support for tickless systems was disabled at compile time, the
function is just an empty dummy function, and the kernel will remain in periodic tick mode. Otherwise,
the kernel proceeds as shown in Figure 15-19.
Free download pdf