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

Issue 10051045: code review 10051045: runtime: fix scheduler race condition (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 1 month ago by dvyukov
Modified:
12 years ago
Reviewers:
rsc
CC:
golang-dev, rsc
Visibility:
Public.

Description

runtime: fix scheduler race condition In starttheworld() we assume that P's with local work are situated in the beginning of idle P list. However, once we start the first M, it can execute all local G's and steal G's from other P's. That breaks the assumption above. Thus starttheworld() will fail to start some P's with local work. It seems that it can not lead to very bad things, but still it's wrong and breaks other assumtions (e.g. we can have a spinning M with local work). The fix is to collect all P's with local work first, and only then start them.

Patch Set 1 #

Patch Set 2 : diff -r ca145611fa96 https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 3 : diff -r ca145611fa96 https://dvyukov%40google.com@code.google.com/p/go/ #

Total comments: 3

Patch Set 4 : diff -r f5d54688b261 https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 5 : diff -r c855ffd64015 https://dvyukov%40google.com@code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+17 lines, -12 lines) Patch
M src/pkg/runtime/proc.c View 1 2 3 3 chunks +17 lines, -12 lines 0 comments Download

Messages

Total messages: 6
dvyukov
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://dvyukov%40google.com@code.google.com/p/go/
12 years, 1 month ago (2013-06-05 20:19:40 UTC) #1
rsc
https://codereview.appspot.com/10051045/diff/5001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): https://codereview.appspot.com/10051045/diff/5001/src/pkg/runtime/proc.c#newcode444 src/pkg/runtime/proc.c:444: add = false; insert comment before this line, and ...
12 years, 1 month ago (2013-06-10 19:08:35 UTC) #2
dvyukov
https://codereview.appspot.com/10051045/diff/5001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): https://codereview.appspot.com/10051045/diff/5001/src/pkg/runtime/proc.c#newcode444 src/pkg/runtime/proc.c:444: add = false; On 2013/06/10 19:08:35, rsc wrote: > ...
12 years, 1 month ago (2013-06-10 19:24:16 UTC) #3
dvyukov
https://codereview.appspot.com/10051045/diff/5001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): https://codereview.appspot.com/10051045/diff/5001/src/pkg/runtime/proc.c#newcode444 src/pkg/runtime/proc.c:444: add = false; On 2013/06/10 19:08:35, rsc wrote: > ...
12 years, 1 month ago (2013-06-10 19:26:25 UTC) #4
rsc
LGTM Sorry, my mistake. The equivalent of the 'g' variable in the Go runtime is ...
12 years, 1 month ago (2013-06-10 20:25:59 UTC) #5
dvyukov
12 years ago (2013-06-12 14:46:46 UTC) #6
*** Submitted as https://code.google.com/p/go/source/detail?r=8ae475f7599b ***

runtime: fix scheduler race condition
In starttheworld() we assume that P's with local work
are situated in the beginning of idle P list.
However, once we start the first M, it can execute all local G's
and steal G's from other P's.
That breaks the assumption above. Thus starttheworld() will fail
to start some P's with local work.
It seems that it can not lead to very bad things, but still
it's wrong and breaks other assumtions
(e.g. we can have a spinning M with local work).
The fix is to collect all P's with local work first,
and only then start them.

R=golang-dev, rsc
CC=golang-dev
https://codereview.appspot.com/10051045
Sign in to reply to this message.

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