From: Emmanuel Odeke Date: Sat, 12 Mar 2016 23:41:08 +0000 (-0700) Subject: runtime: move testSchedLocalQueue* to export_test X-Git-Tag: go1.7beta1~1367 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6dfcc336c520efc85c5aab06ea9d6c45d0aad214;p=gostls13.git runtime: move testSchedLocalQueue* to export_test Move functions testSchedLocalQueueLocal and testSchedLocalQueueSteal from proc.go to export_test.go, the only site that they are used. Fixes #14796 Change-Id: I16b6fa4a13835eab33f66a2c2e87a5f5c79b7bd3 Reviewed-on: https://go-review.googlesource.com/20640 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 0f6d9f7c99..3d29851fa0 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -53,10 +53,68 @@ func GCMask(x interface{}) (ret []byte) { } func RunSchedLocalQueueTest() { - testSchedLocalQueue() + _p_ := new(p) + gs := make([]g, len(_p_.runq)) + for i := 0; i < len(_p_.runq); i++ { + if g, _ := runqget(_p_); g != nil { + throw("runq is not empty initially") + } + for j := 0; j < i; j++ { + runqput(_p_, &gs[i], false) + } + for j := 0; j < i; j++ { + if g, _ := runqget(_p_); g != &gs[i] { + print("bad element at iter ", i, "/", j, "\n") + throw("bad element") + } + } + if g, _ := runqget(_p_); g != nil { + throw("runq is not empty afterwards") + } + } } + func RunSchedLocalQueueStealTest() { - testSchedLocalQueueSteal() + p1 := new(p) + p2 := new(p) + gs := make([]g, len(p1.runq)) + for i := 0; i < len(p1.runq); i++ { + for j := 0; j < i; j++ { + gs[j].sig = 0 + runqput(p1, &gs[j], false) + } + gp := runqsteal(p2, p1, true) + s := 0 + if gp != nil { + s++ + gp.sig++ + } + for { + gp, _ = runqget(p2) + if gp == nil { + break + } + s++ + gp.sig++ + } + for { + gp, _ = runqget(p1) + if gp == nil { + break + } + gp.sig++ + } + for j := 0; j < i; j++ { + if gs[j].sig != 1 { + print("bad element ", j, "(", gs[j].sig, ") at iter ", i, "\n") + throw("bad element") + } + } + if s != i/2 && s != i/2+1 { + print("bad steal ", s, ", want ", i/2, " or ", i/2+1, ", iter ", i, "\n") + throw("bad steal") + } + } } var StringHash = stringHash diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 4aa6b3600e..758a0a898c 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -4027,71 +4027,6 @@ func runqsteal(_p_, p2 *p, stealRunNextG bool) *g { return gp } -func testSchedLocalQueue() { - _p_ := new(p) - gs := make([]g, len(_p_.runq)) - for i := 0; i < len(_p_.runq); i++ { - if g, _ := runqget(_p_); g != nil { - throw("runq is not empty initially") - } - for j := 0; j < i; j++ { - runqput(_p_, &gs[i], false) - } - for j := 0; j < i; j++ { - if g, _ := runqget(_p_); g != &gs[i] { - print("bad element at iter ", i, "/", j, "\n") - throw("bad element") - } - } - if g, _ := runqget(_p_); g != nil { - throw("runq is not empty afterwards") - } - } -} - -func testSchedLocalQueueSteal() { - p1 := new(p) - p2 := new(p) - gs := make([]g, len(p1.runq)) - for i := 0; i < len(p1.runq); i++ { - for j := 0; j < i; j++ { - gs[j].sig = 0 - runqput(p1, &gs[j], false) - } - gp := runqsteal(p2, p1, true) - s := 0 - if gp != nil { - s++ - gp.sig++ - } - for { - gp, _ = runqget(p2) - if gp == nil { - break - } - s++ - gp.sig++ - } - for { - gp, _ = runqget(p1) - if gp == nil { - break - } - gp.sig++ - } - for j := 0; j < i; j++ { - if gs[j].sig != 1 { - print("bad element ", j, "(", gs[j].sig, ") at iter ", i, "\n") - throw("bad element") - } - } - if s != i/2 && s != i/2+1 { - print("bad steal ", s, ", want ", i/2, " or ", i/2+1, ", iter ", i, "\n") - throw("bad steal") - } - } -} - //go:linkname setMaxThreads runtime/debug.setMaxThreads func setMaxThreads(in int) (out int) { lock(&sched.lock)