aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2016-01-08 15:31:09 +0000
committerRuss Cox <rsc@golang.org>2016-01-08 15:31:15 +0000
commit6da608206c222c280078264f02135ffaa4e1aa26 (patch)
tree99bd0b58d508681fbe19c30e0de9427cb725a98b /src/runtime
parentc5bafc828126c8fa057e1accaa448583c7ec145f (diff)
downloadgo-6da608206c222c280078264f02135ffaa4e1aa26.tar.xz
Revert "runtime: make NumGoroutine and Stack agree not to include system goroutines"
This reverts commit c5bafc828126c8fa057e1accaa448583c7ec145f. Change-Id: Ie7030c978c6263b9e996d5aa0e490086796df26d Reviewed-on: https://go-review.googlesource.com/18431 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/mprof.go5
-rw-r--r--src/runtime/proc.go8
-rw-r--r--src/runtime/proc_test.go18
-rw-r--r--src/runtime/runtime2.go2
-rw-r--r--src/runtime/testdata/testprog/misc.go15
5 files changed, 1 insertions, 47 deletions
diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go
index eb7231aec2..684ab0b055 100644
--- a/src/runtime/mprof.go
+++ b/src/runtime/mprof.go
@@ -576,17 +576,12 @@ func Stack(buf []byte, all bool) int {
pc := getcallerpc(unsafe.Pointer(&buf))
systemstack(func() {
g0 := getg()
- // Force traceback=1 to override GOTRACEBACK setting,
- // so that Stack's results are consistent.
- // GOTRACEBACK is only about crash dumps.
- g0.m.traceback = 1
g0.writebuf = buf[0:0:len(buf)]
goroutineheader(gp)
traceback(pc, sp, 0, gp)
if all {
tracebackothers(gp)
}
- g0.m.traceback = 0
n = len(g0.writebuf)
g0.writebuf = nil
})
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index d80b33e9c4..23429fd774 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -2162,9 +2162,6 @@ func goexit0(gp *g) {
_g_ := getg()
casgstatus(gp, _Grunning, _Gdead)
- if isSystemGoroutine(gp) {
- atomic.Xadd(&sched.ngsys, -1)
- }
gp.m = nil
gp.lockedm = nil
_g_.m.lockedg = nil
@@ -2696,9 +2693,6 @@ func newproc1(fn *funcval, argp *uint8, narg int32, nret int32, callerpc uintptr
gostartcallfn(&newg.sched, fn)
newg.gopc = callerpc
newg.startpc = fn.fn
- if isSystemGoroutine(newg) {
- atomic.Xadd(&sched.ngsys, +1)
- }
casgstatus(newg, _Gdead, _Grunnable)
if _p_.goidcache == _p_.goidcacheend {
@@ -2891,7 +2885,7 @@ func badunlockosthread() {
}
func gcount() int32 {
- n := int32(allglen) - sched.ngfree - int32(atomic.Load(&sched.ngsys))
+ n := int32(allglen) - sched.ngfree
for i := 0; ; i++ {
_p_ := allp[i]
if _p_ == nil {
diff --git a/src/runtime/proc_test.go b/src/runtime/proc_test.go
index f3e90bcbd7..30798f723d 100644
--- a/src/runtime/proc_test.go
+++ b/src/runtime/proc_test.go
@@ -9,7 +9,6 @@ import (
"net"
"runtime"
"runtime/debug"
- "strings"
"sync"
"sync/atomic"
"syscall"
@@ -337,23 +336,6 @@ func TestGCFairness(t *testing.T) {
}
}
-func TestNumGoroutine(t *testing.T) {
- output := runTestProg(t, "testprog", "NumGoroutine")
- want := "1\n"
- if output != want {
- t.Fatalf("want %q, got %q", want, output)
- }
-
- buf := make([]byte, 1<<20)
- buf = buf[:runtime.Stack(buf, true)]
-
- n := runtime.NumGoroutine()
-
- if nstk := strings.Count(string(buf), "goroutine "); n != nstk {
- t.Fatalf("NumGoroutine=%d, but found %d goroutines in stack dump", n, nstk)
- }
-}
-
func TestPingPongHog(t *testing.T) {
if testing.Short() {
t.Skip("skipping in -short mode")
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index a4ad749d25..d9a449b68b 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -418,8 +418,6 @@ type schedt struct {
mcount int32 // number of m's that have been created
maxmcount int32 // maximum number of m's allowed (or die)
- ngsys uint32 // number of system goroutines; updated atomically
-
pidle puintptr // idle p's
npidle uint32
nmspinning uint32 // See "Worker thread parking/unparking" comment in proc.go.
diff --git a/src/runtime/testdata/testprog/misc.go b/src/runtime/testdata/testprog/misc.go
deleted file mode 100644
index 237680fc87..0000000000
--- a/src/runtime/testdata/testprog/misc.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import "runtime"
-
-func init() {
- register("NumGoroutine", NumGoroutine)
-}
-
-func NumGoroutine() {
- println(runtime.NumGoroutine())
-}