hwpmc/epoch - don't reference domain if NUMA is not set

It appears that domain information is set correctly independent
of whether or not NUMA is defined. However, there is no memory
backing secondary domains leading to allocation failure.

Reported by:	pho@, np@
Approved by:	sbruno@
This commit is contained in:
mmacy 2018-05-12 20:00:29 +00:00
parent 6a5d4fafb5
commit 71ab2f70a9
3 changed files with 32 additions and 9 deletions

View File

@ -61,6 +61,24 @@ __FBSDID("$FreeBSD$");
#include <sys/unistd.h>
#include <sys/vnode.h>
#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);

View File

@ -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
*/

View File

@ -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;