svn commit: r229427 - head/sys/x86/acpica
John Baldwin
jhb at FreeBSD.org
Tue Jan 3 20:53:59 UTC 2012
Author: jhb
Date: Tue Jan 3 20:53:58 2012
New Revision: 229427
URL: http://svn.freebsd.org/changeset/base/229427
Log:
Fix a few bugs in the SRAT parsing code:
- Actually increment ndomain when building our list of known domains
so that we can properly renumber them to be 0-based and dense.
- If the number of domains exceeds the configured maximum (VM_NDOMAIN),
bail out of processing the SRAT and disable NUMA rather than hitting an
obscure panic later.
- Don't bother parsing the SRAT at all if VM_NDOMAIN is set to 1 to
disable NUMA (the default).
Reported by: phk (2)
MFC after: 1 week
Modified:
head/sys/x86/acpica/srat.c
Modified: head/sys/x86/acpica/srat.c
==============================================================================
--- head/sys/x86/acpica/srat.c Tue Jan 3 20:53:16 2012 (r229426)
+++ head/sys/x86/acpica/srat.c Tue Jan 3 20:53:58 2012 (r229427)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <dev/acpica/acpivar.h>
+#if VM_NDOMAIN > 1
struct cpu_info {
int enabled:1;
int has_memory:1;
@@ -237,9 +238,9 @@ check_phys_avail(void)
/*
* Renumber the memory domains to be compact and zero-based if not
- * already.
+ * already. Returns an error if there are too many domains.
*/
-static void
+static int
renumber_domains(void)
{
int domains[VM_PHYSSEG_MAX];
@@ -261,6 +262,11 @@ renumber_domains(void)
for (j = ndomain; j > slot; j--)
domains[j] = domains[j - 1];
domains[slot] = mem_info[i].domain;
+ ndomain++;
+ if (ndomain > VM_NDOMAIN) {
+ printf("SRAT: Too many memory domains\n");
+ return (EFBIG);
+ }
}
/* Renumber each domain to its index in the sorted 'domains' list. */
@@ -280,6 +286,7 @@ renumber_domains(void)
if (cpus[j].enabled && cpus[j].domain == domains[i])
cpus[j].domain = i;
}
+ return (0);
}
/*
@@ -306,13 +313,12 @@ parse_srat(void *dummy)
srat_walk_table(srat_parse_entry, &error);
acpi_unmap_table(srat);
srat = NULL;
- if (error || check_domains() != 0 || check_phys_avail() != 0) {
+ if (error || check_domains() != 0 || check_phys_avail() != 0 ||
+ renumber_domains() != 0) {
srat_physaddr = 0;
return;
}
- renumber_domains();
-
/* Point vm_phys at our memory affinity table. */
mem_affinity = mem_info;
}
@@ -354,3 +360,4 @@ srat_set_cpus(void *dummy)
}
}
SYSINIT(srat_set_cpus, SI_SUB_CPU, SI_ORDER_ANY, srat_set_cpus, NULL);
+#endif /* VM_NDOMAIN > 1 */
More information about the svn-src-head
mailing list