Page MenuHomeFreeBSD

Remove the secondary_stacks array in arm64 and riscv kernels.
ClosedPublic

Authored by markj on Sun, Mar 22, 9:06 PM.

Details

Summary

Instead, dynamically allocate a page for the boot stack of each AP when
starting them up, like we do on x86. This shrinks the bss by
MAXCPU*KSTACK_PAGES pages, which corresponds to 4MB on arm64 and 256KB
on riscv. mpentry is slightly simplified as well.

Duplicate the logic used on x86 to free the bootstacks, by using a
sysinit to wait for APs to switch to a thread.

While here, mark some static MD variables as such.

Test Plan

Tested boot-up in QEMU for arm64 and riscv.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markj created this revision.Sun, Mar 22, 9:06 PM
markj edited the test plan for this revision. (Show Details)
kib accepted this revision.Sun, Mar 22, 10:24 PM
kib added inline comments.
sys/arm64/arm64/mp_machdep.c
279 ↗(On Diff #69780)

Don't you need to check for bootstacks[cpu] == NULL before waiting for curpcb change ?

477 ↗(On Diff #69780)

I would add 'err' value to the printf.

This revision is now accepted and ready to land.Sun, Mar 22, 10:24 PM
markj updated this revision to Diff 69784.Sun, Mar 22, 11:26 PM

Address feedback:

  • Print the error from PSCI if we fail to start a CPU.
  • Check for a NULL bootstack pointer before freeing, on both riscv and arm64.
This revision now requires review to proceed.Sun, Mar 22, 11:26 PM
kib accepted this revision.Sun, Mar 22, 11:31 PM
This revision is now accepted and ready to land.Sun, Mar 22, 11:31 PM
andrew added inline comments.Mon, Mar 23, 9:52 AM
sys/arm64/arm64/mp_machdep.c
485 ↗(On Diff #69784)

Is there a reason to not use wfe here?

markj added inline comments.Mon, Mar 23, 3:22 PM
sys/arm64/arm64/mp_machdep.c
485 ↗(On Diff #69784)

I don't think so, I just assumed cpu_spinwait() would be fine since we should spend relatively little time here.

markj added inline comments.Mon, Mar 23, 3:47 PM
sys/arm64/arm64/mp_machdep.c
485 ↗(On Diff #69784)

... presumably there is some threshold where a short wfe interval is not any better from a power consumption perspective than a spinwait loop?

This revision was automatically updated to reflect the committed changes.