mirror of
https://github.com/golang/go
synced 2024-09-30 12:08:32 -06:00
runtime: disallow preemption during startTheWorld
Currently, startTheWorld clears preemptoff for the current M before starting the world. A few callers increment m.locks around startTheWorld, presumably to prevent preemption any time during starting the world. This is almost certainly pointless (none of the other callers do this), but there's no harm in making startTheWorld keep preemption disabled until it's all done, which definitely lets us drop these m.locks manipulations. Change-Id: I8a93658abd0c72276c9bafa3d2c7848a65b4691a Reviewed-on: https://go-review.googlesource.com/10155 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
a1da255aa0
commit
9c44a41dd5
@ -21,9 +21,7 @@ func runtime_debug_WriteHeapDump(fd uintptr) {
|
||||
writeheapdump_m(fd)
|
||||
})
|
||||
|
||||
getg().m.locks++ // TODO: Is this necessary?
|
||||
startTheWorld()
|
||||
getg().m.locks--
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -159,9 +159,7 @@ func ReadMemStats(m *MemStats) {
|
||||
readmemstats_m(m)
|
||||
})
|
||||
|
||||
getg().m.locks++ // TODO: Is this necessary?
|
||||
startTheWorld()
|
||||
getg().m.locks--
|
||||
}
|
||||
|
||||
func readmemstats_m(stats *MemStats) {
|
||||
|
@ -550,9 +550,9 @@ func stopTheWorld(reason string) {
|
||||
|
||||
// startTheWorld undoes the effects of stopTheWorld.
|
||||
func startTheWorld() {
|
||||
getg().m.preemptoff = ""
|
||||
semrelease(&worldsema)
|
||||
systemstack(startTheWorldWithSema)
|
||||
getg().m.preemptoff = ""
|
||||
}
|
||||
|
||||
// Holding worldsema grants an M the right to try to stop the world.
|
||||
|
Loading…
Reference in New Issue
Block a user