Module Name: src Committed By: jmcneill Date: Sun Jun 30 17:58:08 UTC 2024
Modified Files: src/sys/arch/arm/acpi: acpi_platform.c cpu_acpi.c src/sys/arch/arm/arm: arm_cpu_topology.c Log Message: aarch64: Add NUMA awareness for ACPI systems with SRAT tables. On an Ampere Altra w/ hemisphere mode enabled: [ 1.0000000] cpu0: package 16, core 0, smt 0, numa 0 [...] [ 1.0000000] cpu32: package 22, core 0, smt 0, numa 1 [ 1.000004] SRAT: 2 NUMA nodes [ 1.000004] SRAT: node 0 memory range 0 (0x88300000 - 0x88400000 flags 1) [ 1.000004] SRAT: node 0 memory range 1 (0x90000000 - 0x100000000 flags 1) [ 1.000004] SRAT: node 0 memory range 2 (0x80000000000 - 0x80080000000 flags 1) [ 1.000004] SRAT: node 0 memory range 3 (0x80100000000 - 0x81000000000 flags 1) [ 1.000004] SRAT: node 1 memory range 0 (0xc0000000000 - 0xc1000000000 flags 1) To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/arm/acpi/acpi_platform.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/acpi/cpu_acpi.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/arm/arm_cpu_topology.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/acpi/acpi_platform.c diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.36 src/sys/arch/arm/acpi/acpi_platform.c:1.37 --- src/sys/arch/arm/acpi/acpi_platform.c:1.36 Fri Apr 7 08:55:29 2023 +++ src/sys/arch/arm/acpi/acpi_platform.c Sun Jun 30 17:58:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_platform.c,v 1.36 2023/04/07 08:55:29 skrll Exp $ */ +/* $NetBSD: acpi_platform.c,v 1.37 2024/06/30 17:58:08 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include "opt_multiprocessor.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.36 2023/04/07 08:55:29 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.37 2024/06/30 17:58:08 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -79,6 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor #include <dev/acpi/acpireg.h> #include <dev/acpi/acpivar.h> #include <arm/acpi/acpi_table.h> +#include <dev/acpi/acpi_srat.h> #include <libfdt.h> @@ -391,6 +392,14 @@ spcr_unmap: } static void +acpi_platform_device_register_post_config(device_t self, void *aux) +{ + if (device_is_a(self, "acpi")) { + acpisrat_load_uvm(); + } +} + +static void acpi_platform_reset(void) { #ifdef EFI_RUNTIME @@ -413,6 +422,7 @@ static const struct fdt_platform acpi_pl .fp_startup = acpi_platform_startup, .fp_init_attach_args = acpi_platform_init_attach_args, .fp_device_register = acpi_platform_device_register, + .fp_device_register_post_config = acpi_platform_device_register_post_config, .fp_reset = acpi_platform_reset, .fp_delay = gtmr_delay, .fp_uart_freq = acpi_platform_uart_freq, Index: src/sys/arch/arm/acpi/cpu_acpi.c diff -u src/sys/arch/arm/acpi/cpu_acpi.c:1.15 src/sys/arch/arm/acpi/cpu_acpi.c:1.16 --- src/sys/arch/arm/acpi/cpu_acpi.c:1.15 Thu May 9 12:41:08 2024 +++ src/sys/arch/arm/acpi/cpu_acpi.c Sun Jun 30 17:58:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_acpi.c,v 1.15 2024/05/09 12:41:08 pho Exp $ */ +/* $NetBSD: cpu_acpi.c,v 1.16 2024/06/30 17:58:08 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #include "opt_multiprocessor.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.15 2024/05/09 12:41:08 pho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.16 2024/06/30 17:58:08 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v #include <dev/acpi/acpireg.h> #include <dev/acpi/acpivar.h> +#include <dev/acpi/acpi_srat.h> #include <arm/armreg.h> #include <arm/cpu.h> @@ -100,6 +101,7 @@ cpu_acpi_attach(device_t parent, device_ const uint64_t mpidr = gicc->ArmMpidr; const int unit = device_unit(self); struct cpu_info *ci = &cpu_info_store[unit]; + struct acpisrat_node *node; #ifdef MULTIPROCESSOR if (cpu_mpidr_aff_read() != mpidr && (boothowto & RB_MD1) == 0) { @@ -133,6 +135,15 @@ cpu_acpi_attach(device_t parent, device_ /* Store the ACPI Processor UID in cpu_info */ ci->ci_acpiid = gicc->Uid; + /* Scan SRAT for NUMA info. */ + if (cpu_mpidr_aff_read() == mpidr) { + acpisrat_init(); + } + node = acpisrat_get_node(gicc->Uid); + if (node != NULL) { + ci->ci_numa_id = node->nodeid; + } + /* Attach the CPU */ cpu_attach(self, mpidr); Index: src/sys/arch/arm/arm/arm_cpu_topology.c diff -u src/sys/arch/arm/arm/arm_cpu_topology.c:1.6 src/sys/arch/arm/arm/arm_cpu_topology.c:1.7 --- src/sys/arch/arm/arm/arm_cpu_topology.c:1.6 Sat Dec 11 19:24:20 2021 +++ src/sys/arch/arm/arm/arm_cpu_topology.c Sun Jun 30 17:58:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_cpu_topology.c,v 1.6 2021/12/11 19:24:20 mrg Exp $ */ +/* $NetBSD: arm_cpu_topology.c,v 1.7 2024/06/30 17:58:08 jmcneill Exp $ */ /* * Copyright (c) 2020 Matthew R. Green @@ -31,7 +31,7 @@ #include "opt_multiprocessor.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: arm_cpu_topology.c,v 1.6 2021/12/11 19:24:20 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_cpu_topology.c,v 1.7 2024/06/30 17:58:08 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -48,7 +48,10 @@ void arm_cpu_topology_set(struct cpu_info * const ci, mpidr_t mpidr) { #ifdef MULTIPROCESSOR - uint pkgid, coreid, smtid, numaid = 0; + uint pkgid, coreid, smtid, numaid; + + /* NUMA info comes from firmware tables (ACPI or FDT). */ + numaid = ci->ci_numa_id; if (mpidr & MPIDR_MT) { pkgid = __SHIFTOUT(mpidr, MPIDR_AFF2);