FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_kdtrace.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/callout.h>
#include <sys/condvar.h>
#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sdt.h>
#include <sys/sleepqueue.h>
#include <sys/sysctl.h>
#include <sys/smp.h>
Go to the source code of this file.
Data Structures | |
struct | cc_mig_ent |
struct | callout_cpu |
Macros | |
#define | CC_CPU(cpu) &cc_cpu |
#define | CC_SELF() &cc_cpu |
#define | CC_LOCK(cc) mtx_lock_spin(&(cc)->cc_lock) |
#define | CC_UNLOCK(cc) mtx_unlock_spin(&(cc)->cc_lock) |
#define | CC_LOCK_ASSERT(cc) mtx_assert(&(cc)->cc_lock, MA_OWNED) |
#define | MAX_SOFTCLOCK_STEPS 100 /* Maximum allowed value of steps. */ |
Functions | |
__FBSDID ("$BSDSUniX$") | |
SDT_PROVIDER_DEFINE (callout_execute) | |
SDT_PROBE_DEFINE1 (callout_execute, kernel,, callout__start,"struct callout *") | |
SDT_PROBE_DEFINE1 (callout_execute, kernel,, callout__end,"struct callout *") | |
SYSCTL_INT (_debug, OID_AUTO, to_avg_depth, CTLFLAG_RD,&avg_depth, 0,"Average number of items examined per softclock call. Units = 1/1000") | |
SYSCTL_INT (_debug, OID_AUTO, to_avg_gcalls, CTLFLAG_RD,&avg_gcalls, 0,"Average number of Giant callouts made per softclock call. Units = 1/1000") | |
SYSCTL_INT (_debug, OID_AUTO, to_avg_lockcalls, CTLFLAG_RD,&avg_lockcalls, 0,"Average number of lock callouts made per softclock call. Units = 1/1000") | |
SYSCTL_INT (_debug, OID_AUTO, to_avg_mpcalls, CTLFLAG_RD,&avg_mpcalls, 0,"Average number of MP callouts made per softclock call. Units = 1/1000") | |
static | MALLOC_DEFINE (M_CALLOUT,"callout","Callout datastructures") |
static void | cc_cme_cleanup (struct callout_cpu *cc) |
static int | cc_cme_migrating (struct callout_cpu *cc) |
caddr_t | kern_timeout_callwheel_alloc (caddr_t v) |
static void | callout_cpu_init (struct callout_cpu *cc) |
void | kern_timeout_callwheel_init (void) |
static void | start_softclock (void *dummy) |
SYSINIT (start_softclock, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softclock, NULL) | |
void | callout_tick (void) |
int | callout_tickstofirst (int limit) |
static struct callout_cpu * | callout_lock (struct callout *c) |
static void | callout_cc_add (struct callout *c, struct callout_cpu *cc, int to_ticks, void(*func)(void *), void *arg, int cpu) |
static void | callout_cc_del (struct callout *c, struct callout_cpu *cc) |
static void | softclock_call_cc (struct callout *c, struct callout_cpu *cc, int *mpcalls, int *lockcalls, int *gcalls) |
void | softclock (void *arg) |
struct callout_handle | timeout (timeout_t *ftn, void *arg, int to_ticks) |
void | untimeout (timeout_t *ftn, void *arg, struct callout_handle handle) |
void | callout_handle_init (struct callout_handle *handle) |
int | callout_reset_on (struct callout *c, int to_ticks, void(*ftn)(void *), void *arg, int cpu) |
int | callout_schedule_on (struct callout *c, int to_ticks, int cpu) |
int | callout_schedule (struct callout *c, int to_ticks) |
int | _callout_stop_safe (struct callout *c, int safe) |
void | callout_init (struct callout *c, int mpsafe) |
void | _callout_init_lock (struct callout *c, struct lock_object *lock, int flags) |
Variables | |
static int | avg_depth |
static int | avg_gcalls |
static int | avg_lockcalls |
static int | avg_mpcalls |
int | callwheelsize |
int | callwheelbits |
int | callwheelmask |
struct callout_cpu | cc_cpu |
static int | timeout_cpu |
void(* | callout_new_inserted )(int cpu, int ticks) = NULL |
#define CC_CPU | ( | cpu | ) | &cc_cpu |
Definition at line 147 of file kern_timeout.c.
Referenced by callout_lock(), kern_timeout_callwheel_alloc(), kern_timeout_callwheel_init(), start_softclock(), and timeout().
#define CC_LOCK | ( | cc | ) | mtx_lock_spin(&(cc)->cc_lock) |
Definition at line 150 of file kern_timeout.c.
Referenced by _callout_stop_safe(), callout_lock(), softclock(), softclock_call_cc(), and timeout().
#define CC_LOCK_ASSERT | ( | cc | ) | mtx_assert(&(cc)->cc_lock, MA_OWNED) |
Definition at line 152 of file kern_timeout.c.
Referenced by callout_cc_add().
#define CC_SELF | ( | ) | &cc_cpu |
Definition at line 148 of file kern_timeout.c.
Referenced by callout_tick(), and callout_tickstofirst().
#define CC_UNLOCK | ( | cc | ) | mtx_unlock_spin(&(cc)->cc_lock) |
Definition at line 151 of file kern_timeout.c.
Referenced by _callout_stop_safe(), callout_lock(), callout_reset_on(), softclock(), softclock_call_cc(), timeout(), and untimeout().
#define MAX_SOFTCLOCK_STEPS 100 /* Maximum allowed value of steps. */ |
Referenced by softclock().
__FBSDID | ( | "$BSDSUniX$" | ) |
void _callout_init_lock | ( | struct callout * | c, |
struct lock_object * | lock, | ||
int | flags | ||
) |
Definition at line 1056 of file kern_timeout.c.
References timeout_cpu.
int _callout_stop_safe | ( | struct callout * | c, |
int | safe | ||
) |
Definition at line 873 of file kern_timeout.c.
References callout_cc_del(), callout_lock(), callwheelmask, callout_cpu::cc_callwheel, callout_cpu::cc_cancel, cc_cme_migrating(), callout_cpu::cc_curr, CC_LOCK, callout_cpu::cc_lock, callout_cpu::cc_next, CC_UNLOCK, callout_cpu::cc_waiting, Giant, panic(), sleepq_add(), sleepq_lock(), sleepq_release(), and sleepq_wait().
|
static |
Definition at line 416 of file kern_timeout.c.
References callout_new_inserted, callwheelmask, callout_cpu::cc_callwheel, callout_cpu::cc_firsttick, CC_LOCK_ASSERT, callout_cpu::cc_ticks, and ticks.
Referenced by callout_reset_on(), and softclock_call_cc().
|
static |
Definition at line 439 of file kern_timeout.c.
References callout_cpu::cc_callfree.
Referenced by _callout_stop_safe(), and softclock_call_cc().
|
static |
Definition at line 235 of file kern_timeout.c.
References callout_init(), callwheelsize, callout_cpu::cc_callfree, callout_cpu::cc_callout, callout_cpu::cc_callwheel, cc_cme_cleanup(), callout_cpu::cc_lock, mtx_init(), and ncallout.
Referenced by kern_timeout_callwheel_init(), and start_softclock().
void callout_handle_init | ( | struct callout_handle * | handle | ) |
Definition at line 760 of file kern_timeout.c.
void callout_init | ( | struct callout * | c, |
int | mpsafe | ||
) |
Definition at line 1040 of file kern_timeout.c.
References Giant, and timeout_cpu.
Referenced by callout_cpu_init(), constty_set(), domaininit(), filt_timerattach(), proc0_init(), start_periodic_resettodr(), synch_setup(), and thread_link().
|
static |
Definition at line 392 of file kern_timeout.c.
References CC_CPU, CC_LOCK, and CC_UNLOCK.
Referenced by _callout_stop_safe(), callout_reset_on(), and untimeout().
int callout_reset_on | ( | struct callout * | c, |
int | to_ticks, | ||
void(*)(void *) | ftn, | ||
void * | arg, | ||
int | cpu | ||
) |
Definition at line 782 of file kern_timeout.c.
References callout_cc_add(), callout_lock(), callwheelmask, callout_cpu::cc_callwheel, callout_cpu::cc_cancel, callout_cpu::cc_curr, callout_cpu::cc_next, CC_UNLOCK, and callout_cpu::cc_waiting.
Referenced by callout_schedule(), and callout_schedule_on().
int callout_schedule | ( | struct callout * | c, |
int | to_ticks | ||
) |
Definition at line 867 of file kern_timeout.c.
References callout_reset_on().
Referenced by logtimeout(), and periodic_resettodr().
int callout_schedule_on | ( | struct callout * | c, |
int | to_ticks, | ||
int | cpu | ||
) |
Definition at line 861 of file kern_timeout.c.
References callout_reset_on().
void callout_tick | ( | void | ) |
Definition at line 334 of file kern_timeout.c.
References callwheelmask, callout_cpu::cc_callwheel, callout_cpu::cc_cookie, callout_cpu::cc_firsttick, callout_cpu::cc_lock, CC_SELF, callout_cpu::cc_softticks, callout_cpu::cc_ticks, swi_sched(), and ticks.
Referenced by hardclock_cnt(), and hardclock_cpu().
int callout_tickstofirst | ( | int | limit | ) |
Definition at line 365 of file kern_timeout.c.
References callwheelmask, callout_cpu::cc_callwheel, callout_cpu::cc_firsttick, callout_cpu::cc_lock, CC_SELF, callout_cpu::cc_ticks, and ncallout.
Referenced by getnextcpuevent().
|
static |
Locked by cc_lock: cc_curr - If a callout is in progress, it is curr_callout. If curr_callout is non-NULL, threads waiting in callout_drain() will be woken up as soon as the relevant callout completes. cc_cancel - Changing to 1 with both callout_lock and c_lock held guarantees that the current callout will not run. The softclock() function sets this to 0 before it drops callout_lock to acquire c_lock, and it calls the handler only if curr_cancelled is still 0 after c_lock is successfully acquired. cc_waiting - If a thread is waiting in callout_drain(), then callout_wait is nonzero. Set only when curr_callout is non-NULL.
Definition at line 180 of file kern_timeout.c.
Referenced by callout_cpu_init(), and softclock_call_cc().
|
static |
Definition at line 195 of file kern_timeout.c.
Referenced by _callout_stop_safe(), and softclock_call_cc().
caddr_t kern_timeout_callwheel_alloc | ( | caddr_t | v | ) |
Definition at line 212 of file kern_timeout.c.
References callwheelbits, callwheelmask, callwheelsize, callout_cpu::cc_callout, callout_cpu::cc_callwheel, CC_CPU, ncallout, and timeout_cpu.
void kern_timeout_callwheel_init | ( | void | ) |
Definition at line 294 of file kern_timeout.c.
References callout_cpu_init(), CC_CPU, and timeout_cpu.
|
static |
SDT_PROBE_DEFINE1 | ( | callout_execute | , |
kernel | , | ||
callout__start | , | ||
"struct callout *" | |||
) |
SDT_PROBE_DEFINE1 | ( | callout_execute | , |
kernel | , | ||
callout__end | , | ||
"struct callout *" | |||
) |
SDT_PROVIDER_DEFINE | ( | callout_execute | ) |
void softclock | ( | void * | arg | ) |
Definition at line 632 of file kern_timeout.c.
References avg_depth, avg_gcalls, avg_lockcalls, avg_mpcalls, callwheelmask, callout_cpu::cc_callwheel, CC_LOCK, callout_cpu::cc_next, callout_cpu::cc_softticks, callout_cpu::cc_ticks, CC_UNLOCK, MAX_SOFTCLOCK_STEPS, and softclock_call_cc().
Referenced by start_softclock().
|
static |
Definition at line 449 of file kern_timeout.c.
References bintime(), binuptime(), callout_cc_add(), callout_cc_del(), callout_cpu::cc_cancel, cc_cme_cleanup(), cc_cme_migrating(), callout_cpu::cc_curr, CC_LOCK, CC_UNLOCK, callout_cpu::cc_waiting, Giant, panic(), printf(), and wakeup().
Referenced by softclock().
|
static |
Definition at line 303 of file kern_timeout.c.
References callout_cpu_init(), callwheelsize, callout_cpu::cc_callout, callout_cpu::cc_callwheel, callout_cpu::cc_cookie, CC_CPU, clk_intr_event, malloc(), panic(), softclock(), swi_add(), and timeout_cpu.
SYSCTL_INT | ( | _debug | , |
OID_AUTO | , | ||
to_avg_depth | , | ||
CTLFLAG_RD | , | ||
& | avg_depth, | ||
0 | |||
) |
SYSCTL_INT | ( | _debug | , |
OID_AUTO | , | ||
to_avg_gcalls | , | ||
CTLFLAG_RD | , | ||
& | avg_gcalls, | ||
0 | |||
) |
SYSCTL_INT | ( | _debug | , |
OID_AUTO | , | ||
to_avg_lockcalls | , | ||
CTLFLAG_RD | , | ||
& | avg_lockcalls, | ||
0 | |||
) |
SYSCTL_INT | ( | _debug | , |
OID_AUTO | , | ||
to_avg_mpcalls | , | ||
CTLFLAG_RD | , | ||
& | avg_mpcalls, | ||
0 | |||
) |
SYSINIT | ( | start_softclock | , |
SI_SUB_SOFTINTR | , | ||
SI_ORDER_FIRST | , | ||
start_softclock | , | ||
NULL | |||
) |
struct callout_handle timeout | ( | timeout_t * | ftn, |
void * | arg, | ||
int | to_ticks | ||
) |
Definition at line 713 of file kern_timeout.c.
References CC_CPU, CC_LOCK, CC_UNLOCK, panic(), and timeout_cpu.
Referenced by __umtx_op_cv_wait(), __umtx_op_lock_umtx(), __umtx_op_lock_umutex(), __umtx_op_sem_wait(), __umtx_op_wait(), __umtx_op_wait_uint(), __umtx_op_wait_uint_private(), __umtx_op_wait_umutex(), do_cv_wait(), fail_point_sleep(), kqueue_scan(), parse_mount(), sys_sigtimedwait(), and sysctl_register_oid().
void untimeout | ( | timeout_t * | ftn, |
void * | arg, | ||
struct callout_handle | handle | ||
) |
Definition at line 738 of file kern_timeout.c.
References callout_lock(), and CC_UNLOCK.
|
static |
Definition at line 69 of file kern_timeout.c.
Referenced by softclock().
|
static |
Definition at line 72 of file kern_timeout.c.
Referenced by softclock().
|
static |
Definition at line 75 of file kern_timeout.c.
Referenced by softclock().
|
static |
Definition at line 78 of file kern_timeout.c.
Referenced by softclock().
void(* callout_new_inserted) (int cpu, int ticks) = NULL |
Definition at line 155 of file kern_timeout.c.
Referenced by callout_cc_add(), and cpu_initclocks_bsp().
int callwheelbits |
Definition at line 85 of file kern_timeout.c.
Referenced by kern_timeout_callwheel_alloc().
int callwheelmask |
Definition at line 85 of file kern_timeout.c.
Referenced by _callout_stop_safe(), callout_cc_add(), callout_reset_on(), callout_tick(), callout_tickstofirst(), kern_timeout_callwheel_alloc(), and softclock().
int callwheelsize |
Definition at line 85 of file kern_timeout.c.
Referenced by callout_cpu_init(), kern_timeout_callwheel_alloc(), and start_softclock().
struct callout_cpu cc_cpu |
Definition at line 146 of file kern_timeout.c.
|
static |
Definition at line 154 of file kern_timeout.c.
Referenced by _callout_init_lock(), callout_init(), kern_timeout_callwheel_alloc(), kern_timeout_callwheel_init(), start_softclock(), and timeout().