riscv: Add an hw.ncpu tunable to limit the number of cores

Based on a similar change to arm64 in 01a8235ea6.

Reviewed by:	mhorne
MRC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30655
This commit is contained in:
Jessica Clarke 2021-06-15 01:21:38 +01:00
parent 7ef082733b
commit 5720b8de48

View File

@ -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;
}
}
}