This adds a maymorestack hook that moves the stack at every
cooperative preemption point.
For #48297.
Change-Id: Ic15f9bcbc163345e6422586302d57fda4744caec
Reviewed-on: https://go-review.googlesource.com/c/go/+/359797
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: David Chase <drchase@google.com>
g.stackguard0 = stackPreempt
}
}
+
+// mayMoreStackMove is a maymorestack hook that forces stack movement
+// at every possible point.
+//
+// See mayMoreStackPreempt.
+//
+//go:nosplit
+//go:linkname mayMoreStackMove
+func mayMoreStackMove() {
+ // Don't do anything on the g0 or gsignal stack.
+ g := getg()
+ if g == g.m.g0 || g == g.m.gsignal {
+ return
+ }
+ // Force stack movement, unless the stack is already poisoned.
+ if g.stackguard0 < stackPoisonMin {
+ g.stackguard0 = stackForceMove
+ }
+}