kvm: fix race between machine.Put and machine.Get
m.available.Signal() has to be called under m.mu.RLock, otherwise it can race with machine.Get: m.Get | m.Put ------------------------------------- m.mu.Lock() | Seatching available vcpu| | m.available.Signal() m.available.Wait | PiperOrigin-RevId: 259394051
This commit is contained in:
parent
a0a86bbb82
commit
ec906e46c0
|
@ -388,7 +388,10 @@ func (m *machine) Get() *vCPU {
|
|||
func (m *machine) Put(c *vCPU) {
|
||||
c.unlock()
|
||||
runtime.UnlockOSThread()
|
||||
|
||||
m.mu.RLock()
|
||||
m.available.Signal()
|
||||
m.mu.RUnlock()
|
||||
}
|
||||
|
||||
// newDirtySet returns a new dirty set.
|
||||
|
|
Loading…
Reference in New Issue