Page MenuHomeFreeBSD

amd64: do not leak pcpu pages
ClosedPublic

Authored by kib on May 3 2023, 9:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 16, 5:58 PM
Unknown Object (File)
Sun, Jun 16, 11:58 AM
Unknown Object (File)
Sat, Jun 15, 4:53 AM
Unknown Object (File)
Thu, Jun 13, 8:47 PM
Unknown Object (File)
Mon, Jun 3, 8:50 AM
Unknown Object (File)
Mon, Jun 3, 8:50 AM
Unknown Object (File)
Mon, Jun 3, 8:50 AM
Unknown Object (File)
Mon, Jun 3, 8:50 AM
Subscribers

Details

Summary
Do not preallocate pcpu area backing pages on early startup, only
allocate enough of KVA for pcpu[MAXCPU] and the page for BSP.  Other
pages are allocated after we know the number of cpus and their
assignments to the domains.

PCPUs are not accessed until they are initialized, which happens on AP
startup.
amd64: initialize APs kpmap_store in init_secondary()

The APs pcpu area is zeroed in init_secondary() by pcpu_init(), so the
early initialization in pmap_bootstrap() is nop.

Fixes:  42f722e721cd010ae5759a4b0d3b7b93c2b9cad2

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.May 3 2023, 9:45 AM
sys/amd64/amd64/mp_machdep.c
318

The domain could be empty. The code needs to try to allocate from other domains before giving up.

sys/amd64/amd64/pmap.c
2001

Perhaps add a comment pointing to amd64_mp_alloc_pcpu()?

kib marked 2 inline comments as done.

Add comment.
Retry if allocation in domain failed.

sys/amd64/amd64/mp_machdep.c
325

This should be ifdef, at least.

It seems cleanest to do the fallback only if vm_ndomains > 1.

kib edited the summary of this revision. (Show Details)

Fix boot on pcid configs.
Change page allocation retry logic.
Zero pcpu_ptes for APs in pmap_bootstrap().

Upload the correct diff

Fix alloc fallback logic for the numa case.

sys/amd64/amd64/mp_machdep.c
316

Should the allocations specify VM_ALLOC_SYSTEM?

sys/amd64/amd64/pmap.c
2002
2041

Can't you use PCPU_SET just like the code immediately below?

kib marked 2 inline comments as done.May 4 2023, 2:19 PM
kib added inline comments.
sys/amd64/amd64/mp_machdep.c
316

I think it does not matter. Or, if it matter, the system is already hosed, since we are dipping into low memory reserve.

This revision is now accepted and ready to land.May 4 2023, 3:21 PM