xref: /freebsd/share/man/man4/eventtimers.4 (revision 61e21613)
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.Dd March 13, 2012
26.Dt EVENTTIMERS 4
27.Os
28.Sh NAME
29.Nm eventtimers
30.Nd kernel event timers subsystem
31.Sh SYNOPSIS
32Kernel uses several types of time-related devices, such as: real time clocks,
33time counters and event timers.
34Real time clocks responsible for tracking real world time, mostly when system
35is down.
36Time counters are responsible for generation of monotonically increasing
37timestamps for precise uptime tracking purposes, when system is running.
38Event timers are responsible for generating interrupts at specified time or
39periodically, to run different time-based events.
40This page is about the last.
41.Sh DESCRIPTION
42Kernel uses time-based events for many different purposes: scheduling,
43statistics, time keeping, profiling and many other things, based on
44.Xr callout 9
45mechanism.
46These purposes now grouped into three main callbacks:
47.Bl -tag -width ".Fn hardclock"
48.It Fn hardclock
49.Xr callout 9
50and timekeeping events entry.
51Called with frequency defined by
52.Va hz
53variable,
54usually 1000Hz.
55.It Fn statclock
56statistics and scheduler events entry.
57Called with frequency about 128Hz.
58.It Fn profclock
59profiler events entry.
60When enabled, called with frequency about 8KHz.
61.El
62.Pp
63Different platforms provide different kinds of timer hardware.
64The goal of the event timers subsystem is to provide unified way to control
65that hardware, and to use it, supplying kernel with all required time-based
66events.
67.Pp
68Each driver implementing event timers, registers them at the subsystem.
69It is possible to see the list of present event timers, like this, via
70.Va kern.eventtimer
71sysctl:
72.Bd -literal
73kern.eventtimer.choice: HPET(550) LAPIC(400) i8254(100) RTC(0)
74kern.eventtimer.et.LAPIC.flags: 15
75kern.eventtimer.et.LAPIC.frequency: 0
76kern.eventtimer.et.LAPIC.quality: 400
77kern.eventtimer.et.i8254.flags: 1
78kern.eventtimer.et.i8254.frequency: 1193182
79kern.eventtimer.et.i8254.quality: 100
80kern.eventtimer.et.RTC.flags: 17
81kern.eventtimer.et.RTC.frequency: 32768
82kern.eventtimer.et.RTC.quality: 0
83kern.eventtimer.et.HPET.flags: 7
84kern.eventtimer.et.HPET.frequency: 14318180
85kern.eventtimer.et.HPET.quality: 550
86.Ed
87.Pp
88where:
89.Bl -inset
90.It Va kern.eventtimer.et. Ns Ar X Ns Va .flags
91is a
92bitmask, defining event timer capabilities:
93.Bl -tag -offset indent -width indent -compact
94.It 1
95periodic mode supported,
96.It 2
97one-shot mode supported,
98.It 4
99timer is per-CPU,
100.It 8
101timer may stop when CPU goes to sleep state,
102.It 16
103timer supports only power-of-2 divisors.
104.El
105.It Va kern.eventtimer.et. Ns Ar X Ns Va .frequency
106is a
107timer base frequency,
108.It Va kern.eventtimer.et. Ns Ar X Ns Va .quality
109is an
110integral value, defining how good is this timer, comparing to others.
111.El
112.Pp
113Timers management code of the kernel chooses one timer from that list.
114Current choice can be read and affected via
115.Va kern.eventtimer.timer
116tunable/sysctl.
117Several other tunables/sysctls are affecting how exactly this timer is used:
118.Bl -inset
119.It Va kern.eventtimer.periodic
120allows to choose periodic and one-shot operation mode.
121In periodic mode, periodic interrupts from timer hardware are taken as the
122only source of time for time events.
123One-shot mode instead uses currently selected time counter to precisely
124schedule all needed events and programs event timer to generate interrupt
125exactly in specified time.
126Default value depends of chosen timer capabilities, but one-shot mode is
127preferred, until other is forced by user or hardware.
128.It Va kern.eventtimer.singlemul
129in periodic mode specifies how much times higher timer frequency should be,
130to not strictly alias
131.Fn hardclock
132and
133.Fn statclock
134events.
135Default values are
1361, 2 or 4, depending on configured HZ value.
137.It Va kern.eventtimer.idletick
138makes each CPU to receive every timer interrupt independently of whether they
139busy or not.
140By default this options is disabled.
141If chosen timer is per-CPU
142and runs in periodic mode, this option has no effect - all interrupts are
143always generating.
144.El
145.Sh SEE ALSO
146.Xr apic 4 ,
147.Xr atrtc 4 ,
148.Xr attimer 4 ,
149.Xr hpet 4 ,
150.Xr timecounters 4 ,
151.Xr eventtimers 9
152