FreeBSD kernel kern code
kern_clock.c File Reference
#include <sys/cdefs.h>
#include "opt_kdb.h"
#include "opt_device_polling.h"
#include "opt_hwpmc_hooks.h"
#include "opt_kdtrace.h"
#include "opt_ntp.h"
#include "opt_watchdog.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/callout.h>
#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/resource.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/sdt.h>
#include <sys/signalvar.h>
#include <sys/sleepqueue.h>
#include <sys/smp.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <sys/sysctl.h>
#include <sys/bus.h>
#include <sys/interrupt.h>
#include <sys/limits.h>
#include <sys/timetc.h>
Include dependency graph for kern_clock.c:

Go to the source code of this file.

Functions

 __FBSDID ("$BSDSUniX$")
 
static void initclocks (void *dummy)
 
 SYSINIT (clocks, SI_SUB_CLOCKS, SI_ORDER_FIRST, initclocks, NULL)
 
 SDT_PROVIDER_DECLARE (sched)
 
 SDT_PROBE_DEFINE2 (sched,,, tick,"struct thread *","struct proc *")
 
static int sysctl_kern_cp_time (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern, OID_AUTO, cp_time, CTLTYPE_LONG|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_cp_time,"LU","CPU time statistics")
 
static int sysctl_kern_cp_times (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern, OID_AUTO, cp_times, CTLTYPE_LONG|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_cp_times,"LU","per-CPU time statistics")
 
void read_cpu_time (long *cp_time)
 
static DPCPU_DEFINE (int, pcputicks)
 
void hardclock_cpu (int usermode)
 
void hardclock (int usermode, uintfptr_t pc)
 
void hardclock_cnt (int cnt, int usermode)
 
void hardclock_sync (int cpu)
 
int tvtohz (struct timeval *tv)
 
void startprofclock (struct proc *p)
 
void stopprofclock (struct proc *p)
 
void statclock (int usermode)
 
void statclock_cnt (int cnt, int usermode)
 
void profclock (int usermode, uintfptr_t pc)
 
void profclock_cnt (int cnt, int usermode, uintfptr_t pc)
 
static int sysctl_kern_clockrate (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_clockrate,"S,clockinfo","Rate and period of various kernel clocks")
 

Variables

static struct mtx time_lock
 
static long empty [CPUSTATES]
 
int stathz
 
int profhz
 
int profprocs
 
volatile int ticks
 
int psratio
 
static int global_hardclock_run = 0
 

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static DPCPU_DEFINE ( int  ,
pcputicks   
)
static
void hardclock ( int  usermode,
uintfptr_t  pc 
)

Definition at line 471 of file kern_clock.c.

References cpu_tick_calibration(), hardclock_cpu(), hardclock_device_poll(), profclock(), statclock(), and tc_ticktock().

Here is the call graph for this function:

void hardclock_cnt ( int  cnt,
int  usermode 
)

Definition at line 497 of file kern_clock.c.

References callout_tick(), clock, cpu_tick_calibration(), hardclock_device_poll(), itimerdecr(), sched_tick(), tc_ticktock(), tick, and ticks.

Referenced by handleevents().

Here is the call graph for this function:

Here is the caller graph for this function:

void hardclock_cpu ( int  usermode)

Definition at line 428 of file kern_clock.c.

References callout_tick(), clock, itimerdecr(), sched_tick(), and tick.

Referenced by hardclock().

Here is the call graph for this function:

Here is the caller graph for this function:

void hardclock_sync ( int  cpu)

Definition at line 579 of file kern_clock.c.

References ticks.

Referenced by configtimer(), and cpu_initclocks_ap().

Here is the caller graph for this function:

static void initclocks ( void *  dummy)
static

Definition at line 398 of file kern_clock.c.

References hz, mtx_init(), and time_lock.

Here is the call graph for this function:

void profclock ( int  usermode,
uintfptr_t  pc 
)

Definition at line 782 of file kern_clock.c.

References profclock_cnt().

Referenced by hardclock().

Here is the call graph for this function:

Here is the caller graph for this function:

void profclock_cnt ( int  cnt,
int  usermode,
uintfptr_t  pc 
)

Definition at line 789 of file kern_clock.c.

References addupc_intr(), and clock.

Referenced by handleevents(), and profclock().

Here is the call graph for this function:

Here is the caller graph for this function:

void read_cpu_time ( long *  cp_time)

Definition at line 329 of file kern_clock.c.

References pcpu_find().

Referenced by sysctl_kern_cp_time().

Here is the call graph for this function:

Here is the caller graph for this function:

SDT_PROBE_DEFINE2 ( sched  ,
tick  ,
"struct thread *"  ,
"struct proc *"   
)
SDT_PROVIDER_DECLARE ( sched  )
void startprofclock ( struct proc *  p)

Definition at line 652 of file kern_clock.c.

References cpu_startprofclock(), and time_lock.

Referenced by do_fork(), and sys_profil().

Here is the call graph for this function:

Here is the caller graph for this function:

void statclock ( int  usermode)

Definition at line 702 of file kern_clock.c.

References statclock_cnt().

Referenced by hardclock().

Here is the call graph for this function:

Here is the caller graph for this function:

void statclock_cnt ( int  cnt,
int  usermode 
)

Definition at line 709 of file kern_clock.c.

References clock, sched_clock(), sched_tdname(), and tick.

Referenced by handleevents(), and statclock().

Here is the call graph for this function:

Here is the caller graph for this function:

void stopprofclock ( struct proc *  p)

Definition at line 672 of file kern_clock.c.

References cpu_stopprofclock(), and time_lock.

Referenced by addupc_task(), do_execve(), exit1(), and sys_profil().

Here is the call graph for this function:

Here is the caller graph for this function:

static int sysctl_kern_clockrate ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 832 of file kern_clock.c.

References hz, profhz, sysctl_handle_opaque(), and tick.

Here is the call graph for this function:

static int sysctl_kern_cp_time ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 99 of file kern_clock.c.

References read_cpu_time().

Here is the call graph for this function:

static int sysctl_kern_cp_times ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 132 of file kern_clock.c.

References empty, mp_maxid, and pcpu_find().

Here is the call graph for this function:

SYSCTL_PROC ( _kern  ,
OID_AUTO  ,
cp_time  ,
CTLTYPE_LONG|CTLFLAG_RD|  CTLFLAG_MPSAFE,
,
,
sysctl_kern_cp_time  ,
"LU"  ,
"CPU time statistics"   
)
SYSCTL_PROC ( _kern  ,
OID_AUTO  ,
cp_times  ,
CTLTYPE_LONG|CTLFLAG_RD|  CTLFLAG_MPSAFE,
,
,
sysctl_kern_cp_times  ,
"LU"  ,
"per-CPU time statistics"   
)
SYSCTL_PROC ( _kern  ,
KERN_CLOCKRATE  ,
clockrate  ,
CTLTYPE_STRUCT|CTLFLAG_RD|  CTLFLAG_MPSAFE,
,
,
sysctl_kern_clockrate  ,
S,
clockinfo"  ,
"Rate and period of various kernel clocks"   
)
SYSINIT ( clocks  ,
SI_SUB_CLOCKS  ,
SI_ORDER_FIRST  ,
initclocks  ,
NULL   
)

Variable Documentation

long empty[CPUSTATES]
static

Definition at line 129 of file kern_clock.c.

Referenced by sysctl_kern_cp_times(), and turnstile_signal().

int global_hardclock_run = 0
static

Definition at line 391 of file kern_clock.c.

int profhz

Definition at line 385 of file kern_clock.c.

Referenced by cpu_initclocks_bsp(), setuptimer(), and sysctl_kern_clockrate().

int profprocs

Definition at line 386 of file kern_clock.c.

int psratio

Definition at line 388 of file kern_clock.c.

Referenced by userret().

int stathz

Definition at line 384 of file kern_clock.c.

Referenced by cpu_initclocks_bsp(), getnextcpuevent(), sched_initticks(), and setuptimer().

struct mtx time_lock
static

Definition at line 93 of file kern_clock.c.

Referenced by initclocks(), startprofclock(), and stopprofclock().