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
This commit is contained in:
parent
7ef082733b
commit
5720b8de48
@ -532,9 +532,9 @@ cpu_check_mmu(u_int id, phandle_t node, u_int addr_size, pcell_t *reg)
|
|||||||
void
|
void
|
||||||
cpu_mp_setmaxid(void)
|
cpu_mp_setmaxid(void)
|
||||||
{
|
{
|
||||||
#ifdef FDT
|
|
||||||
int cores;
|
int cores;
|
||||||
|
|
||||||
|
#ifdef FDT
|
||||||
cores = ofw_cpu_early_foreach(cpu_check_mmu, true);
|
cores = ofw_cpu_early_foreach(cpu_check_mmu, true);
|
||||||
if (cores > 0) {
|
if (cores > 0) {
|
||||||
cores = MIN(cores, MAXCPU);
|
cores = MIN(cores, MAXCPU);
|
||||||
@ -543,12 +543,19 @@ cpu_mp_setmaxid(void)
|
|||||||
mp_ncpus = cores;
|
mp_ncpus = cores;
|
||||||
mp_maxid = cores - 1;
|
mp_maxid = cores - 1;
|
||||||
cpu_enum_method = CPUS_FDT;
|
cpu_enum_method = CPUS_FDT;
|
||||||
return;
|
} else
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
if (bootverbose)
|
||||||
|
printf("No CPU data, limiting to 1 core\n");
|
||||||
|
mp_ncpus = 1;
|
||||||
|
mp_maxid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (bootverbose)
|
if (TUNABLE_INT_FETCH("hw.ncpu", &cores)) {
|
||||||
printf("No CPU data, limiting to 1 core\n");
|
if (cores > 0 && cores < mp_ncpus) {
|
||||||
mp_ncpus = 1;
|
mp_ncpus = cores;
|
||||||
mp_maxid = 0;
|
mp_maxid = cores - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user