Closed
Description
injectglist(glist *gList) npidle may not necessarily be the latest value.
Could it cause scheduling starvation issues?
func injectglist(glist *gList) {
..............
startIdle := func(n int) {
for i := 0; i < n; i++ {
mp := acquirem() // See comment in startm.
lock(&sched.lock)
pp, _ := pidlegetSpinning(0)
if pp == nil {
unlock(&sched.lock)
releasem(mp)
break
}
startm(pp, false, true)
unlock(&sched.lock)
releasem(mp)
}
}
// there no problem;
pp := getg().m.p.ptr()
if pp == nil {
lock(&sched.lock)
globrunqputbatch(&q, int32(qsize))
unlock(&sched.lock)
startIdle(qsize)
return
}
npidle := int(sched.npidle.Load())
// !!!!!!!! npidle may not necessarily be the latest value
var globq gQueue
var n int
for n = 0; n < npidle && !q.empty(); n++ {
g := q.pop()
globq.pushBack(g)
}
if n > 0 {
lock(&sched.lock)
globrunqputbatch(&globq, int32(n))
unlock(&sched.lock)
startIdle(n)
qsize -= n
}
if !q.empty() {
runqputbatch(pp, &q, qsize)
}
**// Should wakeP be called here???????????"**
}
``