diff options
author | Austin Clements <austin@google.com> | 2017-06-13 12:01:56 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2017-09-27 16:29:15 +0000 |
commit | e900e275e8667fde18973cdebe94861353162b87 (patch) | |
tree | dffb246ff30d62faa7f86cd355f98fed508bf3ee /src/runtime/trace.go | |
parent | ee55000f6c45d2f5c38d91679def933fdf27c029 (diff) | |
download | go-e900e275e8667fde18973cdebe94861353162b87.tar.gz go-e900e275e8667fde18973cdebe94861353162b87.zip |
runtime: clean up loops over allp
allp now has length gomaxprocs, which means none of allp[i] are nil or
in state _Pdead. This lets replace several different styles of loops
over allp with normal range loops.
for i := 0; i < gomaxprocs; i++ { ... } loops can simply range over
allp. Likewise, range loops over allp[:gomaxprocs] can just range over
allp.
Loops that check for p == nil || p.state == _Pdead don't need to check
this any more.
Loops that check for p == nil don't have to check this *if* dead Ps
don't affect them. I checked that all such loops are, in fact,
unaffected by dead Ps. One loop was potentially affected, which this
fixes by zeroing p.gcAssistTime in procresize.
Updates #15131.
Change-Id: Ifa1c2a86ed59892eca0610360a75bb613bc6dcee
Reviewed-on: https://go-review.googlesource.com/45575
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/trace.go')
-rw-r--r-- | src/runtime/trace.go | 6 |
1 files changed, 0 insertions, 6 deletions
diff --git a/src/runtime/trace.go b/src/runtime/trace.go index 398d0449b4..e179e18b9f 100644 --- a/src/runtime/trace.go +++ b/src/runtime/trace.go @@ -280,9 +280,6 @@ func StopTrace() { // Loop over all allocated Ps because dead Ps may still have // trace buffers. for _, p := range allp[:cap(allp)] { - if p == nil { - break - } buf := p.tracebuf if buf != 0 { traceFullQueue(buf) @@ -323,9 +320,6 @@ func StopTrace() { // The lock protects us from races with StartTrace/StopTrace because they do stop-the-world. lock(&trace.lock) for _, p := range allp[:cap(allp)] { - if p == nil { - break - } if p.tracebuf != 0 { throw("trace: non-empty trace buffer in proc") } |