mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: convert g.parkingOnChan to atomic type
Updates #53821 Change-Id: I54de39b984984fb3c160aba5afacb90131fd47c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/424394 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
parent
ea6cb02ae5
commit
5b0ce94c07
4 changed files with 9 additions and 10 deletions
|
|
@ -886,7 +886,7 @@ func copystack(gp *g, newsize uintptr) {
|
|||
// Adjust sudogs, synchronizing with channel ops if necessary.
|
||||
ncopy := used
|
||||
if !gp.activeStackChans {
|
||||
if newsize < old.hi-old.lo && atomic.Load8(&gp.parkingOnChan) != 0 {
|
||||
if newsize < old.hi-old.lo && gp.parkingOnChan.Load() {
|
||||
// It's not safe for someone to shrink this stack while we're actively
|
||||
// parking on a channel, but it is safe to grow since we do that
|
||||
// ourselves and explicitly don't want to synchronize with channels
|
||||
|
|
@ -1150,7 +1150,7 @@ func isShrinkStackSafe(gp *g) bool {
|
|||
// We also can't *shrink* the stack in the window between the
|
||||
// goroutine calling gopark to park on a channel and
|
||||
// gp.activeStackChans being set.
|
||||
return gp.syscallsp == 0 && !gp.asyncSafePoint && atomic.Load8(&gp.parkingOnChan) == 0
|
||||
return gp.syscallsp == 0 && !gp.asyncSafePoint && !gp.parkingOnChan.Load()
|
||||
}
|
||||
|
||||
// Maybe shrink the stack being used by gp.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue