FreeBSD kernel kern code
subr_smr.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/counter.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/proc.h>
#include <sys/smp.h>
#include <sys/smr.h>
#include <sys/sysctl.h>
#include <vm/uma.h>
Include dependency graph for subr_smr.c:

Go to the source code of this file.

Macros

#define SMR_SEQ_INIT   1 /* All valid sequence numbers are odd. */
 
#define SMR_SEQ_INCR   2
 
#define SMR_SEQ_MAX_DELTA   (UINT_MAX / 4)
 
#define SMR_SEQ_MAX_ADVANCE   (SMR_SEQ_MAX_DELTA - 1024)
 
#define SMR_LAZY_GRACE   2
 
#define SMR_LAZY_INCR   (SMR_LAZY_GRACE * SMR_SEQ_INCR)
 
#define SMR_SEQ_ADVANCE   SMR_LAZY_INCR
 

Functions

 __FBSDID ("$FreeBSD$")
 
static SYSCTL_NODE (_debug, OID_AUTO, smr, CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, "SMR Stats")
 
static COUNTER_U64_DEFINE_EARLY (advance)
 
 SYSCTL_COUNTER_U64 (_debug_smr, OID_AUTO, advance, CTLFLAG_RW, &advance, "")
 
static COUNTER_U64_DEFINE_EARLY (advance_wait)
 
 SYSCTL_COUNTER_U64 (_debug_smr, OID_AUTO, advance_wait, CTLFLAG_RW, &advance_wait, "")
 
static COUNTER_U64_DEFINE_EARLY (poll)
 
 SYSCTL_COUNTER_U64 (_debug_smr, OID_AUTO, poll, CTLFLAG_RW, &poll, "")
 
static COUNTER_U64_DEFINE_EARLY (poll_scan)
 
 SYSCTL_COUNTER_U64 (_debug_smr, OID_AUTO, poll_scan, CTLFLAG_RW, &poll_scan, "")
 
static COUNTER_U64_DEFINE_EARLY (poll_fail)
 
 SYSCTL_COUNTER_U64 (_debug_smr, OID_AUTO, poll_fail, CTLFLAG_RW, &poll_fail, "")
 
static smr_seq_t smr_lazy_advance (smr_t smr, smr_shared_t s)
 
static smr_seq_t smr_shared_advance (smr_shared_t s)
 
static smr_seq_t smr_default_advance (smr_t smr, smr_shared_t s)
 
static smr_seq_t smr_deferred_advance (smr_t smr, smr_shared_t s, smr_t self)
 
smr_seq_t smr_advance (smr_t smr)
 
static smr_seq_t smr_poll_cpu (smr_t c, smr_seq_t s_rd_seq, smr_seq_t goal, bool wait)
 
static smr_seq_t smr_poll_scan (smr_t smr, smr_shared_t s, smr_seq_t s_rd_seq, smr_seq_t s_wr_seq, smr_seq_t goal, bool wait)
 
bool smr_poll (smr_t smr, smr_seq_t goal, bool wait)
 
smr_t smr_create (const char *name, int limit, int flags)
 
void smr_destroy (smr_t smr)
 
void smr_init (void)
 

Variables

static uma_zone_t smr_shared_zone
 
static uma_zone_t smr_zone
 

Macro Definition Documentation

◆ SMR_LAZY_GRACE

#define SMR_LAZY_GRACE   2

Definition at line 188 of file subr_smr.c.

◆ SMR_LAZY_INCR

#define SMR_LAZY_INCR   (SMR_LAZY_GRACE * SMR_SEQ_INCR)

Definition at line 189 of file subr_smr.c.

◆ SMR_SEQ_ADVANCE

#define SMR_SEQ_ADVANCE   SMR_LAZY_INCR

Definition at line 197 of file subr_smr.c.

◆ SMR_SEQ_INCR

#define SMR_SEQ_INCR   2

Definition at line 151 of file subr_smr.c.

◆ SMR_SEQ_INIT

#define SMR_SEQ_INIT   1 /* All valid sequence numbers are odd. */

Definition at line 150 of file subr_smr.c.

◆ SMR_SEQ_MAX_ADVANCE

#define SMR_SEQ_MAX_ADVANCE   (SMR_SEQ_MAX_DELTA - 1024)

Definition at line 163 of file subr_smr.c.

◆ SMR_SEQ_MAX_DELTA

#define SMR_SEQ_MAX_DELTA   (UINT_MAX / 4)

Definition at line 162 of file subr_smr.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ COUNTER_U64_DEFINE_EARLY() [1/5]

static COUNTER_U64_DEFINE_EARLY ( advance  )
static

◆ COUNTER_U64_DEFINE_EARLY() [2/5]

static COUNTER_U64_DEFINE_EARLY ( advance_wait  )
static

◆ COUNTER_U64_DEFINE_EARLY() [3/5]

static COUNTER_U64_DEFINE_EARLY ( poll  )
static

◆ COUNTER_U64_DEFINE_EARLY() [4/5]

static COUNTER_U64_DEFINE_EARLY ( poll_fail  )
static

◆ COUNTER_U64_DEFINE_EARLY() [5/5]

static COUNTER_U64_DEFINE_EARLY ( poll_scan  )
static

◆ smr_advance()

smr_seq_t smr_advance ( smr_t  smr)

Definition at line 330 of file subr_smr.c.

References flags, smr_default_advance(), smr_deferred_advance(), and smr_lazy_advance().

Here is the call graph for this function:

◆ smr_create()

smr_t smr_create ( const char *  name,
int  limit,
int  flags 
)

Definition at line 586 of file subr_smr.c.

References flags, mp_maxid, name, SMR_SEQ_INIT, smr_shared_zone, smr_zone, and ticks.

◆ smr_default_advance()

static smr_seq_t smr_default_advance ( smr_t  smr,
smr_shared_t  s 
)
static

Definition at line 273 of file subr_smr.c.

References SMR_SEQ_MAX_ADVANCE, SMR_SEQ_MAX_DELTA, and smr_shared_advance().

Referenced by smr_advance(), and smr_deferred_advance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smr_deferred_advance()

static smr_seq_t smr_deferred_advance ( smr_t  smr,
smr_shared_t  s,
smr_t  self 
)
static

Definition at line 307 of file subr_smr.c.

References smr_default_advance(), and SMR_SEQ_INCR.

Referenced by smr_advance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smr_destroy()

void smr_destroy ( smr_t  smr)

Definition at line 614 of file subr_smr.c.

References smr_shared_zone, and smr_zone.

◆ smr_init()

void smr_init ( void  )

Definition at line 626 of file subr_smr.c.

References smr_shared_zone, and smr_zone.

◆ smr_lazy_advance()

static smr_seq_t smr_lazy_advance ( smr_t  smr,
smr_shared_t  s 
)
static

Definition at line 219 of file subr_smr.c.

References atomic_cmpset_64(), SMR_LAZY_GRACE, SMR_LAZY_INCR, SMR_SEQ_INCR, and ticks.

Referenced by smr_advance(), and smr_poll().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smr_poll()

bool smr_poll ( smr_t  smr,
smr_seq_t  goal,
bool  wait 
)

Definition at line 478 of file subr_smr.c.

References flags, smr_lazy_advance(), smr_poll_scan(), SMR_SEQ_ADVANCE, and smr_shared_advance().

Here is the call graph for this function:

◆ smr_poll_cpu()

static smr_seq_t smr_poll_cpu ( smr_t  c,
smr_seq_t  s_rd_seq,
smr_seq_t  goal,
bool  wait 
)
static

Definition at line 370 of file subr_smr.c.

Referenced by smr_poll_scan().

Here is the caller graph for this function:

◆ smr_poll_scan()

static smr_seq_t smr_poll_scan ( smr_t  smr,
smr_shared_t  s,
smr_seq_t  s_rd_seq,
smr_seq_t  s_wr_seq,
smr_seq_t  goal,
bool  wait 
)
static

Definition at line 421 of file subr_smr.c.

References smr_poll_cpu().

Referenced by smr_poll().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smr_shared_advance()

static smr_seq_t smr_shared_advance ( smr_shared_t  s)
static

Definition at line 261 of file subr_smr.c.

References SMR_SEQ_INCR.

Referenced by smr_default_advance(), and smr_poll().

Here is the caller graph for this function:

◆ SYSCTL_COUNTER_U64() [1/5]

SYSCTL_COUNTER_U64 ( _debug_smr  ,
OID_AUTO  ,
advance  ,
CTLFLAG_RW  ,
advance,
""   
)

◆ SYSCTL_COUNTER_U64() [2/5]

SYSCTL_COUNTER_U64 ( _debug_smr  ,
OID_AUTO  ,
advance_wait  ,
CTLFLAG_RW  ,
advance_wait,
""   
)

◆ SYSCTL_COUNTER_U64() [3/5]

SYSCTL_COUNTER_U64 ( _debug_smr  ,
OID_AUTO  ,
poll  ,
CTLFLAG_RW  ,
poll,
""   
)

◆ SYSCTL_COUNTER_U64() [4/5]

SYSCTL_COUNTER_U64 ( _debug_smr  ,
OID_AUTO  ,
poll_fail  ,
CTLFLAG_RW  ,
poll_fail,
""   
)

◆ SYSCTL_COUNTER_U64() [5/5]

SYSCTL_COUNTER_U64 ( _debug_smr  ,
OID_AUTO  ,
poll_scan  ,
CTLFLAG_RW  ,
poll_scan,
""   
)

◆ SYSCTL_NODE()

static SYSCTL_NODE ( _debug  ,
OID_AUTO  ,
smr  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
"SMR Stats"   
)
static

Variable Documentation

◆ smr_shared_zone

uma_zone_t smr_shared_zone
static

Definition at line 146 of file subr_smr.c.

Referenced by smr_create(), smr_destroy(), and smr_init().

◆ smr_zone

uma_zone_t smr_zone
static

Definition at line 147 of file subr_smr.c.

Referenced by smr_create(), smr_destroy(), and smr_init().