Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hwpmc/hwpmc_mod.c
Show All 30 Lines | |||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/domainset.h> | |||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <sys/gtaskqueue.h> | #include <sys/gtaskqueue.h> | ||||
#include <sys/jail.h> | #include <sys/jail.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/kthread.h> | #include <sys/kthread.h> | ||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
Show All 26 Lines | |||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <vm/vm_map.h> | #include <vm/vm_map.h> | ||||
#include <vm/vm_object.h> | #include <vm/vm_object.h> | ||||
#include "hwpmc_soft.h" | #include "hwpmc_soft.h" | ||||
#ifdef NUMA | |||||
#define NDOMAINS vm_ndomains | |||||
#else | |||||
#define NDOMAINS 1 | |||||
#define malloc_domain(size, type, domain, flags) malloc((size), (type), (flags)) | |||||
#define free_domain(addr, type) free(addr, type) | |||||
#endif | |||||
#define PMC_EPOCH_ENTER() struct epoch_tracker pmc_et; epoch_enter_preempt(global_epoch_preempt, &pmc_et) | #define PMC_EPOCH_ENTER() struct epoch_tracker pmc_et; epoch_enter_preempt(global_epoch_preempt, &pmc_et) | ||||
#define PMC_EPOCH_EXIT() epoch_exit_preempt(global_epoch_preempt, &pmc_et) | #define PMC_EPOCH_EXIT() epoch_exit_preempt(global_epoch_preempt, &pmc_et) | ||||
/* | /* | ||||
* Types | * Types | ||||
*/ | */ | ||||
enum pmc_flags { | enum pmc_flags { | ||||
▲ Show 20 Lines • Show All 5,541 Lines • ▼ Show 20 Lines | if (error) | ||||
return (error); | return (error); | ||||
/* allocate space for the sample array */ | /* allocate space for the sample array */ | ||||
for (cpu = 0; cpu < maxcpu; cpu++) { | for (cpu = 0; cpu < maxcpu; cpu++) { | ||||
if (!pmc_cpu_is_active(cpu)) | if (!pmc_cpu_is_active(cpu)) | ||||
continue; | continue; | ||||
pc = pcpu_find(cpu); | pc = pcpu_find(cpu); | ||||
domain = pc->pc_domain; | domain = pc->pc_domain; | ||||
sb = malloc_domain(sizeof(struct pmc_samplebuffer) + | sb = malloc_domainset(sizeof(struct pmc_samplebuffer) + | ||||
pmc_nsamples * sizeof(struct pmc_sample), M_PMC, domain, | pmc_nsamples * sizeof(struct pmc_sample), M_PMC, | ||||
M_WAITOK|M_ZERO); | DOMAINSET_PREF(domain), M_WAITOK | M_ZERO); | ||||
KASSERT(pmc_pcpu[cpu] != NULL, | KASSERT(pmc_pcpu[cpu] != NULL, | ||||
("[pmc,%d] cpu=%d Null per-cpu data", __LINE__, cpu)); | ("[pmc,%d] cpu=%d Null per-cpu data", __LINE__, cpu)); | ||||
sb->ps_callchains = malloc_domain(pmc_callchaindepth * pmc_nsamples * | sb->ps_callchains = malloc_domainset(pmc_callchaindepth * | ||||
sizeof(uintptr_t), M_PMC, domain, M_WAITOK|M_ZERO); | pmc_nsamples * sizeof(uintptr_t), M_PMC, | ||||
DOMAINSET_PREF(domain), M_WAITOK | M_ZERO); | |||||
for (n = 0, ps = sb->ps_samples; n < pmc_nsamples; n++, ps++) | for (n = 0, ps = sb->ps_samples; n < pmc_nsamples; n++, ps++) | ||||
ps->ps_pc = sb->ps_callchains + | ps->ps_pc = sb->ps_callchains + | ||||
(n * pmc_callchaindepth); | (n * pmc_callchaindepth); | ||||
pmc_pcpu[cpu]->pc_sb[PMC_HR] = sb; | pmc_pcpu[cpu]->pc_sb[PMC_HR] = sb; | ||||
sb = malloc_domain(sizeof(struct pmc_samplebuffer) + | sb = malloc_domainset(sizeof(struct pmc_samplebuffer) + | ||||
pmc_nsamples * sizeof(struct pmc_sample), M_PMC, domain, | pmc_nsamples * sizeof(struct pmc_sample), M_PMC, | ||||
M_WAITOK|M_ZERO); | DOMAINSET_PREF(domain), M_WAITOK | M_ZERO); | ||||
KASSERT(pmc_pcpu[cpu] != NULL, | sb->ps_callchains = malloc_domainset(pmc_callchaindepth * | ||||
("[pmc,%d] cpu=%d Null per-cpu data", __LINE__, cpu)); | pmc_nsamples * sizeof(uintptr_t), M_PMC, | ||||
DOMAINSET_PREF(domain), M_WAITOK | M_ZERO); | |||||
sb->ps_callchains = malloc_domain(pmc_callchaindepth * pmc_nsamples * | |||||
sizeof(uintptr_t), M_PMC, domain, M_WAITOK|M_ZERO); | |||||
for (n = 0, ps = sb->ps_samples; n < pmc_nsamples; n++, ps++) | for (n = 0, ps = sb->ps_samples; n < pmc_nsamples; n++, ps++) | ||||
ps->ps_pc = sb->ps_callchains + | ps->ps_pc = sb->ps_callchains + | ||||
(n * pmc_callchaindepth); | (n * pmc_callchaindepth); | ||||
pmc_pcpu[cpu]->pc_sb[PMC_SR] = sb; | pmc_pcpu[cpu]->pc_sb[PMC_SR] = sb; | ||||
sb = malloc_domain(sizeof(struct pmc_samplebuffer) + | sb = malloc_domainset(sizeof(struct pmc_samplebuffer) + | ||||
pmc_nsamples * sizeof(struct pmc_sample), M_PMC, domain, | pmc_nsamples * sizeof(struct pmc_sample), M_PMC, | ||||
M_WAITOK|M_ZERO); | DOMAINSET_PREF(domain), M_WAITOK | M_ZERO); | ||||
sb->ps_callchains = malloc_domainset(pmc_callchaindepth * | |||||
KASSERT(pmc_pcpu[cpu] != NULL, | pmc_nsamples * sizeof(uintptr_t), M_PMC, | ||||
("[pmc,%d] cpu=%d Null per-cpu data", __LINE__, cpu)); | DOMAINSET_PREF(domain), M_WAITOK | M_ZERO); | ||||
sb->ps_callchains = malloc_domain(pmc_callchaindepth * pmc_nsamples * | |||||
sizeof(uintptr_t), M_PMC, domain, M_WAITOK|M_ZERO); | |||||
for (n = 0, ps = sb->ps_samples; n < pmc_nsamples; n++, ps++) | for (n = 0, ps = sb->ps_samples; n < pmc_nsamples; n++, ps++) | ||||
ps->ps_pc = sb->ps_callchains + | ps->ps_pc = sb->ps_callchains + n * pmc_callchaindepth; | ||||
(n * pmc_callchaindepth); | |||||
pmc_pcpu[cpu]->pc_sb[PMC_UR] = sb; | pmc_pcpu[cpu]->pc_sb[PMC_UR] = sb; | ||||
} | } | ||||
/* allocate space for the row disposition array */ | /* allocate space for the row disposition array */ | ||||
pmc_pmcdisp = malloc(sizeof(enum pmc_mode) * md->pmd_npmc, | pmc_pmcdisp = malloc(sizeof(enum pmc_mode) * md->pmd_npmc, | ||||
M_PMC, M_WAITOK|M_ZERO); | M_PMC, M_WAITOK|M_ZERO); | ||||
▲ Show 20 Lines • Show All 281 Lines • Show Last 20 Lines |