FreeBSD kernel kern code
subr_unit.c File Reference
#include <sys/param.h>
#include <sys/types.h>
#include <sys/_unrhdr.h>
#include <sys/bitstring.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
Include dependency graph for subr_unit.c:

Go to the source code of this file.

Data Structures

struct  unr
 
struct  unrb
 

Macros

#define Malloc(foo)   malloc(foo, M_UNIT, M_WAITOK | M_ZERO)
 
#define Free(foo)   free(foo, M_UNIT)
 
#define NBITS   (8 * sizeof(((struct unrb*)NULL)->map))
 

Functions

static MALLOC_DEFINE (M_UNIT, "Unitno", "Unit number allocation")
 
 MTX_SYSINIT (unit, &unitmtx, "unit# allocation", MTX_DEF)
 
 CTASSERT ((sizeof(struct unr) % sizeof(bitstr_t))==0)
 
static bool ub_empty (struct unrb *ub, int len)
 
static bool ub_full (struct unrb *ub, int len)
 
static __inline void check_unrhdr (struct unrhdr *uh __unused, int line __unused)
 
static __inline void * new_unr (struct unrhdr *uh, void **p1, void **p2)
 
static __inline void delete_unr (struct unrhdr *uh, void *ptr)
 
void clean_unrhdrl (struct unrhdr *uh)
 
void clean_unrhdr (struct unrhdr *uh)
 
void init_unrhdr (struct unrhdr *uh, int low, int high, struct mtx *mutex)
 
struct unrhdr * new_unrhdr (int low, int high, struct mtx *mutex)
 
void delete_unrhdr (struct unrhdr *uh)
 
void clear_unrhdr (struct unrhdr *uh)
 
static __inline int is_bitmap (struct unrhdr *uh, struct unr *up)
 
static int optimize_unr (struct unrhdr *uh)
 
static void collapse_unr (struct unrhdr *uh, struct unr *up)
 
int alloc_unrl (struct unrhdr *uh)
 
int alloc_unr (struct unrhdr *uh)
 
static int alloc_unr_specificl (struct unrhdr *uh, u_int item, void **p1, void **p2)
 
int alloc_unr_specific (struct unrhdr *uh, u_int item)
 
static void free_unrl (struct unrhdr *uh, u_int item, void **p1, void **p2)
 
void free_unr (struct unrhdr *uh, u_int item)
 

Variables

static struct mtx unitmtx
 

Macro Definition Documentation

◆ Free

#define Free (   foo)    free(foo, M_UNIT)

Definition at line 95 of file subr_unit.c.

◆ Malloc

#define Malloc (   foo)    malloc(foo, M_UNIT, M_WAITOK | M_ZERO)

Definition at line 94 of file subr_unit.c.

◆ NBITS

#define NBITS   (8 * sizeof(((struct unrb*)NULL)->map))

Definition at line 206 of file subr_unit.c.

Function Documentation

◆ alloc_unr()

int alloc_unr ( struct unrhdr *  uh)

Definition at line 650 of file subr_unit.c.

References alloc_unrl(), and clean_unrhdrl().

Referenced by aio_newproc(), cpuset_create(), mqfs_fileno_alloc(), pts_alloc(), and soaio_kproc_create().

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

◆ alloc_unr_specific()

int alloc_unr_specific ( struct unrhdr *  uh,
u_int  item 
)

Definition at line 764 of file subr_unit.c.

References alloc_unr_specificl(), Free, and Malloc.

Here is the call graph for this function:

◆ alloc_unr_specificl()

static int alloc_unr_specificl ( struct unrhdr *  uh,
u_int  item,
void **  p1,
void **  p2 
)
static

Definition at line 662 of file subr_unit.c.

References check_unrhdr(), collapse_unr(), is_bitmap(), unrb::map, and new_unr().

Referenced by alloc_unr_specific().

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

◆ alloc_unrl()

int alloc_unrl ( struct unrhdr *  uh)

Definition at line 602 of file subr_unit.c.

References check_unrhdr(), collapse_unr(), and unrb::map.

Referenced by alloc_unr().

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

◆ check_unrhdr()

static __inline void check_unrhdr ( struct unrhdr *uh  __unused,
int line  __unused 
)
static

Definition at line 270 of file subr_unit.c.

Referenced by alloc_unr_specificl(), alloc_unrl(), clear_unrhdr(), delete_unrhdr(), free_unrl(), and init_unrhdr().

Here is the caller graph for this function:

◆ clean_unrhdr()

void clean_unrhdr ( struct unrhdr *  uh)

Definition at line 326 of file subr_unit.c.

References clean_unrhdrl().

Here is the call graph for this function:

◆ clean_unrhdrl()

void clean_unrhdrl ( struct unrhdr *  uh)

Definition at line 311 of file subr_unit.c.

References Free.

Referenced by alloc_unr(), clean_unrhdr(), free_unr(), make_dev_alias_v(), and make_dev_sv().

Here is the caller graph for this function:

◆ clear_unrhdr()

void clear_unrhdr ( struct unrhdr *  uh)

Definition at line 382 of file subr_unit.c.

References check_unrhdr(), Free, and init_unrhdr().

Here is the call graph for this function:

◆ collapse_unr()

static void collapse_unr ( struct unrhdr *  uh,
struct unr up 
)
static

Definition at line 530 of file subr_unit.c.

References delete_unr(), is_bitmap(), optimize_unr(), ub_empty(), and ub_full().

Referenced by alloc_unr_specificl(), alloc_unrl(), and free_unrl().

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

◆ CTASSERT()

CTASSERT ( (sizeof(struct unr) % sizeof(bitstr_t))  = =0)

◆ delete_unr()

static __inline void delete_unr ( struct unrhdr *  uh,
void *  ptr 
)
static

Definition at line 301 of file subr_unit.c.

Referenced by collapse_unr(), and optimize_unr().

Here is the caller graph for this function:

◆ delete_unrhdr()

void delete_unrhdr ( struct unrhdr *  uh)

Definition at line 370 of file subr_unit.c.

References check_unrhdr(), and Free.

Referenced by mqfs_fileno_uninit().

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

◆ free_unr()

void free_unr ( struct unrhdr *  uh,
u_int  item 
)

Definition at line 900 of file subr_unit.c.

References clean_unrhdrl(), Free, free_unrl(), and Malloc.

Referenced by aio_daemon(), aio_newproc(), cpuset_create(), cpuset_rel(), cpuset_rel_complete(), mqfs_fileno_free(), ptsdrv_free(), and soaio_kproc_create().

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

◆ free_unrl()

static void free_unrl ( struct unrhdr *  uh,
u_int  item,
void **  p1,
void **  p2 
)
static

Definition at line 792 of file subr_unit.c.

References check_unrhdr(), collapse_unr(), is_bitmap(), unrb::map, and new_unr().

Referenced by free_unr().

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

◆ init_unrhdr()

void init_unrhdr ( struct unrhdr *  uh,
int  low,
int  high,
struct mtx mutex 
)

Definition at line 335 of file subr_unit.c.

References check_unrhdr(), and unitmtx.

Referenced by clear_unrhdr(), and new_unrhdr().

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

◆ is_bitmap()

static __inline int is_bitmap ( struct unrhdr *  uh,
struct unr up 
)
static

Definition at line 402 of file subr_unit.c.

Referenced by alloc_unr_specificl(), collapse_unr(), free_unrl(), and optimize_unr().

Here is the caller graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_UNIT  ,
"Unitno"  ,
"Unit number allocation"   
)
static

◆ MTX_SYSINIT()

MTX_SYSINIT ( unit  ,
unitmtx,
"unit# allocation"  ,
MTX_DEF   
)

◆ new_unr()

static __inline void * new_unr ( struct unrhdr *  uh,
void **  p1,
void **  p2 
)
static

Definition at line 283 of file subr_unit.c.

Referenced by alloc_unr_specificl(), and free_unrl().

Here is the caller graph for this function:

◆ new_unrhdr()

struct unrhdr * new_unrhdr ( int  low,
int  high,
struct mtx mutex 
)

Definition at line 360 of file subr_unit.c.

References init_unrhdr(), and Malloc.

Referenced by aio_onceonly(), cpuset_thread0(), mqfs_fileno_init(), pts_init(), and soaio_init().

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

◆ optimize_unr()

static int optimize_unr ( struct unrhdr *  uh)
static

Definition at line 417 of file subr_unit.c.

References delete_unr(), is_bitmap(), unrb::map, and NBITS.

Referenced by collapse_unr().

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

◆ ub_empty()

static bool ub_empty ( struct unrb ub,
int  len 
)
inlinestatic

Definition at line 210 of file subr_unit.c.

References unrb::map.

Referenced by collapse_unr().

Here is the caller graph for this function:

◆ ub_full()

static bool ub_full ( struct unrb ub,
int  len 
)
inlinestatic

Definition at line 219 of file subr_unit.c.

References unrb::map.

Referenced by collapse_unr().

Here is the caller graph for this function:

Variable Documentation

◆ unitmtx

struct mtx unitmtx
static

Definition at line 97 of file subr_unit.c.

Referenced by init_unrhdr().