FreeBSD kernel kern code
kern_pmc.c File Reference
#include <sys/cdefs.h>
#include "opt_hwpmc_hooks.h"
#include <sys/param.h>
#include <sys/ctype.h>
#include <sys/domainset.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/pmc.h>
#include <sys/pmckern.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>
Include dependency graph for kern_pmc.c:

Go to the source code of this file.

Macros

#define PMC_KERNEL_VERSION   0
 

Functions

 __FBSDID ("$FreeBSD$")
 
 MALLOC_DECLARE (M_PMCHOOKS)
 
 MALLOC_DEFINE (M_PMCHOOKS, "pmchooks", "Memory space for PMC hooks")
 
 MALLOC_DEFINE (M_PMC, "pmc", "Memory space for the PMC module")
 
 DPCPU_DEFINE (uint8_t, pmc_sampled)
 
 SX_SYSINIT (pmcsx, &pmc_sx, "pmc-sx")
 
 SYSCTL_NODE (_kern, OID_AUTO, hwpmc, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "HWPMC parameters")
 
 SYSCTL_INT (_kern_hwpmc, OID_AUTO, softevents, CTLFLAG_RDTUN, &pmc_softevents, 0, "maximum number of soft events")
 
 MTX_SYSINIT (pmc_soft_mtx, &pmc_softs_mtx, "pmc-softs", MTX_SPIN)
 
int pmc_cpu_is_active (int cpu)
 
int pmc_cpu_is_disabled (int cpu)
 
int pmc_cpu_is_present (int cpu)
 
int pmc_cpu_is_primary (int cpu)
 
unsigned int pmc_cpu_max (void)
 
static void pmc_soft_namecleanup (char *name)
 
void pmc_soft_ev_register (struct pmc_soft *ps)
 
void pmc_soft_ev_deregister (struct pmc_soft *ps)
 
struct pmc_soft * pmc_soft_ev_acquire (enum pmc_event ev)
 
void pmc_soft_ev_release (struct pmc_soft *ps)
 
static void init_hwpmc (void *dummy __unused)
 
 SYSINIT (hwpmc, SI_SUB_KDTRACE, SI_ORDER_FIRST, init_hwpmc, NULL)
 

Variables

const int pmc_kernel_version = PMC_KERNEL_VERSION
 
int __read_mostly(* pmc_hook )(struct thread *td, int function, void *arg) = NULL
 
int __read_mostly(* pmc_intr )(struct trapframe *tf) = NULL
 
volatile int pmc_ss_count
 
struct sx pmc_sx
 
struct trapframe pmc_tf [MAXCPU]
 
__read_mostly struct pmc_domain_buffer_header * pmc_dom_hdrs [MAXMEMDOM]
 
static int pmc_softevents = 16
 
int pmc_softs_count
 
struct pmc_soft ** pmc_softs
 
struct mtx pmc_softs_mtx
 

Macro Definition Documentation

◆ PMC_KERNEL_VERSION

#define PMC_KERNEL_VERSION   0

Definition at line 60 of file kern_pmc.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DPCPU_DEFINE()

DPCPU_DEFINE ( uint8_t  ,
pmc_sampled   
)

◆ init_hwpmc()

static void init_hwpmc ( void *dummy  __unused)
static

Definition at line 338 of file kern_pmc.c.

References domain, malloc(), malloc_domainset(), pcpu_find(), pmc_dom_hdrs, pmc_softevents, pmc_softs, and printf().

Here is the call graph for this function:

◆ MALLOC_DECLARE()

MALLOC_DECLARE ( M_PMCHOOKS  )

◆ MALLOC_DEFINE() [1/2]

MALLOC_DEFINE ( M_PMC  ,
"pmc"  ,
"Memory space for the PMC module  
)

◆ MALLOC_DEFINE() [2/2]

MALLOC_DEFINE ( M_PMCHOOKS  ,
"pmchooks"  ,
"Memory space for PMC hooks"   
)

◆ MTX_SYSINIT()

MTX_SYSINIT ( pmc_soft_mtx  ,
pmc_softs_mtx,
"pmc-softs"  ,
MTX_SPIN   
)

◆ pmc_cpu_is_active()

int pmc_cpu_is_active ( int  cpu)

Definition at line 150 of file kern_pmc.c.

References pmc_cpu_is_present().

Referenced by pmc_cpu_is_disabled().

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

◆ pmc_cpu_is_disabled()

int pmc_cpu_is_disabled ( int  cpu)

Definition at line 162 of file kern_pmc.c.

References pmc_cpu_is_active().

Here is the call graph for this function:

◆ pmc_cpu_is_present()

int pmc_cpu_is_present ( int  cpu)

Definition at line 168 of file kern_pmc.c.

Referenced by pmc_cpu_is_active().

Here is the caller graph for this function:

◆ pmc_cpu_is_primary()

int pmc_cpu_is_primary ( int  cpu)

Definition at line 178 of file kern_pmc.c.

◆ pmc_cpu_max()

unsigned int pmc_cpu_max ( void  )

Definition at line 193 of file kern_pmc.c.

References mp_maxid.

◆ pmc_soft_ev_acquire()

struct pmc_soft * pmc_soft_ev_acquire ( enum pmc_event  ev)

Definition at line 307 of file kern_pmc.c.

References ev, pmc_softevents, pmc_softs, and pmc_softs_mtx.

◆ pmc_soft_ev_deregister()

void pmc_soft_ev_deregister ( struct pmc_soft *  ps)

Definition at line 288 of file kern_pmc.c.

References pmc_softevents, pmc_softs, and pmc_softs_mtx.

◆ pmc_soft_ev_register()

void pmc_soft_ev_register ( struct pmc_soft *  ps)

Definition at line 248 of file kern_pmc.c.

References pmc_soft_namecleanup(), pmc_softevents, pmc_softs, pmc_softs_count, pmc_softs_mtx, and printf().

Here is the call graph for this function:

◆ pmc_soft_ev_release()

void pmc_soft_ev_release ( struct pmc_soft *  ps)

Definition at line 328 of file kern_pmc.c.

References pmc_softs_mtx.

◆ pmc_soft_namecleanup()

static void pmc_soft_namecleanup ( char *  name)
static

Definition at line 230 of file kern_pmc.c.

References name.

Referenced by pmc_soft_ev_register().

Here is the caller graph for this function:

◆ SX_SYSINIT()

SX_SYSINIT ( pmcsx  ,
pmc_sx,
"pmc-sx"   
)

◆ SYSCTL_INT()

SYSCTL_INT ( _kern_hwpmc  ,
OID_AUTO  ,
softevents  ,
CTLFLAG_RDTUN  ,
pmc_softevents,
,
"maximum number of soft events"   
)

◆ SYSCTL_NODE()

SYSCTL_NODE ( _kern  ,
OID_AUTO  ,
hwpmc  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
"HWPMC parameters"   
)

◆ SYSINIT()

SYSINIT ( hwpmc  ,
SI_SUB_KDTRACE  ,
SI_ORDER_FIRST  ,
init_hwpmc  ,
NULL   
)

Variable Documentation

◆ pmc_dom_hdrs

__read_mostly struct pmc_domain_buffer_header* pmc_dom_hdrs[MAXMEMDOM]

Definition at line 105 of file kern_pmc.c.

Referenced by init_hwpmc().

◆ pmc_hook

int __read_mostly(* pmc_hook) (struct thread *td, int function, void *arg) ( struct thread *  td,
int  function,
void *  arg 
) = NULL

Definition at line 72 of file kern_pmc.c.

Referenced by intr_irq_handler().

◆ pmc_intr

int __read_mostly(* pmc_intr) (struct trapframe *tf) ( struct trapframe *  tf) = NULL

Definition at line 75 of file kern_pmc.c.

◆ pmc_kernel_version

const int pmc_kernel_version = PMC_KERNEL_VERSION

Definition at line 69 of file kern_pmc.c.

◆ pmc_softevents

int pmc_softevents = 16
static

◆ pmc_softs

struct pmc_soft** pmc_softs

◆ pmc_softs_count

int pmc_softs_count

Definition at line 118 of file kern_pmc.c.

Referenced by pmc_soft_ev_register().

◆ pmc_softs_mtx

struct mtx pmc_softs_mtx

◆ pmc_ss_count

volatile int pmc_ss_count

Definition at line 83 of file kern_pmc.c.

◆ pmc_sx

struct sx pmc_sx

Definition at line 94 of file kern_pmc.c.

◆ pmc_tf

struct trapframe pmc_tf[MAXCPU]

Definition at line 100 of file kern_pmc.c.