mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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 <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
ab5cbc672b
commit
6dfcc336c5
2 changed files with 60 additions and 67 deletions
|
|
@ -53,10 +53,68 @@ func GCMask(x interface{}) (ret []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunSchedLocalQueueTest() {
|
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() {
|
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
|
var StringHash = stringHash
|
||||||
|
|
|
||||||
|
|
@ -4027,71 +4027,6 @@ func runqsteal(_p_, p2 *p, stealRunNextG bool) *g {
|
||||||
return gp
|
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
|
//go:linkname setMaxThreads runtime/debug.setMaxThreads
|
||||||
func setMaxThreads(in int) (out int) {
|
func setMaxThreads(in int) (out int) {
|
||||||
lock(&sched.lock)
|
lock(&sched.lock)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue