Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(240)

Issue 144940043: code review 144940043: runtime: always run semacquire on the G stack (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 1 month ago by khr
Modified:
11 years, 1 month ago
Reviewers:
dvyukov
CC:
golang-codereviews, dvyukov, bradfitz
Visibility:
Public.

Description

runtime: always run semacquire on the G stack semacquire might need to park the currently running G. It can only park if called from the G stack (because it has no way of saving the M stack state). So all calls to semacquire must come from the G stack. The three violators are GOMAXPROCS, ReadMemStats, and WriteHeapDump. This change moves the semacquire call earlier, out of their C code and into their Go code. This seldom caused bugs because semacquire seldom actually had to park the caller. But it did happen intermittently. Fixes issue 8749

Patch Set 1 #

Patch Set 2 : diff -r b18ebcb9f2367d52af8c3515dee63888ca96db70 https://code.google.com/p/go/ #

Patch Set 3 : diff -r b18ebcb9f2367d52af8c3515dee63888ca96db70 https://code.google.com/p/go/ #

Patch Set 4 : diff -r b18ebcb9f2367d52af8c3515dee63888ca96db70 https://code.google.com/p/go/ #

Patch Set 5 : diff -r b18ebcb9f2367d52af8c3515dee63888ca96db70 https://code.google.com/p/go/ #

Total comments: 1

Patch Set 6 : diff -r b18ebcb9f2367d52af8c3515dee63888ca96db70 https://code.google.com/p/go/ #

Patch Set 7 : diff -r b18ebcb9f2367d52af8c3515dee63888ca96db70 https://code.google.com/p/go/ #

Total comments: 2

Patch Set 8 : diff -r b18ebcb9f2367d52af8c3515dee63888ca96db70 https://code.google.com/p/go/ #

Patch Set 9 : diff -r b18ebcb9f2367d52af8c3515dee63888ca96db70 https://code.google.com/p/go/ #

Patch Set 10 : diff -r 2694ad0b98615ebdf85b2cbe6622a17db69621b0 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+114 lines, -132 lines) Patch
M src/runtime/debug.go View 1 2 3 4 5 1 chunk +22 lines, -8 lines 0 comments Download
M src/runtime/heapdump.c View 1 2 3 4 5 6 2 chunks +1 line, -24 lines 0 comments Download
M src/runtime/mem.go View 1 2 3 4 5 1 chunk +36 lines, -1 line 0 comments Download
M src/runtime/mgc0.c View 1 2 3 4 5 6 7 8 9 2 chunks +1 line, -25 lines 0 comments Download
M src/runtime/proc.c View 1 2 3 5 chunks +5 lines, -74 lines 0 comments Download
M src/runtime/runtime.h View 1 2 3 4 5 6 7 8 9 3 chunks +39 lines, -0 lines 0 comments Download
M src/runtime/sema.go View 1 2 3 4 5 6 7 1 chunk +5 lines, -0 lines 0 comments Download
M src/runtime/stubs.go View 1 1 chunk +2 lines, -0 lines 0 comments Download
M src/runtime/thunk.s View 1 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 9
khr
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
11 years, 1 month ago (2014-09-16 04:15:03 UTC) #1
dvyukov
https://codereview.appspot.com/144940043/diff/80001/src/runtime/heapdump.c File src/runtime/heapdump.c (left): https://codereview.appspot.com/144940043/diff/80001/src/runtime/heapdump.c#oldcode765 src/runtime/heapdump.c:765: g->m->gcing = 1; I feel very nervous that you ...
11 years, 1 month ago (2014-09-16 04:38:45 UTC) #2
bradfitz
On Tue, Sep 16, 2014 at 12:38 AM, dvyukov via golang-codereviews < golang-codereviews@googlegroups.com> wrote: > ...
11 years, 1 month ago (2014-09-16 04:48:07 UTC) #3
dvyukov
On Mon, Sep 15, 2014 at 9:48 PM, Brad Fitzpatrick <bradfitz@golang.org> wrote: > > > ...
11 years, 1 month ago (2014-09-16 04:51:49 UTC) #4
bradfitz
On Tue, Sep 16, 2014 at 12:51 AM, Dmitry Vyukov <dvyukov@google.com> wrote: > On Mon, ...
11 years, 1 month ago (2014-09-16 04:52:55 UTC) #5
khr
On 2014/09/16 04:52:55, bradfitz wrote: > On Tue, Sep 16, 2014 at 12:51 AM, Dmitry ...
11 years, 1 month ago (2014-09-16 20:47:00 UTC) #6
dvyukov
https://codereview.appspot.com/144940043/diff/120001/src/runtime/runtime.h File src/runtime/runtime.h (right): https://codereview.appspot.com/144940043/diff/120001/src/runtime/runtime.h#newcode437 src/runtime/runtime.h:437: struct SchedType { { on next line https://codereview.appspot.com/144940043/diff/120001/src/runtime/sema.go File ...
11 years, 1 month ago (2014-09-17 00:18:30 UTC) #7
dvyukov
LGTM otherwise
11 years, 1 month ago (2014-09-17 00:18:39 UTC) #8
khr
11 years, 1 month ago (2014-09-17 00:26:19 UTC) #9
*** Submitted as https://code.google.com/p/go/source/detail?r=367f0d62a03d ***

runtime: always run semacquire on the G stack

semacquire might need to park the currently running G.  It can
only park if called from the G stack (because it has no way of
saving the M stack state).  So all calls to semacquire must come
from the G stack.

The three violators are GOMAXPROCS, ReadMemStats, and WriteHeapDump.
This change moves the semacquire call earlier, out of their C code
and into their Go code.

This seldom caused bugs because semacquire seldom actually had
to park the caller.  But it did happen intermittently.

Fixes issue 8749

LGTM=dvyukov
R=golang-codereviews, dvyukov, bradfitz
CC=golang-codereviews
https://codereview.appspot.com/144940043
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b