Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
ksm: Fix deadlock
Browse files Browse the repository at this point in the history
We need to release the lock before pushing data into the kick channel.
If we push while holding the lock and the throttle loop is waiting for
the KSM lock, we will deadlock.

Fixes #143

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Samuel Ortiz committed Oct 9, 2017
1 parent 197707f commit 3cb3823
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ksm.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,17 +530,19 @@ func (k *ksm) throttle() {
// kick gets us back to the aggressive setting
func (k *ksm) kick() {
k.Lock()
defer k.Unlock()

if !k.initialized {
proxyLog.Error(errors.New("KSM is unavailable"))
k.Unlock()
return
}

// If we're not throttling, we must not kick.
if !k.throttling {
k.Unlock()
return
}

k.Unlock()
k.kickChannel <- true
}

0 comments on commit 3cb3823

Please sign in to comment.