Page MenuHomeFreeBSD

amd64: rework PCPU allocation
ClosedPublic

Authored by kib on Aug 19 2019, 7:33 AM.

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
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 25963

Event Timeline

kib created this revision.Aug 19 2019, 7:33 AM
markj added inline comments.Aug 19 2019, 3:46 PM
sys/amd64/amd64/mp_machdep.c
481

There is a whitespace bug here.

sys/amd64/amd64/pmap.c
1706

pg_nx?

markj added inline comments.Aug 19 2019, 4:00 PM
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
kib updated this revision to Diff 61010.Aug 19 2019, 6:32 PM

Style.

markj added a comment.EditedAug 19 2019, 9:37 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.

kib updated this revision to Diff 61033.Aug 20 2019, 8:55 AM

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

kib added a comment.Aug 20 2019, 8:56 AM

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.

markj accepted this revision.Aug 20 2019, 2:23 PM

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 edited the test plan for this revision. (Show Details)Aug 21 2019, 3:23 PM
kib added a subscriber: pho.
pho added a comment.Aug 21 2019, 6:35 PM

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

This revision was automatically updated to reflect the committed changes.