aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime2.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2025-03-04 10:31:02 -0500
committerGopher Robot <gobot@golang.org>2025-04-11 12:24:59 -0700
commit3968a5bca4fc0cdb4e2bb9fd6169deafdafc420d (patch)
treed78415165d6bbc9f77fc38a452a12217fb675bfd /src/runtime/runtime2.go
parentc77ada1b78ae83c88a4e964a7cbfa2e708073d8b (diff)
downloadgo-3968a5bca4fc0cdb4e2bb9fd6169deafdafc420d.tar.xz
runtime: handle m0 padding better
The SpinbitMutex experiment requires m structs other than m0 to be allocated in 2048-byte size class, by adding padding. Do the calculation more explicitly, to avoid future CLs like CL 653335. Change-Id: I83ae1e86ef3711ab65441f4e487f94b9e1429029 Reviewed-on: https://go-review.googlesource.com/c/go/+/654595 Reviewed-by: Rhys Hiltner <rhys.hiltner@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/runtime2.go')
-rw-r--r--src/runtime/runtime2.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 6b9f49d503..4318930d9c 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -619,13 +619,18 @@ type m struct {
// Up to 10 locks held by this m, maintained by the lock ranking code.
locksHeldLen int
locksHeld [10]heldLockInfo
+}
+
+const mRedZoneSize = (16 << 3) * asanenabledBit // redZoneSize(2048)
+
+type mPadded struct {
+ m
// Size the runtime.m structure so it fits in the 2048-byte size class, and
// not in the next-smallest (1792-byte) size class. That leaves the 11 low
// bits of muintptr values available for flags, as required for
// GOEXPERIMENT=spinbitmutex.
- _ [goexperiment.SpinbitMutexInt * 64 * goarch.PtrSize / 8]byte
- _ [goexperiment.SpinbitMutexInt * 700 * (2 - goarch.PtrSize/4)]byte
+ _ [goexperiment.SpinbitMutexInt * (2048 - mallocHeaderSize - mRedZoneSize - unsafe.Sizeof(m{}))]byte
}
type p struct {