FreeBSD kernel kern code
subr_sleepqueue.c File Reference
#include <sys/cdefs.h>
#include "opt_sleepqueue_profiling.h"
#include "opt_ddb.h"
#include "opt_kdtrace.h"
#include "opt_sched.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/sched.h>
#include <sys/sdt.h>
#include <sys/signalvar.h>
#include <sys/sleepqueue.h>
#include <sys/sysctl.h>
#include <vm/uma.h>
Include dependency graph for subr_sleepqueue.c:

Go to the source code of this file.

Data Structures

struct  sleepqueue
 
struct  sleepqueue_chain
 

Macros

#define SC_TABLESIZE   128 /* Must be power of 2. */
 
#define SC_MASK   (SC_TABLESIZE - 1)
 
#define SC_SHIFT   8
 
#define SC_HASH(wc)   (((uintptr_t)(wc) >> SC_SHIFT) & SC_MASK)
 
#define SC_LOOKUP(wc)   &sleepq_chains[SC_HASH(wc)]
 
#define NR_SLEEPQS   2
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static int sleepq_catch_signals (void *wchan, int pri)
 
static int sleepq_check_signals (void)
 
static int sleepq_check_timeout (void)
 
static int sleepq_init (void *mem, int size, int flags)
 
static int sleepq_resume_thread (struct sleepqueue *sq, struct thread *td, int pri)
 
static void sleepq_switch (void *wchan, int pri)
 
static void sleepq_timeout (void *arg)
 
 SDT_PROBE_DECLARE (sched,,, sleep)
 
 SDT_PROBE_DECLARE (sched,,, wakeup)
 
void init_sleepqueues (void)
 
struct sleepqueuesleepq_alloc (void)
 
void sleepq_free (struct sleepqueue *sq)
 
void sleepq_lock (void *wchan)
 
struct sleepqueuesleepq_lookup (void *wchan)
 
void sleepq_release (void *wchan)
 
void sleepq_add (void *wchan, struct lock_object *lock, const char *wmesg, int flags, int queue)
 
void sleepq_set_timeout (void *wchan, int timo)
 
u_int sleepq_sleepcnt (void *wchan, int queue)
 
void sleepq_wait (void *wchan, int pri)
 
int sleepq_wait_sig (void *wchan, int pri)
 
int sleepq_timedwait (void *wchan, int pri)
 
int sleepq_timedwait_sig (void *wchan, int pri)
 
int sleepq_type (void *wchan)
 
int sleepq_signal (void *wchan, int flags, int pri, int queue)
 
int sleepq_broadcast (void *wchan, int flags, int pri, int queue)
 
void sleepq_remove (struct thread *td, void *wchan)
 
int sleepq_abort (struct thread *td, int intrval)
 

Variables

static struct sleepqueue_chain sleepq_chains [SC_TABLESIZE]
 
static uma_zone_t sleepq_zone
 

Macro Definition Documentation

#define NR_SLEEPQS   2

Definition at line 99 of file subr_sleepqueue.c.

Referenced by sleepq_add(), sleepq_init(), sleepq_resume_thread(), and sleepq_sleepcnt().

#define SC_HASH (   wc)    (((uintptr_t)(wc) >> SC_SHIFT) & SC_MASK)

Definition at line 97 of file subr_sleepqueue.c.

#define SC_MASK   (SC_TABLESIZE - 1)

Definition at line 95 of file subr_sleepqueue.c.

#define SC_SHIFT   8

Definition at line 96 of file subr_sleepqueue.c.

#define SC_TABLESIZE   128 /* Must be power of 2. */

Definition at line 94 of file subr_sleepqueue.c.

Referenced by init_sleepqueues().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
void init_sleepqueues ( void  )

Definition at line 176 of file subr_sleepqueue.c.

References mtx_init(), SC_TABLESIZE, sleepq_alloc(), sleepq_chains, sleepq_init(), sleepq_zone, and snprintf().

Referenced by sleepinit().

Here is the call graph for this function:

Here is the caller graph for this function:

SDT_PROBE_DECLARE ( sched  ,
sleep   
)
SDT_PROBE_DECLARE ( sched  ,
wakeup   
)
int sleepq_abort ( struct thread *  td,
int  intrval 
)

Definition at line 986 of file subr_sleepqueue.c.

References sleepq_lookup(), and sleepq_resume_thread().

Referenced by tdsendsignal(), tdsigwakeup(), and thread_single().

Here is the call graph for this function:

Here is the caller graph for this function:

void sleepq_add ( void *  wchan,
struct lock_object *  lock,
const char *  wmesg,
int  flags,
int  queue 
)

Definition at line 281 of file subr_sleepqueue.c.

References NR_SLEEPQS, SC_LOOKUP, and sleepq_lookup().

Referenced by __lockmgr_args(), _callout_stop_safe(), _cv_timedwait(), _cv_timedwait_sig(), _cv_wait(), _cv_wait_sig(), _cv_wait_unlock(), _sleep(), _sx_slock_hard(), _sx_xlock_hard(), msleep_spin(), and sleeplk().

Here is the call graph for this function:

Here is the caller graph for this function:

struct sleepqueue* sleepq_alloc ( void  )

Definition at line 214 of file subr_sleepqueue.c.

References sleepq_zone.

Referenced by init_sleepqueues(), and thread_init().

Here is the caller graph for this function:

int sleepq_broadcast ( void *  wchan,
int  flags,
int  pri,
int  queue 
)

Definition at line 846 of file subr_sleepqueue.c.

References sleepq_lookup(), and sleepq_resume_thread().

Referenced by __lockmgr_args(), _sx_downgrade(), _sx_sunlock_hard(), _sx_xunlock_hard(), cv_broadcastpri(), wakeup(), and wakeupshlk().

Here is the call graph for this function:

Here is the caller graph for this function:

static int sleepq_catch_signals ( void *  wchan,
int  pri 
)
static

Definition at line 397 of file subr_sleepqueue.c.

References cursig(), panic(), SC_LOOKUP, sleepq_lookup(), sleepq_resume_thread(), sleepq_switch(), and thread_suspend_check().

Referenced by sleepq_timedwait_sig(), and sleepq_wait_sig().

Here is the call graph for this function:

Here is the caller graph for this function:

static int sleepq_check_signals ( void  )
static

Definition at line 588 of file subr_sleepqueue.c.

Referenced by sleepq_timedwait_sig(), and sleepq_wait_sig().

Here is the caller graph for this function:

static int sleepq_check_timeout ( void  )
static

Definition at line 549 of file subr_sleepqueue.c.

References mi_switch().

Referenced by sleepq_timedwait(), and sleepq_timedwait_sig().

Here is the call graph for this function:

Here is the caller graph for this function:

void sleepq_free ( struct sleepqueue sq)

Definition at line 224 of file subr_sleepqueue.c.

References sleepq_zone.

Referenced by thread_fini().

Here is the caller graph for this function:

static int sleepq_init ( void *  mem,
int  size,
int  flags 
)
static

Definition at line 790 of file subr_sleepqueue.c.

References NR_SLEEPQS.

Referenced by init_sleepqueues().

Here is the caller graph for this function:

struct sleepqueue* sleepq_lookup ( void *  wchan)
void sleepq_remove ( struct thread *  td,
void *  wchan 
)

Definition at line 947 of file subr_sleepqueue.c.

References sleepq_lock(), sleepq_lookup(), sleepq_release(), and sleepq_resume_thread().

Referenced by _sleep().

Here is the call graph for this function:

Here is the caller graph for this function:

static int sleepq_resume_thread ( struct sleepqueue sq,
struct thread *  td,
int  pri 
)
static

Definition at line 707 of file subr_sleepqueue.c.

References NR_SLEEPQS, SC_LOOKUP, sched_prio(), setrunnable(), and wakeup().

Referenced by sleepq_abort(), sleepq_broadcast(), sleepq_catch_signals(), sleepq_remove(), sleepq_signal(), sleepq_switch(), and sleepq_timeout().

Here is the call graph for this function:

Here is the caller graph for this function:

void sleepq_set_timeout ( void *  wchan,
int  timo 
)

Definition at line 360 of file subr_sleepqueue.c.

References SC_LOOKUP, and sleepq_timeout().

Referenced by _cv_timedwait(), _cv_timedwait_sig(), _sleep(), msleep_spin(), and sleeplk().

Here is the call graph for this function:

Here is the caller graph for this function:

int sleepq_signal ( void *  wchan,
int  flags,
int  pri,
int  queue 
)

Definition at line 809 of file subr_sleepqueue.c.

References sleepq_lookup(), and sleepq_resume_thread().

Referenced by cv_signal(), and wakeup_one().

Here is the call graph for this function:

Here is the caller graph for this function:

u_int sleepq_sleepcnt ( void *  wchan,
int  queue 
)

Definition at line 378 of file subr_sleepqueue.c.

References NR_SLEEPQS, and sleepq_lookup().

Referenced by __lockmgr_args(), _sx_xunlock_hard(), and wakeupshlk().

Here is the call graph for this function:

Here is the caller graph for this function:

static void sleepq_switch ( void *  wchan,
int  pri 
)
static

Definition at line 490 of file subr_sleepqueue.c.

References mi_switch(), panic(), SC_LOOKUP, sched_sleep(), sleepq_lookup(), sleepq_resume_thread(), and thread_lock_set().

Referenced by sleepq_catch_signals(), sleepq_timedwait(), and sleepq_wait().

Here is the call graph for this function:

Here is the caller graph for this function:

int sleepq_timedwait ( void *  wchan,
int  pri 
)

Definition at line 645 of file subr_sleepqueue.c.

References sleepq_check_timeout(), and sleepq_switch().

Referenced by _cv_timedwait(), _sleep(), msleep_spin(), and sleeplk().

Here is the call graph for this function:

Here is the caller graph for this function:

int sleepq_timedwait_sig ( void *  wchan,
int  pri 
)

Definition at line 665 of file subr_sleepqueue.c.

References sleepq_catch_signals(), sleepq_check_signals(), and sleepq_check_timeout().

Referenced by _cv_timedwait_sig(), _sleep(), and sleeplk().

Here is the call graph for this function:

Here is the caller graph for this function:

static void sleepq_timeout ( void *  arg)
static

Definition at line 877 of file subr_sleepqueue.c.

References SC_LOOKUP, setrunnable(), sleepq_lookup(), and sleepq_resume_thread().

Referenced by sleepq_set_timeout().

Here is the call graph for this function:

Here is the caller graph for this function:

int sleepq_type ( void *  wchan)

Definition at line 684 of file subr_sleepqueue.c.

References sleepq_lock(), sleepq_lookup(), sleepq_release(), and type.

Here is the call graph for this function:

void sleepq_wait ( void *  wchan,
int  pri 
)

Definition at line 611 of file subr_sleepqueue.c.

References sleepq_switch().

Referenced by __lockmgr_args(), _callout_stop_safe(), _cv_wait(), _cv_wait_unlock(), _sleep(), _sx_slock_hard(), _sx_xlock_hard(), msleep_spin(), and sleeplk().

Here is the call graph for this function:

Here is the caller graph for this function:

int sleepq_wait_sig ( void *  wchan,
int  pri 
)

Definition at line 627 of file subr_sleepqueue.c.

References sleepq_catch_signals(), and sleepq_check_signals().

Referenced by _cv_wait_sig(), _sleep(), _sx_slock_hard(), _sx_xlock_hard(), and sleeplk().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct sleepqueue_chain sleepq_chains[SC_TABLESIZE]
static

Definition at line 150 of file subr_sleepqueue.c.

Referenced by init_sleepqueues().

uma_zone_t sleepq_zone
static

Definition at line 151 of file subr_sleepqueue.c.

Referenced by init_sleepqueues(), sleepq_alloc(), and sleepq_free().