aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2025-09-25 13:33:58 -0400
committerCherry Mui <cherryyz@google.com>2025-09-25 13:33:59 -0400
commita693ae1e9aebac896f6634583dbdd1cd319f3983 (patch)
tree44ef04e84afe5ef8652222c5500ab6c779d09650 /src/runtime/proc.go
parent5a78e1a4a1c79185e86b5c18efffba2a9b9d3739 (diff)
parentd70ad4e740e24b4b76961c4b56d698fa23668aa2 (diff)
downloadgo-a693ae1e9aebac896f6634583dbdd1cd319f3983.tar.xz
[dev.simd] all: merge master (d70ad4e) into dev.simd
Conflicts: - src/cmd/compile/internal/types2/stdlib_test.go - src/go/types/stdlib_test.go Merge List: + 2025-09-25 d70ad4e740 sync/atomic: correct Uintptr.Or return doc + 2025-09-25 d7abfe4f0d runtime: acquire/release C TSAN lock when calling cgo symbolizer/tracebacker + 2025-09-25 393d91aea0 cmd/fix: remove all functionality + 2025-09-25 6dceff8bad cmd/link: handle -w flag in external linking mode + 2025-09-25 76d088eb74 cmd/internal/obj/riscv: remove ACFLWSP/ACFSWSP and ACFLW/ACFSW + 2025-09-25 5225e9dc49 doc/next: document new image/jpeg DCT in release notes + 2025-09-25 81a83bba21 cmd: update x/tools@4df13e3 + 2025-09-25 6b32c613ca go/types: make typeset return an iterator + 2025-09-25 fbba930271 image/jpeg: replace fdct.go and idct.go with new implementation in dct.go + 2025-09-25 92e093467f image/jpeg: correct and test reference slowFDCT and slowIDCT + 2025-09-25 27c7bbc51c image/jpeg: prepare for new FDCT/IDCT implementations + 2025-09-24 f15cd63ec4 cmd/compile: don't rely on loop info when there are irreducible loops + 2025-09-24 371c1d2fcb cmd/internal/obj/riscv: add support for vector unit-stride fault-only-first load instructions + 2025-09-23 411c250d64 runtime: add specialized malloc functions for sizes up to 512 bytes + 2025-09-23 d7a38adf4c runtime: eliminate global span queue [green tea] + 2025-09-23 7bc1935db5 cmd/compile/internal: support new(expr) + 2025-09-23 eb78f13c9f doc/go_spec.html: document new(expr) + 2025-09-23 74cc463f9e go/token: add TestRemovedFileFileReturnsNil test + 2025-09-23 902dc27ae9 go/token: clear cache after grabbing the mutex in RemoveFile + 2025-09-23 a13d085a5b cmd/cgo: don't hardcode section name in TestNumberOfExportedFunctions + 2025-09-23 61bf26a9ee cmd/link: fix Macho-O X86_64_RELOC_SUBTRACTOR in internal linking + 2025-09-23 4b787c8c2b reflect: remove stale comment in unpackEface + 2025-09-23 3df27cd21a cmd/compile: fix typo in comment + 2025-09-23 684e8d3363 reflect: allocate memory in TypeAssert[I] only when the assertion succeeds + 2025-09-23 a5866ebe40 cmd/compile: prevent shapifying of pointer shape type + 2025-09-23 a27261c42f go/types,types2: allow new(expr) + 2025-09-23 e93f439ac4 runtime/cgo: retry when CreateThread fails with ERROR_ACCESS_DENIED + 2025-09-23 69e74b0aac runtime: deduplicate pMask resize code + 2025-09-23 fde10c4ce7 runtime: split gcMarkWorkAvailable into two separate conditions + 2025-09-23 5d040df092 runtime: use scan kernels in scanSpan [green tea] + 2025-09-23 7e0251bf58 runtime: don't report non-blocked goroutines as "(durable)" in stacks + 2025-09-23 22ac328856 cmd/link: make -w behavior consistent on Windows Change-Id: Id76b5a30a3b6f6669437f97e3320c9bca65a1e96
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go56
1 files changed, 36 insertions, 20 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 05c60c4ba3..887063638b 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -3126,7 +3126,7 @@ func handoffp(pp *p) {
return
}
// if it has GC work, start it straight away
- if gcBlackenEnabled != 0 && gcMarkWorkAvailable(pp) {
+ if gcBlackenEnabled != 0 && gcShouldScheduleWorker(pp) {
startm(pp, false, false)
return
}
@@ -3507,7 +3507,7 @@ top:
//
// If we're in the GC mark phase, can safely scan and blacken objects,
// and have work to do, run idle-time marking rather than give up the P.
- if gcBlackenEnabled != 0 && gcMarkWorkAvailable(pp) && gcController.addIdleMarkWorker() {
+ if gcBlackenEnabled != 0 && gcShouldScheduleWorker(pp) && gcController.addIdleMarkWorker() {
node := (*gcBgMarkWorkerNode)(gcBgMarkWorkerPool.pop())
if node != nil {
pp.gcMarkWorkerMode = gcMarkWorkerIdleMode
@@ -3914,7 +3914,7 @@ func checkIdleGCNoP() (*p, *g) {
if atomic.Load(&gcBlackenEnabled) == 0 || !gcController.needIdleMarkWorker() {
return nil, nil
}
- if !gcMarkWorkAvailable(nil) {
+ if !gcShouldScheduleWorker(nil) {
return nil, nil
}
@@ -5736,6 +5736,7 @@ func setcpuprofilerate(hz int32) {
// previously destroyed p, and transitions it to status _Pgcstop.
func (pp *p) init(id int32) {
pp.id = id
+ pp.gcw.id = id
pp.status = _Pgcstop
pp.sudogcache = pp.sudogbuf[:0]
pp.deferpool = pp.deferpoolbuf[:0]
@@ -5874,8 +5875,6 @@ func procresize(nprocs int32) *p {
}
sched.procresizetime = now
- maskWords := (nprocs + 31) / 32
-
// Grow allp if necessary.
if nprocs > int32(len(allp)) {
// Synchronize with retake, which could be running
@@ -5891,19 +5890,9 @@ func procresize(nprocs int32) *p {
allp = nallp
}
- if maskWords <= int32(cap(idlepMask)) {
- idlepMask = idlepMask[:maskWords]
- timerpMask = timerpMask[:maskWords]
- } else {
- nidlepMask := make([]uint32, maskWords)
- // No need to copy beyond len, old Ps are irrelevant.
- copy(nidlepMask, idlepMask)
- idlepMask = nidlepMask
-
- ntimerpMask := make([]uint32, maskWords)
- copy(ntimerpMask, timerpMask)
- timerpMask = ntimerpMask
- }
+ idlepMask = idlepMask.resize(nprocs)
+ timerpMask = timerpMask.resize(nprocs)
+ work.spanqMask = work.spanqMask.resize(nprocs)
unlock(&allpLock)
}
@@ -5966,8 +5955,9 @@ func procresize(nprocs int32) *p {
if int32(len(allp)) != nprocs {
lock(&allpLock)
allp = allp[:nprocs]
- idlepMask = idlepMask[:maskWords]
- timerpMask = timerpMask[:maskWords]
+ idlepMask = idlepMask.resize(nprocs)
+ timerpMask = timerpMask.resize(nprocs)
+ work.spanqMask = work.spanqMask.resize(nprocs)
unlock(&allpLock)
}
@@ -6906,6 +6896,32 @@ func (p pMask) clear(id int32) {
atomic.And(&p[word], ^mask)
}
+// any returns true if any bit in p is set.
+func (p pMask) any() bool {
+ for i := range p {
+ if atomic.Load(&p[i]) != 0 {
+ return true
+ }
+ }
+ return false
+}
+
+// resize resizes the pMask and returns a new one.
+//
+// The result may alias p, so callers are encouraged to
+// discard p. Not safe for concurrent use.
+func (p pMask) resize(nprocs int32) pMask {
+ maskWords := (nprocs + 31) / 32
+
+ if maskWords <= int32(cap(p)) {
+ return p[:maskWords]
+ }
+ newMask := make([]uint32, maskWords)
+ // No need to copy beyond len, old Ps are irrelevant.
+ copy(newMask, p)
+ return newMask
+}
+
// pidleput puts p on the _Pidle list. now must be a relatively recent call
// to nanotime or zero. Returns now or the current time if now was zero.
//