Page MenuHomeFreeBSD

vmm: Use a cpuset_t for vCPUs waiting for STARTUP IPIs.
ClosedPublic

Authored by jhb on Oct 27 2022, 3:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 14 2024, 4:36 PM
Unknown Object (File)
Oct 3 2024, 5:14 AM
Unknown Object (File)
Sep 27 2024, 11:24 PM
Unknown Object (File)
Sep 27 2024, 9:31 PM
Unknown Object (File)
Sep 23 2024, 1:19 AM
Unknown Object (File)
Sep 22 2024, 7:32 PM
Unknown Object (File)
Sep 22 2024, 5:09 AM
Unknown Object (File)
Sep 19 2024, 1:38 PM

Details

Summary

Retire the boot_state member of struct vlapic and instead use a cpuset
in the VM to track vCPUs waiting for STARTUP IPIs. INIT IPIs add
vCPUs to this set, and STARTUP IPIs remove vCPUs from the set.
STARTUP IPIs are only reported to userland for vCPUs that were removed
from the set.

In particular, this permits a subsequent change to allocate vCPUs on
demand when the vCPU may not be allocated until after a STARTUP IPI is
reported to userland.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 48218
Build 45104: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Oct 27 2022, 3:06 PM
corvink added inline comments.
sys/amd64/vmm/vmm.c
2444

vm_handle_ipi is called in a rendezvous. So, the caller can already hold the rendezvous_mtx. Therefore, we need to set the MTX_RECURSE flag on mtx_init.

sys/amd64/vmm/io/vlapic.c
1207

Note that the call here is just after a call to vm_smp_rendezvous.

sys/amd64/vmm/vmm.c
2444

Hmm, I think vm_handle_init is the function called in a rendezvous as vm_handle_ipi calls vm_smp_redenzvous itself. I didn't get a panic when testing this in a debug kernel which normally you would get for recursing on a mutex without the flag.

sys/amd64/vmm/vmm.c
2444

Sry. Didn't look close enough. You're right.

2797

Shouldn't we snapshot vm->startup_cpus?

Snapshot the startup cpuset

jhb marked an inline comment as done.Nov 7 2022, 11:38 PM
This revision is now accepted and ready to land.Nov 8 2022, 6:49 AM
sys/amd64/vmm/vmm.c
175

Does it really need to be volatile? I can't see why. In fact, with commit 8b1adff8bcbd I think vm_snapshot_vm() will raise a warning.

sys/amd64/vmm/vmm.c
175

Mmm, correct, it does not as it is locked by the rendezvous_mtx.

jhb marked an inline comment as done.Nov 11 2022, 5:44 PM
This revision now requires review to proceed.Nov 11 2022, 5:49 PM
This revision is now accepted and ready to land.Nov 14 2022, 6:57 AM