Skip to content

Conversation

@copybara-service
Copy link

kvm: replace machine.availableCond with futexes

Between when machine.Get() observes that a vCPU is not in state vCPUReady, and
when it observes that the same vCPU is not in state vCPUGuest, the vCPU can
racily transition from vCPUGuest to vCPUReady in bluepillGuestExit(), causing
machine.Get() to block in machine.available.Wait() despite a vCPU being ready.
To fix this, drop the vCPU handoff mechanism (vCPUWaiter is still needed for
bounce()) and replace machine.available with a sequence counter futex. This
also improves utilization by allowing machine.Get() to grab the first vCPU that
becomes ready, rather than only the specific vCPU it tags for handoff.

Between when machine.Get() observes that a vCPU is not in state vCPUReady, and
when it observes that the same vCPU is not in state vCPUGuest, the vCPU can
racily transition from vCPUGuest to vCPUReady in bluepillGuestExit(), causing
machine.Get() to block in machine.available.Wait() despite a vCPU being ready.
To fix this, drop the vCPU handoff mechanism (vCPUWaiter is still needed for
bounce()) and replace machine.available with a sequence counter futex. This
also improves utilization by allowing machine.Get() to grab the first vCPU that
becomes ready, rather than only the specific vCPU it tags for handoff.

PiperOrigin-RevId: 738486108
@copybara-service copybara-service bot added the exported Issue was exported automatically label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant