Skip to content

kvm: replace machine.availableCond with futexes #11568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

copybara-service[bot]
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