FreeBSD kernel kern code
kern_tc.c File Reference
#include <sys/cdefs.h>
#include "opt_ntp.h"
#include "opt_ffclock.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/sleepqueue.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/timeffc.h>
#include <sys/timepps.h>
#include <sys/timetc.h>
#include <sys/timex.h>
#include <sys/vdso.h>
#include "opt_ddb.h"
Include dependency graph for kern_tc.c:

Go to the source code of this file.

Data Structures

struct  timehands
 

Macros

#define LARGE_STEP   200
 
#define GETTHBINTIME(dst, member)
 
#define GETTHMEMBER(dst, member)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static u_int dummy_get_timecount (struct timecounter *tc)
 
static int sysctl_kern_boottime (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, sysctl_kern_boottime, "S,timeval", "Estimated system boottime")
 
 SYSCTL_NODE (_kern, OID_AUTO, timecounter, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "")
 
static SYSCTL_NODE (_kern_timecounter, OID_AUTO, tc, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "")
 
 SYSCTL_INT (_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RWTUN, &timestepwarnings, 0, "Log time steps")
 
 SYSCTL_INT (_kern_timecounter, OID_AUTO, timehands_count, CTLFLAG_RDTUN|CTLFLAG_NOFETCH, &timehands_count, 0, "Count of timehands in rotation")
 
static int sysctl_kern_timecounter_adjprecision (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_timecounter, OID_AUTO, alloweddeviation, CTLTYPE_INT|CTLFLAG_RWTUN|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_timecounter_adjprecision, "I", "Allowed time interval deviation in percents")
 
static void tc_windup (struct bintime *new_boottimebin)
 
static void cpu_tick_calibrate (int)
 
void dtrace_getnanotime (struct timespec *tsp)
 
void dtrace_getnanouptime (struct timespec *tsp)
 
static int sysctl_kern_timecounter_get (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_timecounter_freq (SYSCTL_HANDLER_ARGS)
 
static __inline u_int tc_delta (struct timehands *th)
 
static __inline void bintime_add_tc_delta (struct bintime *bt, uint64_t scale, uint64_t large_delta, uint64_t delta)
 
static __inline void bintime_off (struct bintime *bt, u_int off)
 
static __inline void getthmember (void *out, size_t out_size, u_int off)
 
void binuptime (struct bintime *bt)
 
void nanouptime (struct timespec *tsp)
 
void microuptime (struct timeval *tvp)
 
void bintime (struct bintime *bt)
 
void nanotime (struct timespec *tsp)
 
void microtime (struct timeval *tvp)
 
void getbinuptime (struct bintime *bt)
 
void getnanouptime (struct timespec *tsp)
 
void getmicrouptime (struct timeval *tvp)
 
void getbintime (struct bintime *bt)
 
void getnanotime (struct timespec *tsp)
 
void getmicrotime (struct timeval *tvp)
 
void getboottime (struct timeval *boottime)
 
void getboottimebin (struct bintime *boottimebin)
 
void sysclock_getsnapshot (struct sysclock_snap *clock_snap, int fast)
 
int sysclock_snap2bintime (struct sysclock_snap *cs, struct bintime *bt, int whichclock, uint32_t flags)
 
void tc_init (struct timecounter *tc)
 
uint64_t tc_getfrequency (void)
 
static bool sleeping_on_old_rtc (struct thread *td)
 
 MTX_SYSINIT (tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_SPIN)
 
void tc_setclock (struct timespec *ts)
 
static void recalculate_scaling_factor_and_large_delta (struct timehands *th)
 
static int sysctl_kern_timecounter_hardware (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_timecounter, OID_AUTO, hardware, CTLTYPE_STRING|CTLFLAG_RWTUN|CTLFLAG_NOFETCH|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_timecounter_hardware, "A", "Timecounter hardware selected")
 
static int sysctl_kern_timecounter_choice (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_timecounter, OID_AUTO, choice, CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_timecounter_choice, "A", "Timecounter hardware detected")
 
static int abi_aware (struct pps_state *pps, int vers)
 
static int pps_fetch (struct pps_fetch_args *fapi, struct pps_state *pps)
 
int pps_ioctl (u_long cmd, caddr_t data, struct pps_state *pps)
 
void pps_init (struct pps_state *pps)
 
void pps_init_abi (struct pps_state *pps)
 
void pps_capture (struct pps_state *pps)
 
void pps_event (struct pps_state *pps, int event)
 
 SYSCTL_INT (_kern_timecounter, OID_AUTO, tick, CTLFLAG_RD, &tc_tick, 0, "Approximate number of hardclock ticks in a millisecond")
 
void tc_ticktock (int cnt)
 
static void __inline tc_adjprecision (void)
 
static void inittimehands (void *dummy)
 
 SYSINIT (timehands, SI_SUB_TUNABLES, SI_ORDER_ANY, inittimehands, NULL)
 
static void inittimecounter (void *dummy)
 
 SYSINIT (timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL)
 
 DPCPU_DEFINE_STATIC (uint64_t, tc_cpu_ticks_base)
 
 DPCPU_DEFINE_STATIC (unsigned, tc_cpu_ticks_last)
 
static uint64_t tc_cpu_ticks (void)
 
void cpu_tick_calibration (void)
 
void set_cputicker (cpu_tick_f *func, uint64_t freq, unsigned var)
 
uint64_t cpu_tickrate (void)
 
uint64_t cputick2usec (uint64_t tick)
 
static int sysctl_fast_gettime (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_timecounter, OID_AUTO, fast_gettime, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, 0, sysctl_fast_gettime, "I", "Enable fast time of day")
 
uint32_t tc_fill_vdso_timehands (struct vdso_timehands *vdso_th)
 

Variables

static struct timecounter dummy_timecounter
 
static struct timehands ths [16]
 
static struct timehands *volatile timehands = &ths[0]
 
struct timecounter * timecounter = &dummy_timecounter
 
static struct timecountertimecounters = &dummy_timecounter
 
static struct mtx tc_lock
 
int tc_min_ticktock_freq = 1
 
volatile time_t time_second = 1
 
volatile time_t time_uptime = 1
 
static int timestepwarnings
 
static int timehands_count = 2
 
struct bintime bt_timethreshold
 
struct bintime bt_tickthreshold
 
sbintime_t sbt_timethreshold
 
sbintime_t sbt_tickthreshold
 
struct bintime tc_tick_bt
 
sbintime_t tc_tick_sbt
 
int tc_precexp
 
int tc_timepercentage = TC_DEFAULTPERC
 
volatile int rtc_generation = 1
 
static int tc_chosen
 
static char tc_from_tunable [16]
 
int sysclock_active = SYSCLOCK_FBCK
 
int time_status
 
long time_esterror
 
static struct mtx tc_setclock_mtx
 
static int tc_tick
 
static int cpu_tick_variable
 
static uint64_t cpu_tick_frequency
 
cpu_tick_f * cpu_ticks = tc_cpu_ticks
 
static int vdso_th_enable = 1
 

Macro Definition Documentation

◆ GETTHBINTIME

#define GETTHBINTIME (   dst,
  member 
)
Value:
do { \
_Static_assert(_Generic(((struct timehands *)NULL)->member, \
struct bintime: 1, default: 0) == 1, \
"struct timehands member is not of struct bintime type"); \
bintime_off(dst, __offsetof(struct timehands, member)); \
} while (0)
void bintime(struct bintime *bt)
Definition: kern_tc.c:415

Definition at line 260 of file kern_tc.c.

◆ GETTHMEMBER

#define GETTHMEMBER (   dst,
  member 
)
Value:
do { \
_Static_assert(_Generic(*dst, \
__typeof(((struct timehands *)NULL)->member): 1, \
default: 0) == 1, \
"*dst and struct timehands member have different types"); \
getthmember(dst, sizeof(*dst), __offsetof(struct timehands, \
member)); \
} while (0)

Definition at line 281 of file kern_tc.c.

◆ LARGE_STEP

#define LARGE_STEP   200

Definition at line 49 of file kern_tc.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ abi_aware()

static int abi_aware ( struct pps_state *  pps,
int  vers 
)
inlinestatic

Definition at line 1585 of file kern_tc.c.

Referenced by pps_fetch().

Here is the caller graph for this function:

◆ bintime()

◆ bintime_add_tc_delta()

static __inline void bintime_add_tc_delta ( struct bintime bt,
uint64_t  scale,
uint64_t  large_delta,
uint64_t  delta 
)
static

Definition at line 217 of file kern_tc.c.

References bt.

Referenced by bintime_off(), and tc_windup().

Here is the caller graph for this function:

◆ bintime_off()

static __inline void bintime_off ( struct bintime bt,
u_int  off 
)
static

Definition at line 240 of file kern_tc.c.

References bintime(), bintime_add_tc_delta(), bt, tc_delta(), timehands::th_generation, timehands::th_large_delta, timehands::th_scale, and timehands.

Here is the call graph for this function:

◆ binuptime()

void binuptime ( struct bintime bt)

◆ cpu_tick_calibrate()

static void cpu_tick_calibrate ( int  reset)
static

Definition at line 2084 of file kern_tc.c.

References bintime(), bootverbose, cpu_tick_frequency, cpu_tick_variable, cpu_ticks, getbinuptime(), and printf().

Referenced by cpu_tick_calibration(), and tc_setclock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cpu_tick_calibration()

void cpu_tick_calibration ( void  )

Definition at line 2065 of file kern_tc.c.

References cpu_tick_calibrate(), and time_uptime.

Referenced by hardclock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cpu_tickrate()

uint64_t cpu_tickrate ( void  )

Definition at line 2144 of file kern_tc.c.

References cpu_tick_frequency, cpu_ticks, tc_cpu_ticks(), and tc_getfrequency().

Referenced by cputick2usec(), kern_clock_getres(), and lim_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cputick2usec()

uint64_t cputick2usec ( uint64_t  tick)

Definition at line 2163 of file kern_tc.c.

References cpu_tickrate(), and tick.

Referenced by boottrace_display(), calcru1(), cputick2timespec(), fill_kinfo_proc_only(), and fill_kinfo_thread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DPCPU_DEFINE_STATIC() [1/2]

DPCPU_DEFINE_STATIC ( uint64_t  ,
tc_cpu_ticks_base   
)

◆ DPCPU_DEFINE_STATIC() [2/2]

DPCPU_DEFINE_STATIC ( unsigned  ,
tc_cpu_ticks_last   
)

◆ dtrace_getnanotime()

void dtrace_getnanotime ( struct timespec *  tsp)

Definition at line 1013 of file kern_tc.c.

References GETTHMEMBER.

◆ dtrace_getnanouptime()

void dtrace_getnanouptime ( struct timespec *  tsp)

Definition at line 1025 of file kern_tc.c.

References bintime(), bt, and GETTHMEMBER.

Here is the call graph for this function:

◆ dummy_get_timecount()

static u_int dummy_get_timecount ( struct timecounter tc)
static

Definition at line 58 of file kern_tc.c.

◆ getbintime()

void getbintime ( struct bintime bt)

Definition at line 465 of file kern_tc.c.

References bt, and GETTHMEMBER.

◆ getbinuptime()

void getbinuptime ( struct bintime bt)

Definition at line 440 of file kern_tc.c.

References bt, and GETTHMEMBER.

Referenced by cpu_tick_calibrate(), and init_va_filerev().

Here is the caller graph for this function:

◆ getboottime()

void getboottime ( struct timeval *  boottime)

Definition at line 487 of file kern_tc.c.

References bintime(), and getboottimebin().

Referenced by acct_process(), fill_kinfo_proc_only(), procdesc_stat(), and sysctl_kern_boottime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getboottimebin()

void getboottimebin ( struct bintime boottimebin)

Definition at line 496 of file kern_tc.c.

References GETTHMEMBER.

Referenced by filt_timervalidate(), getboottime(), kqtimer_proc_continue(), sysclock_snap2bintime(), and umtx_abs_timeout_getsbt().

Here is the caller graph for this function:

◆ getmicrotime()

void getmicrotime ( struct timeval *  tvp)

Definition at line 479 of file kern_tc.c.

References GETTHMEMBER.

Referenced by ttydisc_read_raw_read_timer().

Here is the caller graph for this function:

◆ getmicrouptime()

void getmicrouptime ( struct timeval *  tvp)

Definition at line 456 of file kern_tc.c.

References bintime(), bt, and GETTHMEMBER.

Referenced by ratecheck(), and realitexpire().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getnanotime()

void getnanotime ( struct timespec *  tsp)

Definition at line 472 of file kern_tc.c.

References GETTHMEMBER.

Referenced by clock_dbgprint_hdr(), kern_clock_gettime(), kern_sem_wait(), mqueue_receive(), mqueue_send(), pipe_timestamp(), realtimer_clocktime(), resettodr(), settime_task_func(), and vfs_timestamp().

Here is the caller graph for this function:

◆ getnanouptime()

void getnanouptime ( struct timespec *  tsp)

Definition at line 447 of file kern_tc.c.

References bintime(), bt, and GETTHMEMBER.

Referenced by kern_clock_gettime(), kern_sigtimedwait(), print_uptime(), realtimer_clocktime(), and vn_generic_copy_file_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getthmember()

static __inline void getthmember ( void *  out,
size_t  out_size,
u_int  off 
)
static

Definition at line 269 of file kern_tc.c.

References timehands::th_generation, and timehands.

◆ inittimecounter()

static void inittimecounter ( void *  dummy)
static

Definition at line 1997 of file kern_tc.c.

References hz, printf(), tc_adjprecision(), tc_setclock_mtx, tc_tick, tc_tick_bt, tc_tick_sbt, tc_windup(), tick_bt, tick_sbt, and timecounter.

Here is the call graph for this function:

◆ inittimehands()

static void inittimehands ( void *  dummy)
static

Definition at line 1974 of file kern_tc.c.

References tc_from_tunable, tc_lock, timehands::th_next, ths, and timehands_count.

◆ microtime()

void microtime ( struct timeval *  tvp)

Definition at line 431 of file kern_tc.c.

References bintime(), and bt.

Referenced by settime(), sys_gettimeofday(), unp_internalize(), and vfs_timestamp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ microuptime()

void microuptime ( struct timeval *  tvp)

Definition at line 406 of file kern_tc.c.

References bintime(), binuptime(), and bt.

Referenced by acct_process(), do_fork(), hardclock_device_poll(), itimer_proc_continue(), kern_getitimer(), kern_setitimer(), netisr_poll(), netisr_pollmore(), proc0_post(), realitexpire(), and tty_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MTX_SYSINIT()

MTX_SYSINIT ( tc_setclock_init  ,
tc_setclock_mtx,
"tcsetc"  ,
MTX_SPIN   
)

◆ nanotime()

void nanotime ( struct timespec *  tsp)

Definition at line 422 of file kern_tc.c.

References bintime(), and bt.

Referenced by kern_clock_gettime(), ntp_gettime1(), tc_setclock(), unp_internalize(), and vfs_timestamp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nanouptime()

void nanouptime ( struct timespec *  tsp)

Definition at line 397 of file kern_tc.c.

References bintime(), binuptime(), and bt.

Referenced by kern_clock_gettime(), and unp_internalize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pps_capture()

void pps_capture ( struct pps_state *  pps)

Definition at line 1761 of file kern_tc.c.

References timehands::th_counter, timehands::th_generation, and timehands.

◆ pps_event()

void pps_event ( struct pps_state *  pps,
int  event 
)

Definition at line 1779 of file kern_tc.c.

References bintime(), bt, ts, and wakeup().

Here is the call graph for this function:

◆ pps_fetch()

static int pps_fetch ( struct pps_fetch_args *  fapi,
struct pps_state *  pps 
)
static

Definition at line 1592 of file kern_tc.c.

References abi_aware(), and tvtohz().

Referenced by pps_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pps_init()

void pps_init ( struct pps_state *  pps)

Definition at line 1736 of file kern_tc.c.

Referenced by pps_init_abi().

Here is the caller graph for this function:

◆ pps_init_abi()

void pps_init_abi ( struct pps_state *  pps)

Definition at line 1750 of file kern_tc.c.

References pps_init().

Here is the call graph for this function:

◆ pps_ioctl()

int pps_ioctl ( u_long  cmd,
caddr_t  data,
struct pps_state *  pps 
)

Definition at line 1650 of file kern_tc.c.

References data, and pps_fetch().

Here is the call graph for this function:

◆ recalculate_scaling_factor_and_large_delta()

static void recalculate_scaling_factor_and_large_delta ( struct timehands th)
static

Definition at line 1344 of file kern_tc.c.

References timehands::th_adjustment, timehands::th_counter, timehands::th_large_delta, and timehands::th_scale.

Referenced by tc_windup().

Here is the caller graph for this function:

◆ set_cputicker()

void set_cputicker ( cpu_tick_f *  func,
uint64_t  freq,
unsigned  var 
)

Definition at line 2131 of file kern_tc.c.

References cpu_tick_frequency, cpu_tick_variable, cpu_ticks, and tc_cpu_ticks().

Here is the call graph for this function:

◆ sleeping_on_old_rtc()

static bool sleeping_on_old_rtc ( struct thread *  td)
static

Definition at line 1265 of file kern_tc.c.

References rtc_generation.

Referenced by tc_setclock().

Here is the caller graph for this function:

◆ sysclock_getsnapshot()

void sysclock_getsnapshot ( struct sysclock_snap *  clock_snap,
int  fast 
)

Definition at line 1048 of file kern_tc.c.

References bintime(), bt, sysclock_active, tc_delta(), timehands::th_generation, timehands::th_offset, timehands::th_scale, time_esterror, time_status, and timehands.

Here is the call graph for this function:

◆ sysclock_snap2bintime()

int sysclock_snap2bintime ( struct sysclock_snap *  cs,
struct bintime bt,
int  whichclock,
uint32_t  flags 
)

Definition at line 1122 of file kern_tc.c.

References bintime(), bt, flags, and getboottimebin().

Here is the call graph for this function:

◆ sysctl_fast_gettime()

static int sysctl_fast_gettime ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2178 of file kern_tc.c.

References sysctl_handle_int(), and vdso_th_enable.

Here is the call graph for this function:

◆ SYSCTL_INT() [1/3]

SYSCTL_INT ( _kern_timecounter  ,
OID_AUTO  ,
stepwarnings  ,
CTLFLAG_RWTUN  ,
timestepwarnings,
,
"Log time steps"   
)

◆ SYSCTL_INT() [2/3]

SYSCTL_INT ( _kern_timecounter  ,
OID_AUTO  ,
tick  ,
CTLFLAG_RD  ,
tc_tick,
,
"Approximate number of hardclock ticks in a millisecond"   
)

◆ SYSCTL_INT() [3/3]

SYSCTL_INT ( _kern_timecounter  ,
OID_AUTO  ,
timehands_count  ,
CTLFLAG_RDTUN|  CTLFLAG_NOFETCH,
timehands_count,
,
"Count of timehands in rotation"   
)

◆ sysctl_kern_boottime()

static int sysctl_kern_boottime ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 161 of file kern_tc.c.

References getboottime().

Here is the call graph for this function:

◆ sysctl_kern_timecounter_adjprecision()

static int sysctl_kern_timecounter_adjprecision ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1956 of file kern_tc.c.

References sysctl_handle_int(), tc_adjprecision(), and tc_timepercentage.

Here is the call graph for this function:

◆ sysctl_kern_timecounter_choice()

static int sysctl_kern_timecounter_choice ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1549 of file kern_tc.c.

References sbuf_delete(), sbuf_finish(), sbuf_new_for_sysctl(), sbuf_printf(), sbuf_putc(), sysctl_wire_old_buffer(), tc_lock, timecounter, and timecounters.

Here is the call graph for this function:

◆ sysctl_kern_timecounter_freq()

static int sysctl_kern_timecounter_freq ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 193 of file kern_tc.c.

References sysctl_handle_64(), and timecounter.

Referenced by tc_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_kern_timecounter_get()

static int sysctl_kern_timecounter_get ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 183 of file kern_tc.c.

References sysctl_handle_int(), and timecounter.

Referenced by tc_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_kern_timecounter_hardware()

static int sysctl_kern_timecounter_hardware ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1498 of file kern_tc.c.

References sysctl_handle_string(), tc_chosen, tc_lock, timecounter, and timecounters.

Here is the call graph for this function:

◆ SYSCTL_NODE() [1/2]

SYSCTL_NODE ( _kern  ,
OID_AUTO  ,
timecounter  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
""   
)

◆ SYSCTL_NODE() [2/2]

static SYSCTL_NODE ( _kern_timecounter  ,
OID_AUTO  ,
tc  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
""   
)
static

◆ SYSCTL_PROC() [1/5]

SYSCTL_PROC ( _kern  ,
KERN_BOOTTIME  ,
boottime  ,
CTLTYPE_STRUCT|CTLFLAG_RD|  CTLFLAG_MPSAFE,
NULL  ,
,
sysctl_kern_boottime  ,
S,
timeval"  ,
"Estimated system boottime"   
)

◆ SYSCTL_PROC() [2/5]

SYSCTL_PROC ( _kern_timecounter  ,
OID_AUTO  ,
alloweddeviation  ,
CTLTYPE_INT|CTLFLAG_RWTUN|  CTLFLAG_MPSAFE,
,
,
sysctl_kern_timecounter_adjprecision  ,
"I"  ,
"Allowed time interval deviation in percents"   
)

◆ SYSCTL_PROC() [3/5]

SYSCTL_PROC ( _kern_timecounter  ,
OID_AUTO  ,
choice  ,
CTLTYPE_STRING|CTLFLAG_RD|  CTLFLAG_MPSAFE,
,
,
sysctl_kern_timecounter_choice  ,
"A"  ,
"Timecounter hardware detected"   
)

◆ SYSCTL_PROC() [4/5]

SYSCTL_PROC ( _kern_timecounter  ,
OID_AUTO  ,
fast_gettime  ,
CTLTYPE_INT|CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
,
sysctl_fast_gettime  ,
"I"  ,
"Enable fast time of day"   
)

◆ SYSCTL_PROC() [5/5]

SYSCTL_PROC ( _kern_timecounter  ,
OID_AUTO  ,
hardware  ,
CTLTYPE_STRING|CTLFLAG_RWTUN|CTLFLAG_NOFETCH|  CTLFLAG_MPSAFE,
,
,
sysctl_kern_timecounter_hardware  ,
"A"  ,
"Timecounter hardware selected"   
)

◆ SYSINIT() [1/2]

SYSINIT ( timecounter  ,
SI_SUB_CLOCKS  ,
SI_ORDER_SECOND  ,
inittimecounter  ,
NULL   
)

◆ SYSINIT() [2/2]

SYSINIT ( timehands  ,
SI_SUB_TUNABLES  ,
SI_ORDER_ANY  ,
inittimehands  ,
NULL   
)

◆ tc_adjprecision()

static void __inline tc_adjprecision ( void  )
static

Definition at line 1934 of file kern_tc.c.

References bt_tickthreshold, bt_timethreshold, hz, sbt_tickthreshold, sbt_timethreshold, tc_precexp, tc_tick, and tc_timepercentage.

Referenced by inittimecounter(), and sysctl_kern_timecounter_adjprecision().

Here is the caller graph for this function:

◆ tc_cpu_ticks()

static uint64_t tc_cpu_ticks ( void  )
static

Definition at line 2045 of file kern_tc.c.

References res, timehands::th_counter, and timecounter.

Referenced by cpu_tickrate(), and set_cputicker().

Here is the caller graph for this function:

◆ tc_delta()

static __inline u_int tc_delta ( struct timehands th)
static

Definition at line 207 of file kern_tc.c.

References timehands::th_counter, timehands::th_offset_count, and timecounter.

Referenced by bintime_off(), sysclock_getsnapshot(), and tc_windup().

Here is the caller graph for this function:

◆ tc_fill_vdso_timehands()

uint32_t tc_fill_vdso_timehands ( struct vdso_timehands *  vdso_th)

Definition at line 2194 of file kern_tc.c.

References timehands::th_boottime, timehands::th_counter, timehands::th_offset, timehands::th_offset_count, timehands::th_scale, timehands, and vdso_th_enable.

Referenced by timehands_update().

Here is the caller graph for this function:

◆ tc_getfrequency()

uint64_t tc_getfrequency ( void  )

Definition at line 1258 of file kern_tc.c.

References timehands::th_counter.

Referenced by cpu_tickrate(), and kern_clock_getres().

Here is the caller graph for this function:

◆ tc_init()

void tc_init ( struct timecounter tc)

Definition at line 1181 of file kern_tc.c.

References bootverbose, hz, printf(), sysctl_kern_timecounter_freq(), sysctl_kern_timecounter_get(), tc_chosen, tc_from_tunable, tc_lock, timecounter, and timecounters.

Here is the call graph for this function:

◆ tc_setclock()

void tc_setclock ( struct timespec *  ts)

Definition at line 1292 of file kern_tc.c.

References bintime(), binuptime(), bt, cpu_tick_calibrate(), log(), nanotime(), rtc_generation, sleeping_on_old_rtc(), sleepq_chains_remove_matching(), tc_setclock_mtx, tc_windup(), timestepwarnings, and ts.

Referenced by inittodr(), and settime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tc_ticktock()

void tc_ticktock ( int  cnt)

Definition at line 1919 of file kern_tc.c.

References count, tc_setclock_mtx, tc_tick, and tc_windup().

Referenced by hardclock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tc_windup()

Variable Documentation

◆ bt_tickthreshold

struct bintime bt_tickthreshold

Definition at line 136 of file kern_tc.c.

Referenced by tc_adjprecision().

◆ bt_timethreshold

struct bintime bt_timethreshold

Definition at line 135 of file kern_tc.c.

Referenced by tc_adjprecision().

◆ cpu_tick_frequency

uint64_t cpu_tick_frequency
static

Definition at line 2039 of file kern_tc.c.

Referenced by cpu_tick_calibrate(), cpu_tickrate(), and set_cputicker().

◆ cpu_tick_variable

int cpu_tick_variable
static

Definition at line 2038 of file kern_tc.c.

Referenced by cpu_tick_calibrate(), and set_cputicker().

◆ cpu_ticks

◆ dummy_timecounter

struct timecounter dummy_timecounter
static
Initial value:
= {
dummy_get_timecount, 0, ~0u, 1000000, "dummy", -1000000
}
static u_int dummy_get_timecount(struct timecounter *tc)
Definition: kern_tc.c:58

Definition at line 65 of file kern_tc.c.

◆ rtc_generation

volatile int rtc_generation = 1

◆ sbt_tickthreshold

sbintime_t sbt_tickthreshold

Definition at line 138 of file kern_tc.c.

Referenced by callout_when(), and tc_adjprecision().

◆ sbt_timethreshold

sbintime_t sbt_timethreshold

Definition at line 137 of file kern_tc.c.

Referenced by realitexpire(), and tc_adjprecision().

◆ sysclock_active

int sysclock_active = SYSCLOCK_FBCK

Definition at line 1037 of file kern_tc.c.

Referenced by sysclock_getsnapshot(), and tc_windup().

◆ tc_chosen

int tc_chosen
static

Definition at line 151 of file kern_tc.c.

Referenced by sysctl_kern_timecounter_hardware(), and tc_init().

◆ tc_from_tunable

char tc_from_tunable[16]
static

Definition at line 152 of file kern_tc.c.

Referenced by inittimehands(), and tc_init().

◆ tc_lock

struct mtx tc_lock
static

◆ tc_min_ticktock_freq

int tc_min_ticktock_freq = 1

Definition at line 103 of file kern_tc.c.

Referenced by getnextcpuevent(), and tc_windup().

◆ tc_precexp

◆ tc_setclock_mtx

struct mtx tc_setclock_mtx
static

Definition at line 1284 of file kern_tc.c.

Referenced by inittimecounter(), tc_setclock(), and tc_ticktock().

◆ tc_tick

int tc_tick
static

Definition at line 1914 of file kern_tc.c.

Referenced by inittimecounter(), tc_adjprecision(), and tc_ticktock().

◆ tc_tick_bt

struct bintime tc_tick_bt

Definition at line 139 of file kern_tc.c.

Referenced by inittimecounter().

◆ tc_tick_sbt

sbintime_t tc_tick_sbt

◆ tc_timepercentage

int tc_timepercentage = TC_DEFAULTPERC

Definition at line 142 of file kern_tc.c.

Referenced by sysctl_kern_timecounter_adjprecision(), and tc_adjprecision().

◆ ths

struct timehands ths[16]
static
Initial value:
= {
[0] = {
.th_counter = &dummy_timecounter,
.th_scale = (uint64_t)-1 / 1000000,
.th_large_delta = 1000000,
.th_offset = { .sec = 1 },
.th_generation = 1,
},
}
static struct timecounter dummy_timecounter
Definition: kern_tc.c:65

Definition at line 86 of file kern_tc.c.

Referenced by inittimehands().

◆ time_esterror

long time_esterror
extern

Definition at line 157 of file kern_ntptime.c.

Referenced by kern_ntp_adjtime(), ntp_gettime1(), and sysclock_getsnapshot().

◆ time_second

◆ time_status

◆ time_uptime

volatile time_t time_uptime = 1

Definition at line 106 of file kern_tc.c.

Referenced by cpu_tick_calibration(), hardupdate(), msgbuf_addstr(), sched_sync(), and tc_windup().

◆ timecounter

◆ timecounters

struct timecounter* timecounters = &dummy_timecounter
static

◆ timehands

struct timehands* volatile timehands = &ths[0]
static

◆ timehands_count

int timehands_count = 2
static

Definition at line 130 of file kern_tc.c.

Referenced by inittimehands().

◆ timestepwarnings

int timestepwarnings
static

Definition at line 126 of file kern_tc.c.

Referenced by tc_setclock().

◆ vdso_th_enable

int vdso_th_enable = 1
static

Definition at line 2176 of file kern_tc.c.

Referenced by sysctl_fast_gettime(), and tc_fill_vdso_timehands().