Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 May 2018 20:00:29 +0000 (UTC)
From:      Matt Macy <mmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r333575 - in head/sys: dev/hwpmc kern
Message-ID:  <201805122000.w4CK0TB8065122@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mmacy
Date: Sat May 12 20:00:29 2018
New Revision: 333575
URL: https://svnweb.freebsd.org/changeset/base/333575

Log:
  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@

Modified:
  head/sys/dev/hwpmc/hwpmc_logging.c
  head/sys/dev/hwpmc/hwpmc_mod.c
  head/sys/kern/subr_epoch.c

Modified: head/sys/dev/hwpmc/hwpmc_logging.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_logging.c	Sat May 12 18:07:53 2018	(r333574)
+++ head/sys/dev/hwpmc/hwpmc_logging.c	Sat May 12 20:00:29 2018	(r333575)
@@ -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);

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_mod.c	Sat May 12 18:07:53 2018	(r333574)
+++ head/sys/dev/hwpmc/hwpmc_mod.c	Sat May 12 20:00:29 2018	(r333575)
@@ -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
  */

Modified: head/sys/kern/subr_epoch.c
==============================================================================
--- head/sys/kern/subr_epoch.c	Sat May 12 18:07:53 2018	(r333574)
+++ head/sys/kern/subr_epoch.c	Sat May 12 20:00:29 2018	(r333575)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805122000.w4CK0TB8065122>