Page MenuHomeFreeBSD

amd64: rework PCPU allocation
ClosedPublic

Authored by kib on Aug 19 2019, 7:33 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 29, 4:32 AM
Unknown Object (File)
Thu, Nov 28, 4:22 PM
Unknown Object (File)
Fri, Nov 22, 6:36 AM
Unknown Object (File)
Wed, Nov 20, 4:10 PM
Unknown Object (File)
Oct 12 2024, 8:52 AM
Unknown Object (File)
Oct 5 2024, 3:41 PM
Unknown Object (File)
Oct 3 2024, 4:50 AM
Unknown Object (File)
Oct 2 2024, 4:24 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 25953

Event Timeline

sys/amd64/amd64/mp_machdep.c
479

There is a whitespace bug here.

sys/amd64/amd64/pmap.c
1706

pg_nx?

sys/amd64/amd64/machdep.c
1583

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

sys/amd64/amd64/pmap.c
1712

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.

1714

Extra newline.

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

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.