FreeBSD kernel kern code
subr_devstat.c File Reference
#include <sys/cdefs.h>
#include "opt_kdtrace.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/bio.h>
#include <sys/devicestat.h>
#include <sys/sdt.h>
#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/conf.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/atomic.h>
Include dependency graph for subr_devstat.c:

Go to the source code of this file.

Data Structures

struct  statspage
 

Macros

#define DTRACE_DEVSTAT_START()   SDT_PROBE2(io, , , start, NULL, ds)
 
#define DTRACE_DEVSTAT_BIO_START()   SDT_PROBE2(io, , , start, bp, ds)
 
#define DTRACE_DEVSTAT_DONE()   SDT_PROBE2(io, , , done, NULL, ds)
 
#define DTRACE_DEVSTAT_BIO_DONE()   SDT_PROBE2(io, , , done, bp, ds)
 
#define DTRACE_DEVSTAT_WAIT_START()   SDT_PROBE2(io, , , wait__start, NULL, ds)
 
#define DTRACE_DEVSTAT_WAIT_DONE()   SDT_PROBE2(io, , , wait__done, NULL, ds)
 
#define statsperpage   (PAGE_SIZE / sizeof(struct devstat))
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 SDT_PROVIDER_DEFINE (io)
 
 SDT_PROBE_DEFINE2 (io,,, start,"struct bio *","struct devstat *")
 
 SDT_PROBE_DEFINE2 (io,,, done,"struct bio *","struct devstat *")
 
 SDT_PROBE_DEFINE2 (io,,, wait__start,"struct bio *","struct devstat *")
 
 SDT_PROBE_DEFINE2 (io,,, wait__done,"struct bio *","struct devstat *")
 
 MTX_SYSINIT (devstat_mutex,&devstat_mutex,"devstat", MTX_DEF)
 
static struct devstat * devstat_alloc (void)
 
static void devstat_free (struct devstat *)
 
static void devstat_add_entry (struct devstat *ds, const void *dev_name, int unit_number, uint32_t block_size, devstat_support_flags flags, devstat_type_flags device_type, devstat_priority priority)
 
struct devstat * devstat_new_entry (const void *dev_name, int unit_number, uint32_t block_size, devstat_support_flags flags, devstat_type_flags device_type, devstat_priority priority)
 
void devstat_remove_entry (struct devstat *ds)
 
void devstat_start_transaction (struct devstat *ds, struct bintime *now)
 
void devstat_start_transaction_bio (struct devstat *ds, struct bio *bp)
 
void devstat_end_transaction (struct devstat *ds, uint32_t bytes, devstat_tag_type tag_type, devstat_trans_flags flags, struct bintime *now, struct bintime *then)
 
void devstat_end_transaction_bio (struct devstat *ds, struct bio *bp)
 
void devstat_end_transaction_bio_bt (struct devstat *ds, struct bio *bp, struct bintime *now)
 
static int sysctl_devstat (SYSCTL_HANDLER_ARGS)
 
static SYSCTL_NODE (_kern, OID_AUTO, devstat, CTLFLAG_RD, NULL,"Device Statistics")
 
 SYSCTL_PROC (_kern_devstat, OID_AUTO, all, CTLFLAG_RD|CTLTYPE_OPAQUE, NULL, 0, sysctl_devstat,"S,devstat","All devices in the devstat list")
 
 SYSCTL_INT (_kern_devstat, OID_AUTO, numdevs, CTLFLAG_RD,&devstat_num_devs, 0,"Number of devices in the devstat list")
 
 SYSCTL_LONG (_kern_devstat, OID_AUTO, generation, CTLFLAG_RD,&devstat_generation, 0,"Devstat list generation")
 
 SYSCTL_INT (_kern_devstat, OID_AUTO, version, CTLFLAG_RD,&devstat_version, 0,"Devstat list version number")
 
static TAILQ_HEAD (statspage)
 
 SYSCTL_INT (_debug_sizeof, OID_AUTO, devstat, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, sizeof(struct devstat),"sizeof(struct devstat)")
 

Variables

static int devstat_num_devs
 
static long devstat_generation = 1
 
static int devstat_version = DEVSTAT_VERSION
 
static int devstat_current_devnumber
 
static struct mtx devstat_mutex
 
static struct devstatlist device_statq = STAILQ_HEAD_INITIALIZER(device_statq)
 
static d_mmap_t devstat_mmap
 
static struct cdevsw devstat_cdevsw
 

Macro Definition Documentation

#define DTRACE_DEVSTAT_BIO_DONE ( )    SDT_PROBE2(io, , , done, bp, ds)

Definition at line 62 of file subr_devstat.c.

Referenced by devstat_end_transaction_bio_bt().

#define DTRACE_DEVSTAT_BIO_START ( )    SDT_PROBE2(io, , , start, bp, ds)

Definition at line 60 of file subr_devstat.c.

Referenced by devstat_start_transaction_bio().

#define DTRACE_DEVSTAT_DONE ( )    SDT_PROBE2(io, , , done, NULL, ds)

Definition at line 61 of file subr_devstat.c.

Referenced by devstat_end_transaction().

#define DTRACE_DEVSTAT_START ( )    SDT_PROBE2(io, , , start, NULL, ds)

Definition at line 59 of file subr_devstat.c.

Referenced by devstat_start_transaction().

#define DTRACE_DEVSTAT_WAIT_DONE ( )    SDT_PROBE2(io, , , wait__done, NULL, ds)

Definition at line 64 of file subr_devstat.c.

#define DTRACE_DEVSTAT_WAIT_START ( )    SDT_PROBE2(io, , , wait__start, NULL, ds)

Definition at line 63 of file subr_devstat.c.

#define statsperpage   (PAGE_SIZE / sizeof(struct devstat))

Definition at line 458 of file subr_devstat.c.

Referenced by devstat_alloc(), and devstat_free().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static void devstat_add_entry ( struct devstat *  ds,
const void *  dev_name,
int  unit_number,
uint32_t  block_size,
devstat_support_flags  flags,
devstat_type_flags  device_type,
devstat_priority  priority 
)
static

Definition at line 115 of file subr_devstat.c.

References binuptime(), device_statq, devstat_current_devnumber, devstat_generation, devstat_mutex, devstat_num_devs, printf(), and priority.

Referenced by devstat_new_entry().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct devstat * devstat_alloc ( void  )
static

Definition at line 497 of file subr_devstat.c.

References devstat_cdevsw, devstat_mutex, free(), make_dev_credf(), malloc(), and statsperpage.

Referenced by devstat_new_entry().

Here is the call graph for this function:

Here is the caller graph for this function:

void devstat_end_transaction ( struct devstat *  ds,
uint32_t  bytes,
devstat_tag_type  tag_type,
devstat_trans_flags  flags,
struct bintime now,
struct bintime then 
)

Definition at line 294 of file subr_devstat.c.

References bintime(), binuptime(), and DTRACE_DEVSTAT_DONE.

Referenced by devstat_end_transaction_bio_bt().

Here is the call graph for this function:

Here is the caller graph for this function:

void devstat_end_transaction_bio ( struct devstat *  ds,
struct bio *  bp 
)

Definition at line 340 of file subr_devstat.c.

References devstat_end_transaction_bio_bt().

Referenced by biofinish().

Here is the call graph for this function:

Here is the caller graph for this function:

void devstat_end_transaction_bio_bt ( struct devstat *  ds,
struct bio *  bp,
struct bintime now 
)

Definition at line 347 of file subr_devstat.c.

References devstat_end_transaction(), and DTRACE_DEVSTAT_BIO_DONE.

Referenced by devstat_end_transaction_bio().

Here is the call graph for this function:

Here is the caller graph for this function:

static void devstat_free ( struct devstat *  dsp)
static

Definition at line 562 of file subr_devstat.c.

References devstat_mutex, and statsperpage.

Referenced by devstat_remove_entry().

Here is the caller graph for this function:

struct devstat* devstat_new_entry ( const void *  dev_name,
int  unit_number,
uint32_t  block_size,
devstat_support_flags  flags,
devstat_type_flags  device_type,
devstat_priority  priority 
)

Definition at line 86 of file subr_devstat.c.

References binuptime(), devstat_add_entry(), devstat_alloc(), devstat_generation, and devstat_mutex.

Here is the call graph for this function:

void devstat_remove_entry ( struct devstat *  ds)

Definition at line 196 of file subr_devstat.c.

References device_statq, devstat_free(), devstat_generation, devstat_mutex, and devstat_num_devs.

Here is the call graph for this function:

void devstat_start_transaction ( struct devstat *  ds,
struct bintime now 
)

Definition at line 226 of file subr_devstat.c.

References binuptime(), devstat_mutex, and DTRACE_DEVSTAT_START.

Referenced by devstat_start_transaction_bio().

Here is the call graph for this function:

Here is the caller graph for this function:

void devstat_start_transaction_bio ( struct devstat *  ds,
struct bio *  bp 
)

Definition at line 253 of file subr_devstat.c.

References binuptime(), devstat_mutex, devstat_start_transaction(), and DTRACE_DEVSTAT_BIO_START.

Here is the call graph for this function:

MTX_SYSINIT ( devstat_mutex  ,
devstat_mutex,
"devstat"  ,
MTX_DEF   
)
SDT_PROBE_DEFINE2 ( io  ,
start  ,
"struct bio *"  ,
"struct devstat *"   
)
SDT_PROBE_DEFINE2 ( io  ,
done  ,
"struct bio *"  ,
"struct devstat *"   
)
SDT_PROBE_DEFINE2 ( io  ,
wait__start  ,
"struct bio *"  ,
"struct devstat *"   
)
SDT_PROBE_DEFINE2 ( io  ,
wait__done  ,
"struct bio *"  ,
"struct devstat *"   
)
SDT_PROVIDER_DEFINE ( io  )
static int sysctl_devstat ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 381 of file subr_devstat.c.

References device_statq, devstat_generation, devstat_mutex, and devstat_num_devs.

SYSCTL_INT ( _kern_devstat  ,
OID_AUTO  ,
numdevs  ,
CTLFLAG_RD  ,
devstat_num_devs,
,
"Number of devices in the devstat list"   
)
SYSCTL_INT ( _kern_devstat  ,
OID_AUTO  ,
version  ,
CTLFLAG_RD  ,
devstat_version,
,
"Devstat list version number"   
)
SYSCTL_INT ( _debug_sizeof  ,
OID_AUTO  ,
devstat  ,
CTLFLAG_RD  ,
SYSCTL_NULL_INT_PTR  ,
sizeof(struct devstat)  ,
"sizeof(struct devstat)"   
)
SYSCTL_LONG ( _kern_devstat  ,
OID_AUTO  ,
generation  ,
CTLFLAG_RD  ,
devstat_generation,
,
"Devstat list generation"   
)
static SYSCTL_NODE ( _kern  ,
OID_AUTO  ,
devstat  ,
CTLFLAG_RD  ,
NULL  ,
"Device Statistics"   
)
static
SYSCTL_PROC ( _kern_devstat  ,
OID_AUTO  ,
all  ,
CTLFLAG_RD|  CTLTYPE_OPAQUE,
NULL  ,
,
sysctl_devstat  ,
S,
devstat"  ,
"All devices in the devstat list"   
)
static TAILQ_HEAD ( statspage  )
static

Definition at line 475 of file subr_devstat.c.

Variable Documentation

struct devstatlist device_statq = STAILQ_HEAD_INITIALIZER(device_statq)
static

Definition at line 73 of file subr_devstat.c.

Referenced by devstat_add_entry(), devstat_remove_entry(), and sysctl_devstat().

struct cdevsw devstat_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_flags = D_NEEDGIANT,
.d_mmap = devstat_mmap,
.d_name = "devstat",
}
static d_mmap_t devstat_mmap
Definition: subr_devstat.c:460

Definition at line 462 of file subr_devstat.c.

Referenced by devstat_alloc().

int devstat_current_devnumber
static

Definition at line 69 of file subr_devstat.c.

Referenced by devstat_add_entry().

long devstat_generation = 1
static
d_mmap_t devstat_mmap
static

Definition at line 460 of file subr_devstat.c.

int devstat_num_devs
static

Definition at line 66 of file subr_devstat.c.

Referenced by devstat_add_entry(), devstat_remove_entry(), and sysctl_devstat().

int devstat_version = DEVSTAT_VERSION
static

Definition at line 68 of file subr_devstat.c.