Skip to content

runtime: injectglist(glist *gList) npidle may not necessarily be the latest value. Could it cause scheduling starvation issues? #63555

Closed
@sxstd001

Description

@sxstd001

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???????????"**

}
``

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions