]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: disallow preemption during startTheWorld
authorAustin Clements <austin@google.com>
Fri, 15 May 2015 20:10:00 +0000 (16:10 -0400)
committerAustin Clements <austin@google.com>
Mon, 18 May 2015 14:55:31 +0000 (14:55 +0000)
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>
src/runtime/heapdump.go
src/runtime/mstats.go
src/runtime/proc1.go

index 196cb3fcb5403b55ce7f1f68f7ce2a42579fcc1a..c0fff3f1ced01c7b14b4d7df80cca4634301a461 100644 (file)
@@ -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 (
index bd6ac1a4d5b41c53e86c05cf0258bd30a26957af..3eff7f6b3ef21f0971df1dfda3637d717b3a8d7f 100644 (file)
@@ -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) {
index 3d86d40654e2de7fa3b01cd0f500232cbaa81876..ab0566b470505a109797150f1646067a4fd51983 100644 (file)
@@ -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.