FreeBSD kernel kern code
subr_smp.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/proc.h>
#include <sys/bus.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/pcpu.h>
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
#include <machine/smp.h>
#include "opt_sched.h"
Include dependency graph for subr_smp.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
static int sysctl_kern_smp_active (SYSCTL_HANDLER_ARGS)
 
static SYSCTL_NODE (_kern, OID_AUTO, smp, CTLFLAG_RD|CTLFLAG_CAPRD|CTLFLAG_MPSAFE, NULL, "Kernel SMP")
 
 SYSCTL_INT (_kern_smp, OID_AUTO, maxid, CTLFLAG_RD|CTLFLAG_CAPRD, &mp_maxid, 0, "Max CPU ID.")
 
 SYSCTL_INT (_kern_smp, OID_AUTO, maxcpus, CTLFLAG_RD|CTLFLAG_CAPRD, &mp_maxcpus, 0, "Max number of CPUs that the system was compiled for.")
 
 SYSCTL_PROC (_kern_smp, OID_AUTO, active, CTLFLAG_RD|CTLTYPE_INT|CTLFLAG_MPSAFE, NULL, 0, sysctl_kern_smp_active, "I", "Indicates system is running in SMP mode")
 
 SYSCTL_INT (_kern_smp, OID_AUTO, disabled, CTLFLAG_RDTUN|CTLFLAG_CAPRD, &smp_disabled, 0, "SMP has been disabled from the loader")
 
 SYSCTL_INT (_kern_smp, OID_AUTO, cpus, CTLFLAG_RD|CTLFLAG_CAPRD, &smp_cpus, 0, "Number of CPUs online")
 
 SYSCTL_INT (_kern_smp, OID_AUTO, threads_per_core, CTLFLAG_RD|CTLFLAG_CAPRD, &smp_threads_per_core, 0, "Number of SMT threads online per core")
 
 SYSCTL_INT (_kern_smp, OID_AUTO, cores, CTLFLAG_RD|CTLFLAG_CAPRD, &mp_ncores, 0, "Number of physical cores online")
 
 SYSCTL_INT (_kern_smp, OID_AUTO, topology, CTLFLAG_RDTUN, &smp_topology, 0, "Topology override setting; 0 is default provided by hardware.")
 
void smp_rendezvous_cpus (cpuset_t map, void(*setup_func)(void *), void(*action_func)(void *), void(*teardown_func)(void *), void *arg)
 
void smp_rendezvous (void(*setup_func)(void *), void(*action_func)(void *), void(*teardown_func)(void *), void *arg)
 
static void mp_setvariables_for_up (void *dummy)
 
 SYSINIT (cpu_mp_setvariables, SI_SUB_TUNABLES, SI_ORDER_FIRST, mp_setvariables_for_up, NULL)
 
void smp_no_rendezvous_barrier (void *dummy)
 
void smp_rendezvous_cpus_retry (cpuset_t map, void(*setup_func)(void *), void(*action_func)(void *), void(*teardown_func)(void *), void(*wait_func)(void *, int), struct smp_rendezvous_cpus_retry_arg *arg)
 
void smp_rendezvous_cpus_done (struct smp_rendezvous_cpus_retry_arg *arg)
 
int quiesce_cpus (cpuset_t map, const char *wmesg, int prio)
 
int quiesce_all_cpus (const char *wmesg, int prio)
 
void quiesce_all_critical (void)
 
static void cpus_fence_seq_cst_issue (void *arg __unused)
 
void cpus_fence_seq_cst (void)
 

Variables

cpuset_t all_cpus
 
int mp_ncpus
 
int mp_maxcpus = MAXCPU
 
volatile int smp_started
 
u_int mp_maxid
 
int smp_disabled = 0
 
int smp_cpus = 1
 
int smp_threads_per_core = 1
 
int mp_ncores = -1
 
int smp_topology = 0
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ cpus_fence_seq_cst()

void cpus_fence_seq_cst ( void  )

Definition at line 1062 of file subr_smp.c.

References cpus_fence_seq_cst_issue(), smp_no_rendezvous_barrier(), and smp_rendezvous().

Here is the call graph for this function:

◆ cpus_fence_seq_cst_issue()

static void cpus_fence_seq_cst_issue ( void *arg  __unused)
static

Definition at line 1048 of file subr_smp.c.

Referenced by cpus_fence_seq_cst().

Here is the caller graph for this function:

◆ mp_setvariables_for_up()

static void mp_setvariables_for_up ( void *  dummy)
static

Definition at line 880 of file subr_smp.c.

References all_cpus, mp_maxid, mp_ncores, and mp_ncpus.

◆ quiesce_all_cpus()

int quiesce_all_cpus ( const char *  wmesg,
int  prio 
)

Definition at line 1011 of file subr_smp.c.

References all_cpus, and quiesce_cpus().

Referenced by sysctl_debug_ktr_entries(), and thread_reap_barrier().

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

◆ quiesce_all_critical()

void quiesce_all_critical ( void  )

Definition at line 1024 of file subr_smp.c.

◆ quiesce_cpus()

int quiesce_cpus ( cpuset_t  map,
const char *  wmesg,
int  prio 
)

Definition at line 967 of file subr_smp.c.

References free(), malloc(), mp_maxid, pcpu_find(), quiesce_cpus(), sched_bind(), and sched_unbind().

Referenced by quiesce_all_cpus(), and quiesce_cpus().

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

◆ smp_no_rendezvous_barrier()

void smp_no_rendezvous_barrier ( void *  dummy)

Definition at line 893 of file subr_smp.c.

References smp_started.

Referenced by _rm_wlock(), cpus_fence_seq_cst(), rms_wlock_switch(), and vfs_op_barrier_wait().

Here is the caller graph for this function:

◆ smp_rendezvous()

void smp_rendezvous ( void(*)(void *)  setup_func,
void(*)(void *)  action_func,
void(*)(void *)  teardown_func,
void *  arg 
)

Definition at line 865 of file subr_smp.c.

References all_cpus, and smp_rendezvous_cpus().

Referenced by cpus_fence_seq_cst().

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

◆ smp_rendezvous_cpus()

void smp_rendezvous_cpus ( cpuset_t  map,
void(*)(void *)  setup_func,
void(*)(void *)  action_func,
void(*)(void *)  teardown_func,
void *  arg 
)

Definition at line 844 of file subr_smp.c.

Referenced by _rm_wlock(), smp_rendezvous(), and smp_rendezvous_cpus_retry().

Here is the caller graph for this function:

◆ smp_rendezvous_cpus_done()

void smp_rendezvous_cpus_done ( struct smp_rendezvous_cpus_retry_arg *  arg)

Definition at line 951 of file subr_smp.c.

Referenced by rms_action_func(), and vfs_op_action_func().

Here is the caller graph for this function:

◆ smp_rendezvous_cpus_retry()

void smp_rendezvous_cpus_retry ( cpuset_t  map,
void(*)(void *)  setup_func,
void(*)(void *)  action_func,
void(*)(void *)  teardown_func,
void(*)(void *, int)  wait_func,
struct smp_rendezvous_cpus_retry_arg *  arg 
)

Definition at line 901 of file subr_smp.c.

References smp_rendezvous_cpus(), and smp_started.

Referenced by rms_wlock_switch(), and vfs_op_barrier_wait().

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

◆ SYSCTL_INT() [1/7]

SYSCTL_INT ( _kern_smp  ,
OID_AUTO  ,
cores  ,
CTLFLAG_RD|  CTLFLAG_CAPRD,
mp_ncores,
,
"Number of physical cores online"   
)

◆ SYSCTL_INT() [2/7]

SYSCTL_INT ( _kern_smp  ,
OID_AUTO  ,
cpus  ,
CTLFLAG_RD|  CTLFLAG_CAPRD,
smp_cpus,
,
"Number of CPUs online"   
)

◆ SYSCTL_INT() [3/7]

SYSCTL_INT ( _kern_smp  ,
OID_AUTO  ,
disabled  ,
CTLFLAG_RDTUN|  CTLFLAG_CAPRD,
smp_disabled,
,
"SMP has been disabled from the loader"   
)

◆ SYSCTL_INT() [4/7]

SYSCTL_INT ( _kern_smp  ,
OID_AUTO  ,
maxcpus  ,
CTLFLAG_RD|  CTLFLAG_CAPRD,
mp_maxcpus,
,
"Max number of CPUs that the system was compiled for."   
)

◆ SYSCTL_INT() [5/7]

SYSCTL_INT ( _kern_smp  ,
OID_AUTO  ,
maxid  ,
CTLFLAG_RD|  CTLFLAG_CAPRD,
mp_maxid,
,
"Max CPU ID."   
)

◆ SYSCTL_INT() [6/7]

SYSCTL_INT ( _kern_smp  ,
OID_AUTO  ,
threads_per_core  ,
CTLFLAG_RD|  CTLFLAG_CAPRD,
smp_threads_per_core,
,
"Number of SMT threads online per core"   
)

◆ SYSCTL_INT() [7/7]

SYSCTL_INT ( _kern_smp  ,
OID_AUTO  ,
topology  ,
CTLFLAG_RDTUN  ,
smp_topology,
,
"Topology override setting; 0 is default provided by hardware."   
)

◆ sysctl_kern_smp_active()

static int sysctl_kern_smp_active ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1079 of file subr_smp.c.

References smp_started.

◆ SYSCTL_NODE()

static SYSCTL_NODE ( _kern  ,
OID_AUTO  ,
smp  ,
CTLFLAG_RD|CTLFLAG_CAPRD|  CTLFLAG_MPSAFE,
NULL  ,
"Kernel SMP"   
)
static

◆ SYSCTL_PROC()

SYSCTL_PROC ( _kern_smp  ,
OID_AUTO  ,
active  ,
CTLFLAG_RD|CTLTYPE_INT|  CTLFLAG_MPSAFE,
NULL  ,
,
sysctl_kern_smp_active  ,
"I"  ,
"Indicates system is running in SMP mode  
)

◆ SYSINIT()

SYSINIT ( cpu_mp_setvariables  ,
SI_SUB_TUNABLES  ,
SI_ORDER_FIRST  ,
mp_setvariables_for_up  ,
NULL   
)

Variable Documentation

◆ all_cpus

◆ mp_maxcpus

int mp_maxcpus = MAXCPU

Definition at line 74 of file subr_smp.c.

◆ mp_maxid

◆ mp_ncores

int mp_ncores = -1

Definition at line 105 of file subr_smp.c.

Referenced by mp_setvariables_for_up().

◆ mp_ncpus

◆ smp_cpus

int smp_cpus = 1

Definition at line 97 of file subr_smp.c.

Referenced by umtxq_busy().

◆ smp_disabled

int smp_disabled = 0

Definition at line 93 of file subr_smp.c.

◆ smp_started

◆ smp_threads_per_core

int smp_threads_per_core = 1

Definition at line 101 of file subr_smp.c.

◆ smp_topology

int smp_topology = 0

Definition at line 109 of file subr_smp.c.