Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 15: Time Management


The kernel distinguishes between two types of clocks:


  1. Aglobal clockis responsible to provide the periodic tick that is mainly used to update
    thejiffiesvalues. In former versions of the kernel, this type of clock was realized by
    the programmable interrupt timer (PIT) on IA-32 systems, and on similar chips on other
    architectures.

  2. Onelocal clockper CPU allows for performing process accounting, profiling, and last but
    not least, high-resolution timers.


The role of the global clock is assumed by one specifically selected local clock. Note that high-resolution
timers only work on systems that provide per-CPU clock sources. The extensive communication required
between processors would otherwise degrade system performance too much as compared to the benefit
of having high-resolution timers.

The overall concept is complicated by problems that unfortunately arise on the two most widespread
platforms: AMD64 and IA-32 (the MIPS platform is also affected). Local clocks on SMP systems are based
on APIC chips. Unfortunately, these clocks only work properly dependent on the power-saving mode
they are in. For low-power modes (ACPI mode C3, to be precise), the local APIC timers are stopped,
and thus become useless as clock sources. A system-global clock that still works at this power man-
agement state is then used to periodically activate signals that look as if they would originate from the
original clock sources. The workaround is known as thebroadcasting mechanism; more about this follow
in Section 15.6.

Since broadcasting requires communication between the CPUs, the solution is
slower and less accurate than properlocal time sources; the kernel will
automatically switch back high-resolution to low-resolution mode.

15.3.2 Configuration Options


Timer implementation is influenced by several configuration symbols. Two choices are possible at com-
pile time:


  1. The kernel can be built with or without support for dynamic ticks. If dynamic ticks are
    enabled, the pre-processor constantCONFIG_NO_HZis set.

  2. High-resolution support can be enabled or disabled. The pre-processor symbol
    CONFIG_HIGH_RES_TIMERSis enabled if support for them is compiled in.


Both are important in the following discussion of timer implementation. Recall that both choices are
independent of each other; this leads to four different configurations of the time and timer subsystems.

Additionally, each architecture is required to make some configuration choices. They cannot be influ-
enced by the user.

❑ GENERIC_TIMEsignals that the architecture supports the generic time framework.
GENERIC_CLOCKEVENTSstates that the same holds for generic clock events. Since both are
necessary requirements for dynamic ticks and high-resolution timers, only architectures that
Free download pdf