aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sema.go
diff options
context:
space:
mode:
authorRhys Hiltner <rhys@justin.tv>2019-12-17 16:40:46 -0800
committerAustin Clements <austin@google.com>2020-01-02 20:13:03 +0000
commita4c579e8f7c8129b2c27779f206ebd2c9b393633 (patch)
treedfe75aa1cb160812d5acc74bf6572983574be8d1 /src/runtime/sema.go
parentbf268472408b0f46767d46ae1d14439e5eb84014 (diff)
downloadgo-a4c579e8f7c8129b2c27779f206ebd2c9b393633.tar.gz
go-a4c579e8f7c8129b2c27779f206ebd2c9b393633.zip
runtime: emit trace event in direct semaphore handoff
When a goroutine yields the remainder of its time to another goroutine during direct semaphore handoff (as in an Unlock of a sync.Mutex in starvation mode), it needs to signal that change to the execution tracer. The discussion in CL 200577 didn't reach consensus on how best to describe that, but pointed out that "traceEvGoSched / goroutine calls Gosched" could be confusing. Emit a "traceEvGoPreempt / goroutine is preempted" event in this case, to allow the execution tracer to find a consistent event ordering without being both specific and inaccurate about why the active goroutine has changed. Fixes #36186 Change-Id: Ic4ade19325126db2599aff6aba7cba028bb0bee9 Reviewed-on: https://go-review.googlesource.com/c/go/+/211797 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/sema.go')
-rw-r--r--src/runtime/sema.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime/sema.go b/src/runtime/sema.go
index 7bbf871caa..9bfd4f96d5 100644
--- a/src/runtime/sema.go
+++ b/src/runtime/sema.go
@@ -199,9 +199,9 @@ func semrelease1(addr *uint32, handoff bool, skipframes int) {
// the waiter G immediately.
// Note that waiter inherits our time slice: this is desirable
// to avoid having a highly contended semaphore hog the P
- // indefinitely. goyield is like Gosched, but it does not emit a
- // GoSched trace event and, more importantly, puts the current G
- // on the local runq instead of the global one.
+ // indefinitely. goyield is like Gosched, but it emits a
+ // "preempted" trace event instead and, more importantly, puts
+ // the current G on the local runq instead of the global one.
// We only do this in the starving regime (handoff=true), as in
// the non-starving case it is possible for a different waiter
// to acquire the semaphore while we are yielding/scheduling,