xref: /freebsd/share/man/man4/eventtimers.4 (revision 675be9115aae86ad6b3d877155d4fd7822892105)
1.\" Copyright (c) 2010 Alexander Motin <mav@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd September 15, 2010
28.Dt EVENTTIMERS 4
29.Os
30.Sh NAME
31.Nm eventtimers
32.Nd kernel event timers subsystem
33.Sh SYNOPSIS
34Kernel uses several types of time-related devices, such as: real time clocks,
35time counters and event timers.
36Real time clocks responsible for tracking real world time, mostly when system
37is down.
38Time counters are responsible for generation of monotonically increasing
39timestamps for precise uptime tracking purposes, when system is running.
40Event timers are responsible for generating interrupts at specified time or
41periodically, to run different time-based events.
42This page is about the last.
43.Sh DESCRIPTION
44Kernel uses time-based events for many different purposes: scheduling,
45statistics, time keeping, profiling and many other things, based on
46.Xr callout 9
47mechanism.
48These purposes now grouped into three main callbacks:
49.Bl -tag
50.It hardclock()
51.Xr callout 9
52and timekeeping events entry. Called with frequency defined by hz variable,
53usually 1000Hz.
54.It statclock()
55statistics and scheduler events entry. Called with frequency about 128Hz.
56.It profclock()
57profiler events entry. When enabled, called with frequency about 8KHz.
58.El
59Different platforms provide different kinds of timer hardware.
60The goal of the event timers subsystem is to provide unified way to control
61that hardware, and to use it, supplying kernel with all required time-based
62events.
63.Pp
64Each driver implementing event timers, registers them at the subsystem.
65It is possible to see the list of present event timers, like this, via
66.Va kern.eventtimer
67sysctl:
68.Bd -literal
69kern.eventtimer.choice: HPET(550) LAPIC(400) i8254(100) RTC(0)
70kern.eventtimer.et.LAPIC.flags: 15
71kern.eventtimer.et.LAPIC.frequency: 0
72kern.eventtimer.et.LAPIC.quality: 400
73kern.eventtimer.et.i8254.flags: 1
74kern.eventtimer.et.i8254.frequency: 1193182
75kern.eventtimer.et.i8254.quality: 100
76kern.eventtimer.et.RTC.flags: 17
77kern.eventtimer.et.RTC.frequency: 32768
78kern.eventtimer.et.RTC.quality: 0
79kern.eventtimer.et.HPET.flags: 7
80kern.eventtimer.et.HPET.frequency: 14318180
81kern.eventtimer.et.HPET.quality: 550
82.Ed
83, where:
84.Bl -tag
85.It Va kern.eventtimer.et. Ns Ar X Ns Va .flags
86bitmask, defining event timer capabilities:
87.Bl -tag -compact
88.It 1
89periodic mode supported,
90.It 2
91one-shot mode supported,
92.It 4
93timer is per-CPU,
94.It 8
95timer may stop when CPU goes to sleep state,
96.It 16
97timer supports only power-of-2 divisors.
98.El
99.It Va kern.eventtimer.et. Ns Ar X Ns Va .frequency
100timer base frequency,
101.It Va kern.eventtimer.et. Ns Ar X Ns Va .quality
102integral value, defining how good is this timer, comparing to others.
103.El
104.Pp
105Timers management code of the kernel chooses one timer from that list.
106Current choice can be read and affected via
107.Va kern.eventtimer.timer
108tunable/sysctl.
109Several other tunables/sysctls are affecting how exactly this timer is used:
110.Bl -tag
111.It Va kern.eventtimer.periodic
112allows to choose periodic and one-shot operation mode.
113In periodic mode, periodic interrupts from timer hardware are taken as the
114only source of time for time events.
115One-shot mode instead uses currently selected time counter to precisely
116schedule all needed events and programs event timer to generate interrupt
117exactly in specified time.
118Default value depends of chosen timer capabilities, but one-shot mode is
119preferred, until other is forced by user or hardware.
120.It Va kern.eventtimer.singlemul
121in periodic mode specifies how much times higher timer frequency should be,
122to not strictly alias hardclock() and statclock() events. Default values are
1231, 2 or 4, depending on configured HZ value.
124.It Va kern.eventtimer.idletick
125makes each CPU to receive every timer interrupt independently of whether they
126busy or not. By default this options is disabled. If chosen timer is per-CPU
127and runs in periodic mode, this option has no effect - all interrupts are
128always generating.
129.El
130.Sh SEE ALSO
131.Xr attimer 4 ,
132.Xr atrtc 4 ,
133.Xr hpet 4
134