Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Some more CPU topology stuff:
details: https://anonhg.NetBSD.org/src/rev/372850aab486
branches: trunk
changeset: 967749:372850aab486
user: ad <ad%NetBSD.org@localhost>
date: Fri Dec 20 21:05:33 2019 +0000
description:
Some more CPU topology stuff:
- Use cegger@'s ACPI SRAT parsing code to figure out NUMA node ID for each
CPU as it is attached.
- For scheduler experiments with SMT, flag CPUs with the lowest numbered SMT
IDs as "primaries", link back to the primaries from secondaries, and build
a circular list of CPUs in each package with identical SMT IDs.
- No need for package/core/smt/numa IDs to be anything other than a u_int.
diffstat:
sys/arch/aarch64/aarch64/cpu.c | 7 +-
sys/arch/aarch64/aarch64/cpufunc.c | 8 +-
sys/arch/arm/arm32/arm32_boot.c | 8 +-
sys/arch/arm/arm32/cpu.c | 8 +-
sys/arch/macppc/macppc/cpu.c | 6 +-
sys/arch/mips/mips/cpu_subr.c | 6 +-
sys/arch/x86/x86/cpu.c | 18 +++++-
sys/arch/x86/x86/cpu_topology.c | 40 ++++++++++-
sys/arch/x86/x86/identcpu.c | 7 +-
sys/kern/kern_cpu.c | 117 ++++++++++++++++++++++++------------
sys/sys/cpu.h | 5 +-
sys/sys/cpu_data.h | 13 ++-
sys/sys/sched.h | 3 +-
13 files changed, 169 insertions(+), 77 deletions(-)
diffs (truncated from 640 to 300 lines):
diff -r c6dd091eb5b0 -r 372850aab486 sys/arch/aarch64/aarch64/cpu.c
--- a/sys/arch/aarch64/aarch64/cpu.c Fri Dec 20 20:54:48 2019 +0000
+++ b/sys/arch/aarch64/aarch64/cpu.c Fri Dec 20 21:05:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.26 2019/11/22 05:21:19 mlelstv Exp $ */
+/* $NetBSD: cpu.c,v 1.27 2019/12/20 21:05:33 ad Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.26 2019/11/22 05:21:19 mlelstv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.27 2019/12/20 21:05:33 ad Exp $");
#include "locators.h"
#include "opt_arm_debug.h"
@@ -230,8 +230,7 @@
aprint_naive("\n");
aprint_normal(": %s\n", model);
- aprint_normal_dev(ci->ci_dev, "package %lu, core %lu, smt %lu\n",
- ci->ci_package_id, ci->ci_core_id, ci->ci_smt_id);
+ cpu_topology_print(ci);
}
static void
diff -r c6dd091eb5b0 -r 372850aab486 sys/arch/aarch64/aarch64/cpufunc.c
--- a/sys/arch/aarch64/aarch64/cpufunc.c Fri Dec 20 20:54:48 2019 +0000
+++ b/sys/arch/aarch64/aarch64/cpufunc.c Fri Dec 20 21:05:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.c,v 1.11 2019/12/05 05:45:52 ryo Exp $ */
+/* $NetBSD: cpufunc.c,v 1.12 2019/12/20 21:05:33 ad Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -29,7 +29,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.11 2019/12/05 05:45:52 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.12 2019/12/20 21:05:33 ad Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -96,11 +96,13 @@
cpu_topology_set(ci,
__SHIFTOUT(mpidr, MPIDR_AFF2),
__SHIFTOUT(mpidr, MPIDR_AFF1),
- __SHIFTOUT(mpidr, MPIDR_AFF0));
+ __SHIFTOUT(mpidr, MPIDR_AFF0),
+ 0);
} else {
cpu_topology_set(ci,
__SHIFTOUT(mpidr, MPIDR_AFF1),
__SHIFTOUT(mpidr, MPIDR_AFF0),
+ 0,
0);
}
}
diff -r c6dd091eb5b0 -r 372850aab486 sys/arch/arm/arm32/arm32_boot.c
--- a/sys/arch/arm/arm32/arm32_boot.c Fri Dec 20 20:54:48 2019 +0000
+++ b/sys/arch/arm/arm32/arm32_boot.c Fri Dec 20 21:05:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm32_boot.c,v 1.34 2019/12/02 23:22:43 ad Exp $ */
+/* $NetBSD: arm32_boot.c,v 1.35 2019/12/20 21:05:33 ad Exp $ */
/*
* Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
@@ -122,7 +122,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.34 2019/12/02 23:22:43 ad Exp $");
+__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.35 2019/12/20 21:05:33 ad Exp $");
#include "opt_arm_debug.h"
#include "opt_cputypes.h"
@@ -361,11 +361,13 @@
cpu_topology_set(ci,
__SHIFTOUT(mpidr, MPIDR_AFF2),
__SHIFTOUT(mpidr, MPIDR_AFF1),
- __SHIFTOUT(mpidr, MPIDR_AFF0));
+ __SHIFTOUT(mpidr, MPIDR_AFF0),
+ 0);
} else {
cpu_topology_set(ci,
__SHIFTOUT(mpidr, MPIDR_AFF1),
__SHIFTOUT(mpidr, MPIDR_AFF0),
+ 0,
0);
}
diff -r c6dd091eb5b0 -r 372850aab486 sys/arch/arm/arm32/cpu.c
--- a/sys/arch/arm/arm32/cpu.c Fri Dec 20 20:54:48 2019 +0000
+++ b/sys/arch/arm/arm32/cpu.c Fri Dec 20 21:05:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.135 2019/12/02 23:22:43 ad Exp $ */
+/* $NetBSD: cpu.c,v 1.136 2019/12/20 21:05:33 ad Exp $ */
/*
* Copyright (c) 1995 Mark Brinicombe.
@@ -46,7 +46,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.135 2019/12/02 23:22:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.136 2019/12/20 21:05:33 ad Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -114,11 +114,13 @@
cpu_topology_set(ci,
__SHIFTOUT(mpidr, MPIDR_AFF2),
__SHIFTOUT(mpidr, MPIDR_AFF1),
- __SHIFTOUT(mpidr, MPIDR_AFF0));
+ __SHIFTOUT(mpidr, MPIDR_AFF0),
+ 0);
} else {
cpu_topology_set(ci,
__SHIFTOUT(mpidr, MPIDR_AFF1),
__SHIFTOUT(mpidr, MPIDR_AFF0),
+ 0,
0);
}
#endif
diff -r c6dd091eb5b0 -r 372850aab486 sys/arch/macppc/macppc/cpu.c
--- a/sys/arch/macppc/macppc/cpu.c Fri Dec 20 20:54:48 2019 +0000
+++ b/sys/arch/macppc/macppc/cpu.c Fri Dec 20 21:05:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.68 2019/12/13 23:01:41 macallan Exp $ */
+/* $NetBSD: cpu.c,v 1.69 2019/12/20 21:05:33 ad Exp $ */
/*-
* Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.68 2019/12/13 23:01:41 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.69 2019/12/20 21:05:33 ad Exp $");
#include "opt_ppcparam.h"
#include "opt_multiprocessor.h"
@@ -175,7 +175,7 @@
core = package & 1;
package >>= 1;
}
- cpu_topology_set(ci, package, core, 0);
+ cpu_topology_set(ci, package, core, 0, 0);
if (ci->ci_khz == 0) {
cpu_OFgetspeed(self, ci);
diff -r c6dd091eb5b0 -r 372850aab486 sys/arch/mips/mips/cpu_subr.c
--- a/sys/arch/mips/mips/cpu_subr.c Fri Dec 20 20:54:48 2019 +0000
+++ b/sys/arch/mips/mips/cpu_subr.c Fri Dec 20 21:05:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_subr.c,v 1.40 2019/12/03 15:20:59 riastradh Exp $ */
+/* $NetBSD: cpu_subr.c,v 1.41 2019/12/20 21:05:33 ad Exp $ */
/*-
* Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.40 2019/12/03 15:20:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.41 2019/12/20 21:05:33 ad Exp $");
#include "opt_cputype.h"
#include "opt_ddb.h"
@@ -189,7 +189,7 @@
ci->ci_divisor_recip = cpu_info_store.ci_divisor_recip;
ci->ci_cpuwatch_count = cpu_info_store.ci_cpuwatch_count;
- cpu_topology_set(ci, cpu_package_id, cpu_core_id, cpu_smt_id);
+ cpu_topology_set(ci, cpu_package_id, cpu_core_id, cpu_smt_id, 0);
pmap_md_alloc_ephemeral_address_space(ci);
diff -r c6dd091eb5b0 -r 372850aab486 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c Fri Dec 20 20:54:48 2019 +0000
+++ b/sys/arch/x86/x86/cpu.c Fri Dec 20 21:05:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.178 2019/12/07 11:45:45 nonaka Exp $ */
+/* $NetBSD: cpu.c,v 1.179 2019/12/20 21:05:34 ad Exp $ */
/*
* Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.178 2019/12/07 11:45:45 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.179 2019/12/20 21:05:34 ad Exp $");
#include "opt_ddb.h"
#include "opt_mpbios.h" /* for MPDEBUG */
@@ -72,6 +72,7 @@
#include "lapic.h"
#include "ioapic.h"
+#include "acpica.h"
#include <sys/param.h>
#include <sys/proc.h>
@@ -106,6 +107,10 @@
#include <x86/fpu.h>
+#if NACPICA > 0
+#include <dev/acpi/acpi_srat.h>
+#endif
+
#if NLAPIC > 0
#include <machine/apicvar.h>
#include <machine/i82489reg.h>
@@ -404,6 +409,10 @@
cpu_init_tss(ci);
} else {
KASSERT(ci->ci_data.cpu_idlelwp != NULL);
+#if NACPICA > 0
+ /* Parse out NUMA info for cpu_identify(). */
+ acpisrat_init();
+#endif
}
#ifdef SVS
@@ -706,6 +715,11 @@
x86_patch(false);
#endif
+#if NACPICA > 0
+ /* Finished with NUMA info for now. */
+ acpisrat_exit();
+#endif
+
kcpuset_create(&cpus, true);
kcpuset_set(cpus, cpu_index(curcpu()));
for (i = 0; i < maxcpus; i++) {
diff -r c6dd091eb5b0 -r 372850aab486 sys/arch/x86/x86/cpu_topology.c
--- a/sys/arch/x86/x86/cpu_topology.c Fri Dec 20 20:54:48 2019 +0000
+++ b/sys/arch/x86/x86/cpu_topology.c Fri Dec 20 21:05:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_topology.c,v 1.15 2019/12/02 23:22:43 ad Exp $ */
+/* $NetBSD: cpu_topology.c,v 1.16 2019/12/20 21:05:34 ad Exp $ */
/*-
* Copyright (c) 2009 Mindaugas Rasiukevicius <rmind at NetBSD org>,
@@ -36,7 +36,9 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.15 2019/12/02 23:22:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.16 2019/12/20 21:05:34 ad Exp $");
+
+#include "acpica.h"
#include <sys/param.h>
#include <sys/bitops.h>
@@ -44,10 +46,33 @@
#include <machine/specialreg.h>
+#include <dev/acpi/acpi_srat.h>
+
#include <x86/cpufunc.h>
#include <x86/cputypes.h>
#include <x86/cpuvar.h>
+static uint32_t
+x86_cpu_get_numa_node(uint32_t apic_id)
+{
+#if NACPICA > 0
+ uint32_t i, j, nn, nc;
+ struct acpisrat_cpu c;
+
+ nn = acpisrat_nodes();
+ for (i = 0; i < nn; i++) {
+ nc = acpisrat_node_cpus(i);
+ for (j = 0; j < nc; j++) {
+ acpisrat_cpu(i, j, &c);
+ if (c.apicid == apic_id) {
+ return c.nodeid;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
void
x86_cpu_topology(struct cpu_info *ci)
{
@@ -55,7 +80,7 @@
u_int core_max; /* Core per package */
int n, cpu_family, apic_id, smt_bits, core_bits = 0;
uint32_t descs[4];
- int package_id, core_id, smt_id;
Home |
Main Index |
Thread Index |
Old Index