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

Issue 185780043: code review 185780043: runtime: simplify lock-free logic in netpoll

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 5 months ago by rsc
Modified:
9 years, 4 months ago
Reviewers:
CC:
austin, dvyukov, rlh, mattn, golang-codereviews
Visibility:
Public.

Description

runtime: simplify lock-free logic in netpoll Before, pd.closing, pd.rt/pd.wt, and pd.rg/pd.wg were all accessed in a lock-free manner. In this CL, the bits being checked in pd.closing and pd.rt/pd.wt are moved into the low bits of pd.rg/pd.wg, so that there is only one memory word being accessed lock-free. Austin, Rick, and I spent two hours at a wall-sized whiteboard covered with the relevant flow of the existing code this morning. We were unable to find a flaw but also unable to convince ourselves it is correct. Having just one lock-free word (one for reader and one for writer, but those are independent) should be much easier to reason about, and it may actually be correct. This change is for Go 1.5, not Go 1.4. (If adding the Go 1.2 locks back to the current implementation fixes the problems we are seeing, we will ship Go 1.4 with locks.)

Patch Set 1 #

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

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

Total comments: 20
Unified diffs Side-by-side diffs Delta from patch set Stats (+212 lines, -191 lines) Patch
M src/runtime/netpoll.go View 1 2 11 chunks +211 lines, -191 lines 20 comments Download
M src/runtime/runtime.h View 1 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 10
rsc
Hello austin, dvyukov, rlh (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
9 years, 5 months ago (2014-12-02 21:50:43 UTC) #1
austin
https://codereview.appspot.com/185780043/diff/40001/src/runtime/netpoll.go File src/runtime/netpoll.go (left): https://codereview.appspot.com/185780043/diff/40001/src/runtime/netpoll.go#oldcode140 src/runtime/netpoll.go:140: err := netpollcheckerr(pd, int32(mode)) Did netpollarm need this check? ...
9 years, 5 months ago (2014-12-03 04:16:36 UTC) #2
dvyukov
Have you taken windows into account? It has significantly different logic. I see that you ...
9 years, 4 months ago (2014-12-03 08:10:21 UTC) #3
rlh
https://codereview.appspot.com/185780043/diff/40001/src/runtime/netpoll.go File src/runtime/netpoll.go (right): https://codereview.appspot.com/185780043/diff/40001/src/runtime/netpoll.go#newcode28 src/runtime/netpoll.go:28: lock mutex Not sure what this lock is intended ...
9 years, 4 months ago (2014-12-03 15:39:20 UTC) #4
dvyukov
I do not see this as a net win. We are exchanging one complex lock-free ...
9 years, 4 months ago (2014-12-03 16:14:13 UTC) #5
mattn
https://codereview.appspot.com/185780043/diff/40001/src/runtime/netpoll.go File src/runtime/netpoll.go (right): https://codereview.appspot.com/185780043/diff/40001/src/runtime/netpoll.go#newcode366 src/runtime/netpoll.go:366: _g_.iowait = status // can use closure in Go ...
9 years, 4 months ago (2014-12-03 16:34:53 UTC) #6
rsc
On Wed, Dec 3, 2014 at 11:14 AM, <dvyukov@google.com> wrote: > I do not see ...
9 years, 4 months ago (2014-12-03 16:52:35 UTC) #7
austin
https://codereview.appspot.com/185780043/diff/40001/src/runtime/netpoll.go File src/runtime/netpoll.go (right): https://codereview.appspot.com/185780043/diff/40001/src/runtime/netpoll.go#newcode308 src/runtime/netpoll.go:308: return atomicloaduintptr(&pd.rg) & pdStatusClosing != 0 This may be ...
9 years, 4 months ago (2014-12-03 17:16:39 UTC) #8
dvyukov
On Wed, Dec 3, 2014 at 5:52 PM, Russ Cox <rsc@golang.org> wrote: > On Wed, ...
9 years, 4 months ago (2014-12-11 16:25:18 UTC) #9
gobot
9 years, 4 months ago (2014-12-19 05:17:24 UTC) #10
R=close

To the author of this CL:

The Go project has moved to Gerrit Code Review.

If this CL should be continued, please see the latest version of
https://golang.org/doc/contribute.html for instructions on
how to set up Git and the Go project's Gerrit codereview plugin,
and then create a new change with your current code.

If there has been discussion on this CL, please give a link to it
(golang.org/cl/185780043 is best) in the description in your
new CL.

Thanks very much.
Sign in to reply to this message.

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