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