From e0dba45c620866bb16cd0db2c51732f03a9b27f3 Mon Sep 17 00:00:00 2001 From: Dmitrii Martynov Date: Mon, 7 Apr 2025 17:08:19 +0300 Subject: runtime: size field for gQueue and gList Before CL, all instances of gQueue and gList stored the size of structures in a separate variable. The size changed manually and passed as a separate argument to different functions. This CL added an additional field to gQueue and gList structures to store the size. Also, the calculation of size was moved into the implementation of API for these structures. This allows to reduce possible errors by eliminating manual calculation of the size and simplifying functions' signatures. Change-Id: I087da2dfaec4925e4254ad40fce5ccb4c175ec41 Reviewed-on: https://go-review.googlesource.com/c/go/+/664777 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt Reviewed-by: Keith Randall Reviewed-by: Keith Randall Auto-Submit: Keith Randall --- src/runtime/runtime2.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/runtime/runtime2.go') diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 4318930d9c..e56b45053e 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -671,10 +671,7 @@ type p struct { runnext guintptr // Available G's (status == Gdead) - gFree struct { - gList - n int32 - } + gFree gList sudogcache []*sudog sudogbuf [128]*sudog @@ -785,8 +782,7 @@ type schedt struct { needspinning atomic.Uint32 // See "Delicate dance" comment in proc.go. Boolean. Must hold sched.lock to set to 1. // Global runnable queue. - runq gQueue - runqsize int32 + runq gQueue // disable controls selective disabling of the scheduler. // @@ -797,7 +793,6 @@ type schedt struct { // user disables scheduling of user goroutines. user bool runnable gQueue // pending runnable Gs - n int32 // length of runnable } // Global cache of dead G's. @@ -805,7 +800,6 @@ type schedt struct { lock mutex stack gList // Gs with stacks noStack gList // Gs without stacks - n int32 } // Central cache of sudog structs. -- cgit v1.3