Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 15: Time Management


Before discussing these functions, let us therefore consider which situations are faced by the kernel
depending on the selected configuration:

❑ A low-resolution system without dynamic ticks always uses a periodic tick. Support for one-shot
operations is not included in the kernel at all.
❑ Low-resolution systems with dynamic ticks use the tick device in one-shot mode.
❑ High-resolution systems always use one-shot mode independent of whether they work with
dynamic ticks or not.

All systems initially work in low-resolution mode and without dynamic ticks; they switch to a different
combination only later when the required hardware is initialized. I therefore focus on the low-resolution,
periodic tick case here. The more advanced options are discussed in Sections 15.4.5 (high-resolution
timers) and 15.5 (dynamic ticks). Some corrections are also required for broadcast mode; Section 15.6
covers them in more detail.

Before examining the low-resolution case without dynamic ticks, I would like to point out that
Figure 15-9 provides an overview of the tick handler functions that are used for the various possible
combinations. Note that which broadcast function is chosen for a system without dynamic ticks depends
on the mode of the underlying tick device. The details are given below.

HZ-based dynamic ticks

tick_handle_oneshot_broadcast
tick_handle_oneshot_broadcast
tick_handle_periodic_broadcast

tick_handle_periodic (low-res)
hrtimer_interrupt (high-res)

tick_nohz_handler (low-res)
hrtimer_interrupt (high-res)

broadcast

event_handler

Figure 15-9: Tick event and broadcast handler functions for all possible combinations of low- and
high-resolution mode, and with/without dynamic ticks.

Let us finally turn our attention totick_setup_periodic. The code flow diagram is shown in
Figure 15-10.

Set event device to periodic mode

Set event device to one-shot mode

Program next clock event

Yes

No

tick_setup_periodic

tick_set_periodic_handler

Event device supports periodic events?

Figure 15-10: Code flow diagram fortick_setup_periodic.
Free download pdf