FreeBSD kernel kern code
kern_cpuset.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/refcount.h>
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/syscallsubr.h>
#include <sys/cpuset.h>
#include <sys/sx.h>
#include <sys/queue.h>
#include <sys/libkern.h>
#include <sys/limits.h>
#include <sys/bus.h>
#include <sys/interrupt.h>
#include <vm/uma.h>
Include dependency graph for kern_cpuset.c:

Go to the source code of this file.

Data Structures

struct  cpuset_args
 
struct  cpuset_setid_args
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 SYSCTL_INT (_kern_sched, OID_AUTO, cpusetsize, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, sizeof(cpuset_t),"sizeof(cpuset_t)")
 
struct cpuset * cpuset_ref (struct cpuset *set)
 
static struct cpuset * cpuset_refroot (struct cpuset *set)
 
static struct cpuset * cpuset_refbase (struct cpuset *set)
 
void cpuset_rel (struct cpuset *set)
 
static void cpuset_rel_defer (struct setlist *head, struct cpuset *set)
 
static void cpuset_rel_complete (struct cpuset *set)
 
static struct cpuset * cpuset_lookup (cpusetid_t setid, struct thread *td)
 
static int _cpuset_create (struct cpuset *set, struct cpuset *parent, const cpuset_t *mask, cpusetid_t id)
 
static int cpuset_create (struct cpuset **setp, struct cpuset *parent, const cpuset_t *mask)
 
static int cpuset_testupdate (struct cpuset *set, cpuset_t *mask, int check_mask)
 
static void cpuset_update (struct cpuset *set, cpuset_t *mask)
 
static int cpuset_modify (struct cpuset *set, cpuset_t *mask)
 
static int cpuset_which (cpuwhich_t which, id_t id, struct proc **pp, struct thread **tdp, struct cpuset **setp)
 
static int cpuset_shadow (struct cpuset *set, struct cpuset *fset, const cpuset_t *mask)
 
static int cpuset_setproc (pid_t pid, struct cpuset *set, cpuset_t *mask)
 
int cpusetobj_ffs (const cpuset_t *set)
 
char * cpusetobj_strprint (char *buf, const cpuset_t *set)
 
int cpusetobj_strscan (cpuset_t *set, const char *buf)
 
int cpuset_setthread (lwpid_t id, cpuset_t *mask)
 
struct cpuset * cpuset_thread0 (void)
 
int cpuset_create_root (struct prison *pr, struct cpuset **setp)
 
int cpuset_setproc_update_set (struct proc *p, struct cpuset *set)
 
static void cpuset_init (void *arg)
 
 SYSINIT (cpuset, SI_SUB_SMP, SI_ORDER_ANY, cpuset_init, NULL)
 
int sys_cpuset (struct thread *td, struct cpuset_args *uap)
 
int sys_cpuset_setid (struct thread *td, struct cpuset_setid_args *uap)
 

Variables

static uma_zone_t cpuset_zone
 
static struct mtx cpuset_lock
 
static struct setlist cpuset_ids
 
static struct unrhdrcpuset_unr
 
static struct cpuset * cpuset_zero
 
cpuset_t * cpuset_root
 

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static int _cpuset_create ( struct cpuset *  set,
struct cpuset *  parent,
const cpuset_t *  mask,
cpusetid_t  id 
)
static

Definition at line 253 of file kern_cpuset.c.

References cpuset_ids, cpuset_lock, and cpuset_ref().

Referenced by cpuset_create(), cpuset_setproc(), cpuset_shadow(), and cpuset_thread0().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cpuset_create ( struct cpuset **  setp,
struct cpuset *  parent,
const cpuset_t *  mask 
)
static

Definition at line 281 of file kern_cpuset.c.

References _cpuset_create(), alloc_unr(), cpuset_zone, free_unr(), and set.

Referenced by cpuset_create_root(), and sys_cpuset().

Here is the call graph for this function:

Here is the caller graph for this function:

int cpuset_create_root ( struct prison *  pr,
struct cpuset **  setp 
)

Definition at line 794 of file kern_cpuset.c.

References cpuset_create(), and set.

Referenced by kern_jail_set().

Here is the call graph for this function:

Here is the caller graph for this function:

static void cpuset_init ( void *  arg)
static

Definition at line 837 of file kern_cpuset.c.

References all_cpus, cpuset_modify(), cpuset_zero, mask, and panic().

Here is the call graph for this function:

static struct cpuset* cpuset_lookup ( cpusetid_t  setid,
struct thread *  td 
)
static

Definition at line 216 of file kern_cpuset.c.

References cpuset_ids, cpuset_lock, cpuset_ref(), cpuset_rel(), jailed(), and set.

Referenced by cpuset_which(), and sys_cpuset_setid().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cpuset_modify ( struct cpuset *  set,
cpuset_t *  mask 
)
static

Definition at line 351 of file kern_cpuset.c.

References cpuset_lock, cpuset_testupdate(), cpuset_update(), jailed(), and priv_check().

Referenced by cpuset_init().

Here is the call graph for this function:

Here is the caller graph for this function:

struct cpuset* cpuset_ref ( struct cpuset *  set)
static struct cpuset* cpuset_refbase ( struct cpuset *  set)
static

Definition at line 150 of file kern_cpuset.c.

References cpuset_ref().

Referenced by cpuset_which().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct cpuset* cpuset_refroot ( struct cpuset *  set)
static

Definition at line 133 of file kern_cpuset.c.

References cpuset_ref().

Referenced by sys_cpuset().

Here is the call graph for this function:

Here is the caller graph for this function:

void cpuset_rel ( struct cpuset *  set)

Definition at line 164 of file kern_cpuset.c.

References cpuset_lock, cpuset_zone, and free_unr().

Referenced by cpuset_lookup(), cpuset_rel_complete(), cpuset_setproc_update_set(), cpuset_setthread(), prison_deref(), sys_cpuset(), sys_cpuset_setid(), thread_free(), and thread_wait().

Here is the call graph for this function:

Here is the caller graph for this function:

static void cpuset_rel_complete ( struct cpuset *  set)
static

Definition at line 205 of file kern_cpuset.c.

References cpuset_rel(), and cpuset_zone.

Referenced by cpuset_setproc().

Here is the call graph for this function:

Here is the caller graph for this function:

static void cpuset_rel_defer ( struct setlist *  head,
struct cpuset *  set 
)
static

Definition at line 187 of file kern_cpuset.c.

References cpuset_lock.

Referenced by cpuset_setproc().

Here is the caller graph for this function:

static int cpuset_setproc ( pid_t  pid,
struct cpuset *  set,
cpuset_t *  mask 
)
static

Definition at line 509 of file kern_cpuset.c.

References _cpuset_create(), cpuset_ref(), cpuset_rel_complete(), cpuset_rel_defer(), cpuset_shadow(), cpuset_which(), cpuset_zone, and sched_affinity().

Referenced by cpuset_setproc_update_set(), sys_cpuset(), and sys_cpuset_setid().

Here is the call graph for this function:

Here is the caller graph for this function:

int cpuset_setproc_update_set ( struct proc *  p,
struct cpuset *  set 
)

Definition at line 817 of file kern_cpuset.c.

References cpuset_ref(), cpuset_rel(), and cpuset_setproc().

Referenced by do_jail_attach().

Here is the call graph for this function:

Here is the caller graph for this function:

int cpuset_setthread ( lwpid_t  id,
cpuset_t *  mask 
)

Definition at line 707 of file kern_cpuset.c.

References cpuset_rel(), cpuset_shadow(), cpuset_which(), cpuset_zone, sched_affinity(), and set.

Referenced by intr_event_bind(), kproc_create(), and kthread_add().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cpuset_shadow ( struct cpuset *  set,
struct cpuset *  fset,
const cpuset_t *  mask 
)
static

Definition at line 482 of file kern_cpuset.c.

References _cpuset_create(), parent, and set.

Referenced by cpuset_setproc(), and cpuset_setthread().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cpuset_testupdate ( struct cpuset *  set,
cpuset_t *  mask,
int  check_mask 
)
static

Definition at line 306 of file kern_cpuset.c.

References cpuset_lock.

Referenced by cpuset_modify().

Here is the caller graph for this function:

struct cpuset* cpuset_thread0 ( void  )

Definition at line 750 of file kern_cpuset.c.

References _cpuset_create(), cpuset_ids, cpuset_lock, cpuset_zero, cpuset_zone, mtx_init(), new_unrhdr(), and set.

Referenced by proc0_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void cpuset_update ( struct cpuset *  set,
cpuset_t *  mask 
)
static

Definition at line 333 of file kern_cpuset.c.

References cpuset_lock.

Referenced by cpuset_modify().

Here is the caller graph for this function:

static int cpuset_which ( cpuwhich_t  which,
id_t  id,
struct proc **  pp,
struct thread **  tdp,
struct cpuset **  setp 
)
static

Definition at line 399 of file kern_cpuset.c.

References allprison_lock, cpuset_lookup(), cpuset_ref(), cpuset_refbase(), p_cansched(), pfind(), pr, prison_find_child(), set, and tdfind().

Referenced by cpuset_setproc(), and cpuset_setthread().

Here is the call graph for this function:

Here is the caller graph for this function:

int cpusetobj_ffs ( const cpuset_t *  set)

Definition at line 627 of file kern_cpuset.c.

char* cpusetobj_strprint ( char *  buf,
const cpuset_t *  set 
)

Definition at line 648 of file kern_cpuset.c.

References buf, and snprintf().

Referenced by sysctl_debug_ktr_cpumask().

Here is the call graph for this function:

Here is the caller graph for this function:

int cpusetobj_strscan ( cpuset_t *  set,
const char *  buf 
)

Definition at line 671 of file kern_cpuset.c.

References sscanf().

Referenced by ktr_cpumask_initializer(), and sysctl_debug_ktr_cpumask().

Here is the call graph for this function:

Here is the caller graph for this function:

int sys_cpuset ( struct thread *  td,
struct cpuset_args uap 
)

Definition at line 854 of file kern_cpuset.c.

References cpuset_create(), cpuset_refroot(), cpuset_rel(), cpuset_setproc(), set, and cpuset_args::setid.

Here is the call graph for this function:

int sys_cpuset_setid ( struct thread *  td,
struct cpuset_setid_args uap 
)

Definition at line 882 of file kern_cpuset.c.

References cpuset_lookup(), cpuset_rel(), cpuset_setproc(), cpuset_setid_args::id, set, cpuset_setid_args::setid, and cpuset_setid_args::which.

Here is the call graph for this function:

SYSCTL_INT ( _kern_sched  ,
OID_AUTO  ,
cpusetsize  ,
CTLFLAG_RD  ,
SYSCTL_NULL_INT_PTR  ,
sizeof(cpuset_t)  ,
"sizeof(cpuset_t)"   
)
SYSINIT ( cpuset  ,
SI_SUB_SMP  ,
SI_ORDER_ANY  ,
cpuset_init  ,
NULL   
)

Variable Documentation

struct setlist cpuset_ids
static

Definition at line 107 of file kern_cpuset.c.

Referenced by _cpuset_create(), cpuset_lookup(), and cpuset_thread0().

struct mtx cpuset_lock
static
cpuset_t* cpuset_root
struct unrhdr* cpuset_unr
static

Definition at line 108 of file kern_cpuset.c.

struct cpuset* cpuset_zero
static

Definition at line 109 of file kern_cpuset.c.

Referenced by cpuset_init(), and cpuset_thread0().

uma_zone_t cpuset_zone
static