From 01a8235ea61ced963f1e368405cc6d71c0c33bd0 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Thu, 28 Feb 2019 14:40:43 +0000 Subject: [PATCH] Add the hw.ncpu tunable to arm64. This allows us to limit the number of CPUs to use, e.g. to debug problems seen when enabling multiple clusters. Reviewed by: manu Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D19404 --- sys/arm64/arm64/mp_machdep.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index b887aed3d19..b2df286ee48 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -638,9 +638,10 @@ cpu_find_cpu0_fdt(u_int id, phandle_t node, u_int addr_size, pcell_t *reg) void cpu_mp_setmaxid(void) { -#if defined(DEV_ACPI) || defined(FDT) int cores; -#endif + + mp_ncpus = 1; + mp_maxid = 0; switch(arm64_bus_method) { #ifdef DEV_ACPI @@ -653,7 +654,6 @@ cpu_mp_setmaxid(void) cores); mp_ncpus = cores; mp_maxid = cores - 1; - return; } break; #endif @@ -667,18 +667,21 @@ cpu_mp_setmaxid(void) cores); mp_ncpus = cores; mp_maxid = cores - 1; - return; } break; #endif default: + if (bootverbose) + printf("No CPU data, limiting to 1 core\n"); break; } - if (bootverbose) - printf("No CPU data, limiting to 1 core\n"); - mp_ncpus = 1; - mp_maxid = 0; + if (TUNABLE_INT_FETCH("hw.ncpu", &cores)) { + if (cores > 0 && cores < mp_ncpus) { + mp_ncpus = cores; + mp_maxid = cores - 1; + } + } } /*