aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-01-12 15:34:03 -0800
committerIan Lance Taylor <iant@golang.org>2016-01-14 05:55:43 +0000
commitefd93a412eb5941d767b70097e93a589747de34f (patch)
tree2f11a4fc4129ea55c51931d10b9ba2ebf6c817c3 /src/runtime/proc.go
parentf36ee8c2494465a78f416e7f7653134b5428c168 (diff)
downloadgo-efd93a412eb5941d767b70097e93a589747de34f.tar.xz
runtime: minimize time between lockextra/unlockextra
This doesn't fix a bug, but may improve performance in programs that have many concurrent calls from C to Go. The old code made several system calls between lockextra and unlockextra. That could be happening while another thread is spinning acquiring lockextra. This changes the code to not make any system calls while holding the lock. Change-Id: I50576478e478670c3d6429ad4e1b7d80f98a19d8 Reviewed-on: https://go-review.googlesource.com/18548 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index be1bb815d5..a7e94a9c1d 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -1427,20 +1427,24 @@ func dropm() {
// After the call to setg we can only call nosplit functions
// with no pointer manipulation.
mp := getg().m
- mnext := lockextra(true)
- mp.schedlink.set(mnext)
// Block signals before unminit.
// Unminit unregisters the signal handling stack (but needs g on some systems).
// Setg(nil) clears g, which is the signal handler's cue not to run Go handlers.
// It's important not to try to handle a signal between those two steps.
+ sigmask := mp.sigmask
sigblock()
unminit()
+
+ mnext := lockextra(true)
+ mp.schedlink.set(mnext)
+
setg(nil)
- msigrestore(mp)
// Commit the release of mp.
unlockextra(mp)
+
+ msigrestore(sigmask)
}
// A helper function for EnsureDropM.