aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime2.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-03-16 20:08:00 -0400
committerCherry Zhang <cherryyz@google.com>2020-03-18 16:00:44 +0000
commit0c0e8f224d5724e317952f77d215a752a3a7b7d9 (patch)
treec190a79fde5ddd44ab0987067accfc3ae84b597e /src/runtime/runtime2.go
parent6412750f32224f6820f781d09b2092c5c358dddc (diff)
downloadgo-0c0e8f224d5724e317952f77d215a752a3a7b7d9.tar.gz
go-0c0e8f224d5724e317952f77d215a752a3a7b7d9.zip
runtime: don't send preemption signal if there is a signal pending
If multiple threads call preemptone to preempt the same M, it may send many signals to the same M such that it hardly make progress, causing live-lock problem. Only send a signal if there isn't already one pending. Fixes #37741. Change-Id: Id94adb0b95acbd18b23abe637a8dcd81ab41b452 Reviewed-on: https://go-review.googlesource.com/c/go/+/223737 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/runtime2.go')
-rw-r--r--src/runtime/runtime2.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 9e3ccb2e40..1a98927647 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -539,6 +539,10 @@ type m struct {
// requested, but fails. Accessed atomically.
preemptGen uint32
+ // Whether this is a pending preemption signal on this M.
+ // Accessed atomically.
+ signalPending uint32
+
dlogPerM
mOS