diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c index 4d30b2ca7409..ce6f44afaf80 100644 --- a/sys/dev/hwpmc/hwpmc_logging.c +++ b/sys/dev/hwpmc/hwpmc_logging.c @@ -61,6 +61,24 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef NUMA +#define NDOMAINS vm_ndomains + +static int +getdomain(int cpu) +{ + struct pcpu *pc; + + pc = pcpu_find(cpu); + return (pc->pc_domain); +} +#else +#define NDOMAINS 1 +#define malloc_domain(size, type, domain, flags) malloc((size), (type), (flags)) +#define free_domain(addr, type) free(addr, type) +#define getdomain(cpu) 0 +#endif + /* * Sysctl tunables */ @@ -1148,7 +1166,6 @@ void pmclog_initialize() { int domain, cpu; - struct pcpu *pc; struct pmclog_buffer *plb; if (pmclog_buffer_size <= 0 || pmclog_buffer_size > 16*1024) { @@ -1170,20 +1187,18 @@ pmclog_initialize() pmc_nlogbuffers_pcpu = PMC_NLOGBUFFERS_PCPU; pmclog_buffer_size = PMC_LOG_BUFFER_SIZE; } - for (domain = 0; domain < vm_ndomains; domain++) { + for (domain = 0; domain < NDOMAINS; domain++) { pmc_dom_hdrs[domain] = malloc_domain(sizeof(struct pmc_domain_buffer_header), M_PMC, domain, M_WAITOK|M_ZERO); mtx_init(&pmc_dom_hdrs[domain]->pdbh_mtx, "pmc_bufferlist_mtx", "pmc-leaf", MTX_SPIN); TAILQ_INIT(&pmc_dom_hdrs[domain]->pdbh_head); } CPU_FOREACH(cpu) { - if (CPU_ABSENT(cpu)) - continue; - pc = pcpu_find(cpu); - domain = pc->pc_domain; + domain = getdomain(cpu); + KASSERT(pmc_dom_hdrs[domain] != NULL, ("no mem allocated for domain: %d", domain)); pmc_dom_hdrs[domain]->pdbh_ncpus++; } - for (domain = 0; domain < vm_ndomains; domain++) { + for (domain = 0; domain < NDOMAINS; domain++) { int ncpus = pmc_dom_hdrs[domain]->pdbh_ncpus; int total = ncpus*pmc_nlogbuffers_pcpu; @@ -1215,7 +1230,7 @@ pmclog_shutdown() mtx_destroy(&pmc_kthread_mtx); - for (domain = 0; domain < vm_ndomains; domain++) { + for (domain = 0; domain < NDOMAINS; domain++) { mtx_destroy(&pmc_dom_hdrs[domain]->pdbh_mtx); while ((plb = TAILQ_FIRST(&pmc_dom_hdrs[domain]->pdbh_head)) != NULL) { TAILQ_REMOVE(&pmc_dom_hdrs[domain]->pdbh_head, plb, plb_next); diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 8b7a9a7d6a44..18118e8157b9 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -76,6 +76,14 @@ __FBSDID("$FreeBSD$"); #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 + /* * Types */ diff --git a/sys/kern/subr_epoch.c b/sys/kern/subr_epoch.c index 7e5e83bf9473..a1f0b2c8e79f 100644 --- a/sys/kern/subr_epoch.c +++ b/sys/kern/subr_epoch.c @@ -119,7 +119,7 @@ static __read_mostly int inited; static void epoch_call_task(void *context); -#if defined(__powerpc64__) || defined(__powerpc__) +#if defined(__powerpc64__) || defined(__powerpc__) || !defined(NUMA) static bool usedomains = false; #else static bool usedomains = true;