git: 5720b8de4832 - main - riscv: Add an hw.ncpu tunable to limit the number of cores
Jessica Clarke
jrtc27 at FreeBSD.org
Tue Jun 15 00:23:37 UTC 2021
The branch main has been updated by jrtc27:
URL: https://cgit.FreeBSD.org/src/commit/?id=5720b8de4832da70e76b9a72c679d0b168d7834e
commit 5720b8de4832da70e76b9a72c679d0b168d7834e
Author: Jessica Clarke <jrtc27 at FreeBSD.org>
AuthorDate: 2021-06-15 00:21:38 +0000
Commit: Jessica Clarke <jrtc27 at FreeBSD.org>
CommitDate: 2021-06-15 00:22:13 +0000
riscv: Add an hw.ncpu tunable to limit the number of cores
Based on a similar change to arm64 in 01a8235ea61c.
Reviewed by: mhorne
MRC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30655
---
sys/riscv/riscv/mp_machdep.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c
index cdcc86e715dd..1dadf19ce51f 100644
--- a/sys/riscv/riscv/mp_machdep.c
+++ b/sys/riscv/riscv/mp_machdep.c
@@ -532,9 +532,9 @@ cpu_check_mmu(u_int id, phandle_t node, u_int addr_size, pcell_t *reg)
void
cpu_mp_setmaxid(void)
{
-#ifdef FDT
int cores;
+#ifdef FDT
cores = ofw_cpu_early_foreach(cpu_check_mmu, true);
if (cores > 0) {
cores = MIN(cores, MAXCPU);
@@ -543,12 +543,19 @@ cpu_mp_setmaxid(void)
mp_ncpus = cores;
mp_maxid = cores - 1;
cpu_enum_method = CPUS_FDT;
- return;
- }
+ } else
#endif
+ {
+ if (bootverbose)
+ printf("No CPU data, limiting to 1 core\n");
+ mp_ncpus = 1;
+ mp_maxid = 0;
+ }
- 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;
+ }
+ }
}
More information about the dev-commits-src-main
mailing list