Skip to content

kvm: remove machine.mu #11570

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
Open

kvm: remove machine.mu #11570

wants to merge 1 commit into from

Conversation

copybara-service[bot]
Copy link

kvm: remove machine.mu

This is only possible after cl/738486108; before that CL, vCPU handoff requires
the waiter to block concurrent machine.Get() from the owner of the stolen vCPU
(but this blocks all concurrent calls to machine.Get(), reducing
utilization).

  • Convert machine.vCPUsByTID from map to AtomicPtrMap.

  • Combine vCPU.tid and vCPU.state into a single uint64 so that machine.Get()
    can atomically pin a VCPU to the calling thread with a single CAS.

  • machine.vCPUsByID is only mutated by initialization and immutable thereafter,
    making machine.mu unnecessary in both machine.initArchState() and
    machine.dropPageTables(); note in particular that
    addressSpace.MapFile/Unmap() => addressSpace.invalidate() =>
    dirtySet.forEach() already reads both m.vCPUsByID slice and contents without
    holding machine.mu.

This is only possible after cl/738486108; before that CL, vCPU handoff requires
the waiter to block concurrent machine.Get() from the owner of the stolen vCPU
(but this blocks *all* concurrent calls to machine.Get(), reducing
utilization).

- Convert machine.vCPUsByTID from map to AtomicPtrMap.

- Combine vCPU.tid and vCPU.state into a single uint64 so that machine.Get()
  can atomically pin a VCPU to the calling thread with a single CAS.

- machine.vCPUsByID is only mutated by initialization and immutable thereafter,
  making machine.mu unnecessary in both machine.initArchState() and
  machine.dropPageTables(); note in particular that
  addressSpace.MapFile/Unmap() => addressSpace.invalidate() =>
  dirtySet.forEach() already reads both m.vCPUsByID slice and contents without
  holding machine.mu.

PiperOrigin-RevId: 738547619
@copybara-service copybara-service bot added the exported Issue was exported automatically label Mar 20, 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