36#include "opt_hwpmc_hooks.h"
40#include <sys/domainset.h>
42#include <sys/malloc.h>
43#include <sys/kernel.h>
47#include <sys/pmckern.h>
49#include <sys/sysctl.h>
53#include <vm/vm_extern.h>
54#include <vm/vm_kern.h>
57FEATURE(hwpmc_hooks,
"Kernel support for HW PMC");
58#define PMC_KERNEL_VERSION PMC_VERSION
60#define PMC_KERNEL_VERSION 0
111SYSCTL_NODE(_kern, OID_AUTO, hwpmc, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
154 !CPU_ISSET(cpu, &hlt_cpus_mask));
171 return (!CPU_ABSENT(cpu));
181 return (!CPU_ISSET(cpu, &logical_cpus_mask));
208pmc_cpu_max_active(
void)
236 for ( ; *p ==
'_' ; p++)
239 if (*p ==
'_' && (*(p + 1) ==
'_' || *(p + 1) ==
'\0'))
250 static int warned = 0;
254 ps->ps_ev.pm_ev_code = 0;
270 printf(
"hwpmc: too many soft events, "
271 "increase kern.hwpmc.softevents tunable\n");
277 ps->ps_ev.pm_ev_code = PMC_EV_SOFT_FIRST + n;
291 KASSERT(ps != NULL, (
"pmc_soft_deregister: called with NULL"));
295 if (ps->ps_ev.pm_ev_code != 0 &&
297 KASSERT((
int)ps->ps_ev.pm_ev_code >= PMC_EV_SOFT_FIRST &&
298 (
int)ps->ps_ev.pm_ev_code <= PMC_EV_SOFT_LAST,
299 (
"pmc_soft_deregister: invalid event value"));
300 pmc_softs[ps->ps_ev.pm_ev_code - PMC_EV_SOFT_FIRST] = NULL;
314 KASSERT((
int)
ev >= PMC_EV_SOFT_FIRST &&
315 (
int)
ev <= PMC_EV_SOFT_LAST,
316 (
"event out of range"));
344 (void)
printf(
"hwpmc: tunable \"softevents\"=%d out of "
353 sizeof(
struct pmc_domain_buffer_header), M_PMC,
354 DOMAINSET_PREF(
domain), M_WAITOK | M_ZERO);
355 mtx_init(&
pmc_dom_hdrs[
domain]->pdbh_mtx,
"pmc_bufferlist_mtx",
"pmc-leaf", MTX_SPIN);
FEATURE(kdtrace_hooks, "Kernel DTrace hooks which are required to load DTrace kernel modules")
void *() malloc(size_t size, struct malloc_type *mtp, int flags)
void * malloc_domainset(size_t size, struct malloc_type *mtp, struct domainset *ds, int flags)
SX_SYSINIT(pmcsx, &pmc_sx, "pmc-sx")
MALLOC_DECLARE(M_PMCHOOKS)
int pmc_cpu_is_disabled(int cpu)
SYSCTL_NODE(_kern, OID_AUTO, hwpmc, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "HWPMC parameters")
void pmc_soft_ev_release(struct pmc_soft *ps)
int __read_mostly(* pmc_intr)(struct trapframe *tf)
struct trapframe pmc_tf[MAXCPU]
MALLOC_DEFINE(M_PMCHOOKS, "pmchooks", "Memory space for PMC hooks")
const int pmc_kernel_version
int __read_mostly(* pmc_hook)(struct thread *td, int function, void *arg)
volatile int pmc_ss_count
struct pmc_soft * pmc_soft_ev_acquire(enum pmc_event ev)
static void pmc_soft_namecleanup(char *name)
int pmc_cpu_is_primary(int cpu)
static void init_hwpmc(void *dummy __unused)
int pmc_cpu_is_present(int cpu)
unsigned int pmc_cpu_max(void)
void pmc_soft_ev_register(struct pmc_soft *ps)
void pmc_soft_ev_deregister(struct pmc_soft *ps)
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)
__read_mostly struct pmc_domain_buffer_header * pmc_dom_hdrs[MAXMEMDOM]
struct pmc_soft ** pmc_softs
int pmc_cpu_is_active(int cpu)
#define PMC_KERNEL_VERSION
static int pmc_softevents
SYSINIT(hwpmc, SI_SUB_KDTRACE, SI_ORDER_FIRST, init_hwpmc, NULL)
DPCPU_DEFINE(uint8_t, pmc_sampled)
struct iommu_domain ** domain
static bool kasan_enabled __read_mostly
struct pcpu * pcpu_find(u_int cpuid)
int printf(const char *fmt,...)