From owner-svn-src-stable@FreeBSD.ORG Fri Jan 13 19:54:01 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E28B6106564A; Fri, 13 Jan 2012 19:54:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C1F5F8FC0C; Fri, 13 Jan 2012 19:54:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q0DJs071077733; Fri, 13 Jan 2012 19:54:00 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q0DJs0fA077731; Fri, 13 Jan 2012 19:54:00 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201201131954.q0DJs0fA077731@svn.freebsd.org> From: John Baldwin Date: Fri, 13 Jan 2012 19:54:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r230078 - stable/9/sys/x86/acpica X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 19:54:01 -0000 Author: jhb Date: Fri Jan 13 19:54:00 2012 New Revision: 230078 URL: http://svn.freebsd.org/changeset/base/230078 Log: MFC 229427: 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). Modified: stable/9/sys/x86/acpica/srat.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) Modified: stable/9/sys/x86/acpica/srat.c ============================================================================== --- stable/9/sys/x86/acpica/srat.c Fri Jan 13 19:51:15 2012 (r230077) +++ stable/9/sys/x86/acpica/srat.c Fri Jan 13 19:54:00 2012 (r230078) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include +#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 */