From: Austin Clements Date: Fri, 15 May 2015 20:10:00 +0000 (-0400) Subject: runtime: disallow preemption during startTheWorld X-Git-Tag: go1.5beta1~547 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9c44a41dd56660b7685da61bf1efb00cc7c1e198;p=gostls13.git 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 --- diff --git a/src/runtime/heapdump.go b/src/runtime/heapdump.go index 196cb3fcb5..c0fff3f1ce 100644 --- a/src/runtime/heapdump.go +++ b/src/runtime/heapdump.go @@ -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 ( diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go index bd6ac1a4d5..3eff7f6b3e 100644 --- a/src/runtime/mstats.go +++ b/src/runtime/mstats.go @@ -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) { diff --git a/src/runtime/proc1.go b/src/runtime/proc1.go index 3d86d40654..ab0566b470 100644 --- a/src/runtime/proc1.go +++ b/src/runtime/proc1.go @@ -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.