FreeBSD kernel kern code
kern_rmlock.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_kdtrace.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/kdb.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/rmlock.h>
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/turnstile.h>
#include <sys/lock_profile.h>
#include <machine/cpu.h>
Include dependency graph for kern_rmlock.c:

Go to the source code of this file.

Macros

#define RM_DESTROYED   ((void *)0xdead)
 
#define rm_destroyed(rm)   (LIST_FIRST(&(rm)->rm_activeReaders) == RM_DESTROYED)
 
#define RMPF_ONQUEUE   1
 
#define RMPF_SIGNAL   2
 
#define _rm_assert(c, what, file, line)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static void assert_rm (struct lock_object *lock, int what)
 
static void lock_rm (struct lock_object *lock, int how)
 
static int unlock_rm (struct lock_object *lock)
 
 MTX_SYSINIT (rm_spinlock,&rm_spinlock,"rm_spinlock", MTX_SPIN)
 
static void rm_tracker_add (struct pcpu *pc, struct rm_priotracker *tracker)
 
static int rm_trackers_present (const struct pcpu *pc, const struct rmlock *rm, const struct thread *td)
 
static void rm_tracker_remove (struct pcpu *pc, struct rm_priotracker *tracker)
 
static void rm_cleanIPI (void *arg)
 
void rm_init_flags (struct rmlock *rm, const char *name, int opts)
 
void rm_init (struct rmlock *rm, const char *name)
 
void rm_destroy (struct rmlock *rm)
 
int rm_wowned (struct rmlock *rm)
 
void rm_sysinit (void *arg)
 
void rm_sysinit_flags (void *arg)
 
static int _rm_rlock_hard (struct rmlock *rm, struct rm_priotracker *tracker, int trylock)
 
int _rm_rlock (struct rmlock *rm, struct rm_priotracker *tracker, int trylock)
 
static void _rm_unlock_hard (struct thread *td, struct rm_priotracker *tracker)
 
void _rm_runlock (struct rmlock *rm, struct rm_priotracker *tracker)
 
void _rm_wlock (struct rmlock *rm)
 
void _rm_wunlock (struct rmlock *rm)
 
void _rm_wlock_debug (struct rmlock *rm, const char *file, int line)
 
void _rm_wunlock_debug (struct rmlock *rm, const char *file, int line)
 
int _rm_rlock_debug (struct rmlock *rm, struct rm_priotracker *tracker, int trylock, const char *file, int line)
 
void _rm_runlock_debug (struct rmlock *rm, struct rm_priotracker *tracker, const char *file, int line)
 

Variables

struct lock_class lock_class_rm
 
struct lock_class lock_class_rm_sleepable
 
static struct mtx rm_spinlock
 

Macro Definition Documentation

#define _rm_assert (   c,
  what,
  file,
  line 
)

Definition at line 73 of file kern_rmlock.c.

#define RM_DESTROYED   ((void *)0xdead)

Definition at line 64 of file kern_rmlock.c.

Referenced by rm_destroy().

#define rm_destroyed (   rm)    (LIST_FIRST(&(rm)->rm_activeReaders) == RM_DESTROYED)

Definition at line 66 of file kern_rmlock.c.

#define RMPF_ONQUEUE   1

Definition at line 69 of file kern_rmlock.c.

Referenced by _rm_rlock_hard(), _rm_wlock(), and rm_cleanIPI().

#define RMPF_SIGNAL   2

Definition at line 70 of file kern_rmlock.c.

Referenced by _rm_unlock_hard(), and _rm_wlock().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
int _rm_rlock ( struct rmlock *  rm,
struct rm_priotracker *  tracker,
int  trylock 
)

Definition at line 402 of file kern_rmlock.c.

References _rm_rlock_hard(), and rm_tracker_add().

Referenced by _rm_rlock_debug().

Here is the call graph for this function:

Here is the caller graph for this function:

int _rm_rlock_debug ( struct rmlock *  rm,
struct rm_priotracker *  tracker,
int  trylock,
const char *  file,
int  line 
)

Definition at line 685 of file kern_rmlock.c.

References _rm_rlock().

Here is the call graph for this function:

static int _rm_rlock_hard ( struct rmlock *  rm,
struct rm_priotracker *  tracker,
int  trylock 
)
static

Definition at line 321 of file kern_rmlock.c.

References critical_enter(), critical_exit(), pcpu_find(), rm_spinlock, rm_tracker_add(), rm_tracker_remove(), rm_trackers_present(), and RMPF_ONQUEUE.

Referenced by _rm_rlock().

Here is the call graph for this function:

Here is the caller graph for this function:

void _rm_runlock ( struct rmlock *  rm,
struct rm_priotracker *  tracker 
)

Definition at line 474 of file kern_rmlock.c.

References _rm_unlock_hard(), and rm_tracker_remove().

Referenced by _rm_runlock_debug().

Here is the call graph for this function:

Here is the caller graph for this function:

void _rm_runlock_debug ( struct rmlock *  rm,
struct rm_priotracker *  tracker,
const char *  file,
int  line 
)

Definition at line 693 of file kern_rmlock.c.

References _rm_runlock().

Here is the call graph for this function:

static void _rm_unlock_hard ( struct thread *  td,
struct rm_priotracker *  tracker 
)
static

Definition at line 441 of file kern_rmlock.c.

References critical_exit(), rm_spinlock, RMPF_SIGNAL, ts, turnstile_chain_lock(), turnstile_chain_unlock(), turnstile_lookup(), turnstile_signal(), and turnstile_unpend().

Referenced by _rm_runlock().

Here is the call graph for this function:

Here is the caller graph for this function:

void _rm_wlock ( struct rmlock *  rm)

Definition at line 495 of file kern_rmlock.c.

References all_cpus, rm_cleanIPI(), rm_spinlock, RMPF_ONQUEUE, RMPF_SIGNAL, smp_no_rendevous_barrier(), smp_rendezvous_cpus(), ts, turnstile_trywait(), and turnstile_wait().

Referenced by _rm_wlock_debug().

Here is the call graph for this function:

Here is the caller graph for this function:

void _rm_wlock_debug ( struct rmlock *  rm,
const char *  file,
int  line 
)

Definition at line 671 of file kern_rmlock.c.

References _rm_wlock().

Here is the call graph for this function:

void _rm_wunlock ( struct rmlock *  rm)

Definition at line 544 of file kern_rmlock.c.

Referenced by _rm_wunlock_debug().

Here is the caller graph for this function:

void _rm_wunlock_debug ( struct rmlock *  rm,
const char *  file,
int  line 
)

Definition at line 678 of file kern_rmlock.c.

References _rm_wunlock().

Here is the call graph for this function:

static void assert_rm ( struct lock_object *  lock,
int  what 
)
static

Definition at line 115 of file kern_rmlock.c.

static void lock_rm ( struct lock_object *  lock,
int  how 
)
static

Definition at line 128 of file kern_rmlock.c.

References panic().

Here is the call graph for this function:

MTX_SYSINIT ( rm_spinlock  ,
rm_spinlock,
"rm_spinlock"  ,
MTX_SPIN   
)
static void rm_cleanIPI ( void *  arg)
static

Definition at line 229 of file kern_rmlock.c.

References pcpu_find(), rm_spinlock, and RMPF_ONQUEUE.

Referenced by _rm_wlock().

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_destroy ( struct rmlock *  rm)

Definition at line 282 of file kern_rmlock.c.

References lock_destroy(), mtx_destroy(), RM_DESTROYED, and sx_destroy().

Here is the call graph for this function:

void rm_init ( struct rmlock *  rm,
const char *  name 
)

Definition at line 275 of file kern_rmlock.c.

References rm_init_flags().

Referenced by osd_init(), and rm_sysinit().

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_init_flags ( struct rmlock *  rm,
const char *  name,
int  opts 
)

Definition at line 251 of file kern_rmlock.c.

References all_cpus, lc, lock_class_rm, lock_class_rm_sleepable, lock_init(), mtx_init(), and sx_init_flags().

Referenced by rm_init(), and rm_sysinit_flags().

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_sysinit ( void *  arg)

Definition at line 305 of file kern_rmlock.c.

References rm_init().

Here is the call graph for this function:

void rm_sysinit_flags ( void *  arg)

Definition at line 313 of file kern_rmlock.c.

References rm_init_flags().

Here is the call graph for this function:

static void rm_tracker_add ( struct pcpu *  pc,
struct rm_priotracker *  tracker 
)
inlinestatic

Definition at line 175 of file kern_rmlock.c.

Referenced by _rm_rlock(), and _rm_rlock_hard().

Here is the caller graph for this function:

static void rm_tracker_remove ( struct pcpu *  pc,
struct rm_priotracker *  tracker 
)
inlinestatic

Definition at line 214 of file kern_rmlock.c.

Referenced by _rm_rlock_hard(), and _rm_runlock().

Here is the caller graph for this function:

static int rm_trackers_present ( const struct pcpu *  pc,
const struct rmlock *  rm,
const struct thread *  td 
)
static

Definition at line 196 of file kern_rmlock.c.

References count.

Referenced by _rm_rlock_hard().

Here is the caller graph for this function:

int rm_wowned ( struct rmlock *  rm)

Definition at line 295 of file kern_rmlock.c.

static int unlock_rm ( struct lock_object *  lock)
static

Definition at line 142 of file kern_rmlock.c.

Variable Documentation

struct lock_class lock_class_rm
Initial value:
= {
.lc_name = "rm",
.lc_flags = LC_SLEEPLOCK | LC_RECURSABLE,
.lc_assert = assert_rm,
.lc_lock = lock_rm,
.lc_unlock = unlock_rm,
}
static void lock_rm(struct lock_object *lock, int how)
Definition: kern_rmlock.c:128
static int unlock_rm(struct lock_object *lock)
Definition: kern_rmlock.c:142
static void assert_rm(struct lock_object *lock, int what)
Definition: kern_rmlock.c:115

Definition at line 86 of file kern_rmlock.c.

Referenced by rm_init_flags().

struct lock_class lock_class_rm_sleepable
Initial value:
= {
.lc_name = "sleepable rm",
.lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE,
.lc_assert = assert_rm,
.lc_lock = lock_rm,
.lc_unlock = unlock_rm,
}
static void lock_rm(struct lock_object *lock, int how)
Definition: kern_rmlock.c:128
static int unlock_rm(struct lock_object *lock)
Definition: kern_rmlock.c:142
static void assert_rm(struct lock_object *lock, int what)
Definition: kern_rmlock.c:115

Definition at line 100 of file kern_rmlock.c.

Referenced by rm_init_flags().

struct mtx rm_spinlock
static

Definition at line 164 of file kern_rmlock.c.

Referenced by _rm_rlock_hard(), _rm_unlock_hard(), _rm_wlock(), and rm_cleanIPI().