Page MenuHomeFreeBSD

amd64: rework PCPU allocation
ClosedPublic

Authored by kib on Aug 19 2019, 7:33 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 15 2024, 9:35 AM
Unknown Object (File)
Jan 23 2024, 7:01 PM
Unknown Object (File)
Jan 10 2024, 2:57 AM
Unknown Object (File)
Dec 29 2023, 3:07 AM
Unknown Object (File)
Dec 8 2023, 5:08 PM
Unknown Object (File)
Nov 11 2023, 6:46 AM
Unknown Object (File)
Nov 10 2023, 2:52 AM
Unknown Object (File)
Nov 8 2023, 12:14 AM
Subscribers

Details

Summary

Move pcpu KVA out of .bss into dynamically allocated VA at pmap_bootstrap(). This avoids demoting superpage mapping .data/.bss. Also it makes possible to use pmap_qenter() for installation of domain-local pcpu page on NUMA configs.

Remove unecessary VM_ALLOC_ZERO from allocation of the domain-local page for pcpu.

Do not constrain allocations for doublefault, boot, and mce stacks. All these stacks are used only once (doublefault, boot) or very rare (mce).

Refactor pcpu and IST initialization by moving it to helper functions.

[Basically this is my previous patch, rebased on top of Jeff' commit, with unnecessary diffs reduced. I do not like extern struct pcpus declarations spread over sources, and have a plan to fix that after this commit lands]

Test Plan

Peter, could you, please, sanity-check this change ?

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 25973

Event Timeline

sys/amd64/amd64/mp_machdep.c
481

There is a whitespace bug here.

sys/amd64/amd64/pmap.c
1705

pg_nx?

sys/amd64/amd64/machdep.c
1583

Style: extra space after the cast. This is duplicated below.

sys/amd64/amd64/pmap.c
1711

Why don't we need to call amd64_bsp_pcpu_init2() here?

I would wrap this in a amd64_bsp_pcpu_reinit() function, defined in machdep.c.

1713

Extra newline.

kib marked an inline comment as done.Aug 19 2019, 4:31 PM
kib added inline comments.
sys/amd64/amd64/pmap.c
1711

This is pmap_bootstrap(), called from getmemsize(). There is no point in calling amd64_bp_pcpu_init2() this early. More, I suspect that some values to put into pcpu are not yet ready.

That was the reason for doing init1/init2.

init2 is called much later in hammer_time().

kib marked 5 inline comments as done.Aug 19 2019, 6:30 PM

I see a hang during boot with this patch applied on a dual socket Xeon. It occurs fairly late, after disk and USB controller drivers attach, but before I can break into the debugger. It also happens with SMP disabled.

Preserve apic_id on temp bsp pcpu->final bsp pcpu transition.
Remove unneeded segment registration.

I see a hang during boot with this patch applied on a dual socket Xeon. It occurs fairly late, after disk and USB controller drivers attach, but before I can break into the debugger. It also happens with SMP disabled.

Yes, I do not have USB in regular testing kernel. Apparently contig scan hung because I did unneeded (now) segment registration for pcpu range.

I would still find it neater to somehow group the bsp pcpu reinit with related code in machdep.c.

This revision is now accepted and ready to land.Aug 20 2019, 2:23 PM
kib added a subscriber: pho.

I ran a brief 2 hour test with D21320.61033.diff. No problems seen.