|
FreeBSD kernel kern code
|
#include <sys/cdefs.h>#include "opt_compat.h"#include "opt_ntp.h"#include <sys/param.h>#include <sys/kernel.h>#include <sys/sysctl.h>#include <sys/syslog.h>#include <sys/systm.h>#include <sys/timepps.h>#include <sys/timetc.h>#include <sys/timex.h>#include <sys/vdso.h>
Go to the source code of this file.
Data Structures | |
| struct | timehands |
Macros | |
| #define | LARGE_STEP 200 |
Functions | |
| __FBSDID ("$BSDSUniX$") | |
| 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, NULL, 0, sysctl_kern_boottime,"S,timeval","System boottime") | |
| SYSCTL_NODE (_kern, OID_AUTO, timecounter, CTLFLAG_RW, 0,"") | |
| static | SYSCTL_NODE (_kern_timecounter, OID_AUTO, tc, CTLFLAG_RW, 0,"") |
| SYSCTL_INT (_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RW,×tepwarnings, 0,"Log time steps") | |
| static void | tc_windup (void) |
| static void | cpu_tick_calibrate (int) |
| void | dtrace_getnanotime (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) |
| 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 | tc_init (struct timecounter *tc) |
| uint64_t | tc_getfrequency (void) |
| void | tc_setclock (struct timespec *ts) |
| static int | sysctl_kern_timecounter_hardware (SYSCTL_HANDLER_ARGS) |
| SYSCTL_PROC (_kern_timecounter, OID_AUTO, hardware, CTLTYPE_STRING|CTLFLAG_RW, 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, 0, 0, sysctl_kern_timecounter_choice,"A","Timecounter hardware detected") | |
| int | pps_ioctl (u_long cmd, caddr_t data, struct pps_state *pps) |
| void | pps_init (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 | inittimecounter (void *dummy) |
| SYSINIT (timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL) | |
| 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 | th0 |
| static struct timehands | th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0} |
| static struct timehands | th8 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th9} |
| static struct timehands | th7 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th8} |
| static struct timehands | th6 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th7} |
| static struct timehands | th5 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th6} |
| static struct timehands | th4 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th5} |
| static struct timehands | th3 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th4} |
| static struct timehands | th2 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th3} |
| static struct timehands | th1 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th2} |
| static struct timehands *volatile | timehands = &th0 |
| struct timecounter * | timecounter = &dummy_timecounter |
| static struct timecounter * | timecounters = &dummy_timecounter |
| int | tc_min_ticktock_freq = 1 |
| volatile time_t | time_second = 1 |
| volatile time_t | time_uptime = 1 |
| struct bintime | boottimebin |
| struct timeval | boottime |
| static int | timestepwarnings |
| 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 |
| #define LARGE_STEP 200 |
Definition at line 32 of file kern_tc.c.
Referenced by tc_windup().
| __FBSDID | ( | "$BSDSUniX$" | ) |
| void bintime | ( | struct bintime * | bt | ) |
Definition at line 203 of file kern_tc.c.
References binuptime(), and boottimebin.
Referenced by configtimer(), cpu_activeclock(), cpu_idleclock(), cpu_initclocks_ap(), cpu_tick_calibrate(), devstat_end_transaction(), doconfigtimer(), getnextcpuevent(), handleevents(), hardclockintr(), init_va_filerev(), loadtimer(), microtime(), microuptime(), nanotime(), nanouptime(), pps_event(), softclock_call_cc(), tc_setclock(), tc_windup(), timercb(), unp_internalize(), and uuid_time().


| void binuptime | ( | struct bintime * | bt | ) |
Definition at line 171 of file kern_tc.c.
References tc_delta(), timehands::th_generation, timehands::th_offset, timehands::th_scale, and timehands.
Referenced by bintime(), configtimer(), cpu_activeclock(), cpu_idleclock(), cpu_initclocks_ap(), devstat_add_entry(), devstat_end_transaction(), devstat_new_entry(), devstat_start_transaction(), devstat_start_transaction_bio(), doconfigtimer(), microuptime(), nanouptime(), softclock_call_cc(), tc_setclock(), and timercb().


|
static |
Definition at line 896 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().


| void cpu_tick_calibration | ( | void | ) |
Definition at line 877 of file kern_tc.c.
References cpu_tick_calibrate(), and time_uptime.
Referenced by hardclock(), and hardclock_cnt().


| uint64_t cpu_tickrate | ( | void | ) |
Definition at line 956 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().


| uint64_t cputick2usec | ( | uint64_t | tick | ) |
Definition at line 975 of file kern_tc.c.
References cpu_tickrate().
Referenced by calcru1(), cputick2timespec(), fill_kinfo_proc_only(), and fill_kinfo_thread().


| void dtrace_getnanotime | ( | struct timespec * | tsp | ) |
Definition at line 313 of file kern_tc.c.
References timehands::th_generation, timehands::th_nanotime, and timehands.
|
static |
| void getbintime | ( | struct bintime * | bt | ) |
Definition at line 268 of file kern_tc.c.
References boottimebin, timehands::th_generation, timehands::th_offset, and timehands.
| void getbinuptime | ( | struct bintime * | bt | ) |
Definition at line 229 of file kern_tc.c.
References timehands::th_generation, timehands::th_offset, and timehands.
Referenced by cpu_tick_calibrate(), and init_va_filerev().

| void getmicrotime | ( | struct timeval * | tvp | ) |
Definition at line 295 of file kern_tc.c.
References timehands::th_generation, timehands::th_microtime, and timehands.
Referenced by ttydisc_read_raw_read_timer().

| void getmicrouptime | ( | struct timeval * | tvp | ) |
Definition at line 255 of file kern_tc.c.
References timehands::th_generation, timehands::th_offset, and timehands.
Referenced by kern_getitimer(), kern_select(), kern_setitimer(), kqueue_scan(), ratecheck(), realitexpire(), selsocket(), and sys_poll().

| void getnanotime | ( | struct timespec * | tsp | ) |
Definition at line 282 of file kern_tc.c.
References timehands::th_generation, timehands::th_nanotime, and timehands.
Referenced by kern_clock_gettime(), kern_sem_wait(), mqueue_receive(), mqueue_send(), realtimer_clocktime(), resettodr(), and vfs_timestamp().

| void getnanouptime | ( | struct timespec * | tsp | ) |
Definition at line 242 of file kern_tc.c.
References timehands::th_generation, timehands::th_offset, and timehands.
Referenced by do_lock_umtx(), do_lock_umutex(), do_rw_rdlock2(), do_rw_wrlock2(), do_sem_wait(), do_wait(), kern_clock_gettime(), kern_nanosleep(), kern_sigtimedwait(), print_uptime(), and realtimer_clocktime().

|
static |
Definition at line 828 of file kern_tc.c.
References hz, printf(), tc_tick, tc_windup(), and timecounter.

| void microtime | ( | struct timeval * | tvp | ) |
Definition at line 220 of file kern_tc.c.
References bintime().
Referenced by settime(), sys_gettimeofday(), unp_internalize(), and vfs_timestamp().


| void microuptime | ( | struct timeval * | tvp | ) |
Definition at line 194 of file kern_tc.c.
References bintime(), and binuptime().
Referenced by acct_process(), do_fork(), hardclock_device_poll(), netisr_poll(), netisr_pollmore(), proc0_post(), and tty_info().


| void nanotime | ( | struct timespec * | tsp | ) |
Definition at line 211 of file kern_tc.c.
References bintime().
Referenced by kern_clock_gettime(), ntp_gettime1(), proc0_post(), tc_setclock(), and vfs_timestamp().


| void nanouptime | ( | struct timespec * | tsp | ) |
Definition at line 185 of file kern_tc.c.
References bintime(), and binuptime().
Referenced by kern_clock_gettime().


| void pps_capture | ( | struct pps_state * | pps | ) |
Definition at line 702 of file kern_tc.c.
References timehands::th_counter, timehands::th_generation, and timehands.
| void pps_event | ( | struct pps_state * | pps, |
| int | event | ||
| ) |
Definition at line 716 of file kern_tc.c.
References bintime(), boottimebin, and ts.

| int pps_ioctl | ( | u_long | cmd, |
| caddr_t | data, | ||
| struct pps_state * | pps | ||
| ) |
| void set_cputicker | ( | cpu_tick_f * | func, |
| uint64_t | freq, | ||
| unsigned | var | ||
| ) |
Definition at line 943 of file kern_tc.c.
References cpu_tick_frequency, cpu_tick_variable, cpu_ticks, and tc_cpu_ticks().

|
static |
Definition at line 990 of file kern_tc.c.
References sysctl_handle_int(), timekeep_push_vdso(), and vdso_th_enable.

| SYSCTL_INT | ( | _kern_timecounter | , |
| OID_AUTO | , | ||
| stepwarnings | , | ||
| CTLFLAG_RW | , | ||
| & | timestepwarnings, | ||
| 0 | , | ||
| "Log time steps" | |||
| ) |
| SYSCTL_INT | ( | _kern_timecounter | , |
| OID_AUTO | , | ||
| tick | , | ||
| CTLFLAG_RD | , | ||
| & | tc_tick, | ||
| 0 | , | ||
| "Approximate number of hardclock ticks in a millisecond" | |||
| ) |
|
static |
|
static |
Definition at line 609 of file kern_tc.c.
References buf, sprintf(), timecounter, and timecounters.

|
static |
Definition at line 141 of file kern_tc.c.
References sysctl_handle_64(), and timecounter.
Referenced by tc_init().


|
static |
Definition at line 131 of file kern_tc.c.
References sysctl_handle_int(), and timecounter.
Referenced by tc_init().


|
static |
Definition at line 574 of file kern_tc.c.
References sysctl_handle_string(), timecounter, timecounters, and timekeep_push_vdso().

| SYSCTL_NODE | ( | _kern | , |
| OID_AUTO | , | ||
| timecounter | , | ||
| CTLFLAG_RW | , | ||
| 0 | , | ||
| "" | |||
| ) |
|
static |
| SYSCTL_PROC | ( | _kern | , |
| KERN_BOOTTIME | , | ||
| boottime | , | ||
| CTLTYPE_STRUCT| | CTLFLAG_RD, | ||
| NULL | , | ||
| 0 | , | ||
| sysctl_kern_boottime | , | ||
| " | S, | ||
| timeval" | , | ||
| "System boottime" | |||
| ) |
| SYSCTL_PROC | ( | _kern_timecounter | , |
| OID_AUTO | , | ||
| hardware | , | ||
| CTLTYPE_STRING| | CTLFLAG_RW, | ||
| 0 | , | ||
| 0 | , | ||
| sysctl_kern_timecounter_hardware | , | ||
| "A" | , | ||
| "Timecounter hardware selected" | |||
| ) |
| SYSCTL_PROC | ( | _kern_timecounter | , |
| OID_AUTO | , | ||
| choice | , | ||
| CTLTYPE_STRING| | CTLFLAG_RD, | ||
| 0 | , | ||
| 0 | , | ||
| sysctl_kern_timecounter_choice | , | ||
| "A" | , | ||
| "Timecounter hardware detected" | |||
| ) |
| 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" | |||
| ) |
| SYSINIT | ( | timecounter | , |
| SI_SUB_CLOCKS | , | ||
| SI_ORDER_SECOND | , | ||
| inittimecounter | , | ||
| NULL | |||
| ) |
|
static |
Definition at line 861 of file kern_tc.c.
References timehands::th_counter, and timecounter.
Referenced by cpu_tickrate(), and set_cputicker().

|
static |
Definition at line 155 of file kern_tc.c.
References timehands::th_counter, timehands::th_offset_count, and timecounter.
Referenced by binuptime(), and tc_windup().

| uint32_t tc_fill_vdso_timehands | ( | struct vdso_timehands * | vdso_th | ) |
Definition at line 1007 of file kern_tc.c.
References boottimebin, cpu_fill_vdso_timehands(), timehands::th_counter, timehands::th_offset, timehands::th_offset_count, timehands::th_scale, timehands, and vdso_th_enable.
Referenced by timehands_update().


| uint64_t tc_getfrequency | ( | void | ) |
Definition at line 390 of file kern_tc.c.
References timehands::th_counter.
Referenced by cpu_tickrate(), and kern_clock_getres().

| void tc_init | ( | struct timecounter * | tc | ) |
Definition at line 329 of file kern_tc.c.
References bootverbose, hz, printf(), sysctl_kern_timecounter_freq(), sysctl_kern_timecounter_get(), timecounter, and timecounters.

| void tc_setclock | ( | struct timespec * | ts | ) |
Definition at line 402 of file kern_tc.c.
References bintime(), binuptime(), boottime, boottimebin, cpu_tick_calibrate(), log(), nanotime(), tc_windup(), and timestepwarnings.
Referenced by inittodr(), and settime().


| void tc_ticktock | ( | int | cnt | ) |
Definition at line 816 of file kern_tc.c.
References count, tc_tick, and tc_windup().
Referenced by hardclock(), and hardclock_cnt().


|
static |
Definition at line 435 of file kern_tc.c.
References bintime(), boottimebin, cpu_disable_c2_sleep, LARGE_STEP, ntp_update_second(), tc_delta(), tc_min_ticktock_freq, timehands::th_adjustment, timehands::th_counter, timehands::th_generation, timehands::th_microtime, timehands::th_nanotime, timehands::th_next, timehands::th_offset, timehands::th_offset_count, timehands::th_scale, time_second, time_uptime, timecounter, timehands, and timekeep_push_vdso().
Referenced by inittimecounter(), tc_setclock(), and tc_ticktock().


| struct timeval boottime |
Definition at line 98 of file kern_tc.c.
Referenced by acct_process(), fill_kinfo_proc_only(), sysctl_kern_boottime(), and tc_setclock().
| struct bintime boottimebin |
Definition at line 97 of file kern_tc.c.
Referenced by bintime(), getbintime(), pps_event(), tc_fill_vdso_timehands(), tc_setclock(), and tc_windup().
|
static |
Definition at line 858 of file kern_tc.c.
Referenced by cpu_tick_calibrate(), cpu_tickrate(), and set_cputicker().
|
static |
Definition at line 857 of file kern_tc.c.
Referenced by cpu_tick_calibrate(), and set_cputicker().
| cpu_tick_f* cpu_ticks = tc_cpu_ticks |
Definition at line 986 of file kern_tc.c.
Referenced by calcru(), cpu_tick_calibrate(), cpu_tickrate(), get_thread_cputime(), mi_switch(), proc0_post(), rufetchtd(), sched_throw(), set_cputicker(), and thread_exit().
|
static |
| int tc_min_ticktock_freq = 1 |
Definition at line 92 of file kern_tc.c.
Referenced by getnextcpuevent(), and tc_windup().
|
static |
Definition at line 811 of file kern_tc.c.
Referenced by inittimecounter(), and tc_ticktock().
|
static |
| volatile time_t time_second = 1 |
Definition at line 94 of file kern_tc.c.
Referenced by hardupdate(), kern_clock_gettime(), kern_msgctl(), kern_msgrcv(), kern_msgsnd(), kern_semctl(), kern_shmat(), kern_shmctl(), mkdumpheader(), shm_delete_mapping(), shmget_allocate_segment(), sys_msgget(), sys_semget(), sys_semop(), tc_windup(), and vfs_timestamp().
| volatile time_t time_uptime = 1 |
Definition at line 95 of file kern_tc.c.
Referenced by cpu_tick_calibration(), malloc(), malloc_last_fail(), msgbuf_addstr(), sched_sync(), and tc_windup().
| struct timecounter* timecounter = &dummy_timecounter |
Definition at line 89 of file kern_tc.c.
Referenced by inittimecounter(), sysctl_kern_timecounter_choice(), sysctl_kern_timecounter_freq(), sysctl_kern_timecounter_get(), sysctl_kern_timecounter_hardware(), tc_cpu_ticks(), tc_delta(), tc_init(), and tc_windup().
|
static |
Definition at line 90 of file kern_tc.c.
Referenced by sysctl_kern_timecounter_choice(), sysctl_kern_timecounter_hardware(), and tc_init().
Definition at line 88 of file kern_tc.c.
Referenced by binuptime(), dtrace_getnanotime(), getbintime(), getbinuptime(), getmicrotime(), getmicrouptime(), getnanotime(), getnanouptime(), pps_capture(), tc_fill_vdso_timehands(), and tc_windup().
|
static |
Definition at line 106 of file kern_tc.c.
Referenced by tc_setclock().
|
static |
Definition at line 988 of file kern_tc.c.
Referenced by sysctl_fast_gettime(), and tc_fill_vdso_timehands().