mirror of
https://github.com/golang/go
synced 2024-11-18 11:24:41 -07:00
runtime: don't start GC if preemptoff is set
In order to avoid deadlocks, startGC avoids kicking off GC if locks are held by the calling M. However, it currently fails to check preemptoff, which is the other way to disable preemption. Fix this by adding a check for preemptoff. Change-Id: Ie1083166e5ba4af5c9d6c5a42efdfaaef41ca997 Reviewed-on: https://go-review.googlesource.com/10153 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
e544bee1dd
commit
5f7060afd2
@ -703,7 +703,7 @@ func startGC(mode int) {
|
|||||||
// trying to run gc while holding a lock. The next mallocgc without a lock
|
// trying to run gc while holding a lock. The next mallocgc without a lock
|
||||||
// will do the gc instead.
|
// will do the gc instead.
|
||||||
mp := acquirem()
|
mp := acquirem()
|
||||||
if gp := getg(); gp == mp.g0 || mp.locks > 1 || !memstats.enablegc || panicking != 0 || gcpercent < 0 {
|
if gp := getg(); gp == mp.g0 || mp.locks > 1 || mp.preemptoff != "" || !memstats.enablegc || panicking != 0 || gcpercent < 0 {
|
||||||
releasem(mp)
|
releasem(mp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user