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

Issue 54650044: code review 54650044: runtime: grow stack by copying (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 4 months ago by khr
Modified:
11 years ago
Reviewers:
gobot, dave, rsc, khr1, bsiegert, dvyukov, bradfitz
CC:
rsc, golang-codereviews
Visibility:
Public.

Description

runtime: grow stack by copying On stack overflow, if all frames on the stack are copyable, we copy the frames to a new stack twice as large as the old one. During GC, if a G is using less than 1/4 of its stack, copy the stack to a stack half its size. TODO - Do something about C frames. When a C frame is in the stack segment, it isn't copyable. We allocate a new segment in this case. - For idempotent C code, we can abort it, copy the stack, then retry. I'm working on a separate CL for this. - For other C code, we can raise the stackguard to the lowest Go frame so the next call that Go frame makes triggers a copy, which will then succeed. - Pick a starting stack size? The plan is that eventually we reach a point where the stack contains only copyable frames.

Patch Set 1 #

Patch Set 2 : diff -r 2fcaec19e523 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 3 : diff -r ae14bde9ce3c https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 4 : diff -r a2fe41181fe1 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 5 : diff -r a2fe41181fe1 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 6 : diff -r b869c9fd939c https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 7 : diff -r c92f6dbc444a https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 8 : diff -r c92f6dbc444a https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 9 : diff -r c92f6dbc444a https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 10 : diff -r c92f6dbc444a https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 11 : diff -r 652a653e2809 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 12 : diff -r 652a653e2809 https://khr%40golang.org@code.google.com/p/go/ #

Total comments: 5

Patch Set 13 : diff -r 70499e5fbe5b https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 14 : diff -r 70499e5fbe5b https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 15 : diff -r 70499e5fbe5b https://khr%40golang.org@code.google.com/p/go/ #

Total comments: 5

Patch Set 16 : diff -r 838ade034dc6 https://khr%40golang.org@code.google.com/p/go/ #

Total comments: 15

Patch Set 17 : diff -r 6efc914b865e https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 18 : diff -r 6efc914b865e https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 19 : diff -r 6efc914b865e https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 20 : diff -r 6efc914b865e https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 21 : diff -r 6efc914b865e https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 22 : diff -r d50b94cf70db https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 23 : diff -r efc55d0638f4 https://khr%40golang.org@code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+586 lines, -67 lines) Patch
M src/pkg/runtime/malloc.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3 chunks +29 lines, -0 lines 0 comments Download
M src/pkg/runtime/mem_darwin.c View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/runtime/mem_dragonfly.c View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/runtime/mem_freebsd.c View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/runtime/mem_linux.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/runtime/mem_netbsd.c View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/runtime/mem_openbsd.c View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/runtime/mem_plan9.c View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/runtime/mem_solaris.c View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/runtime/mem_windows.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +13 lines, -0 lines 0 comments Download
M src/pkg/runtime/mgc0.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 7 chunks +11 lines, -27 lines 0 comments Download
M src/pkg/runtime/proc.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 5 chunks +45 lines, -0 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3 chunks +3 lines, -1 line 0 comments Download
M src/pkg/runtime/stack.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/stack.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 9 chunks +426 lines, -32 lines 0 comments Download
M src/pkg/runtime/traceback_arm.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +5 lines, -3 lines 0 comments Download
M src/pkg/runtime/traceback_x86.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +5 lines, -3 lines 0 comments Download

Messages

Total messages: 29
dvyukov
https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c File src/pkg/runtime/stack.c (right): https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c#newcode227 src/pkg/runtime/stack.c:227: // +------------------+ <- frame->argp This is useful. Please make ...
11 years, 4 months ago (2014-02-15 06:43:09 UTC) #1
khr
On 2014/02/15 06:43:09, dvyukov wrote: > https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c > File src/pkg/runtime/stack.c (right): > > https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c#newcode227 > ...
11 years, 4 months ago (2014-02-23 08:57:08 UTC) #2
khr
Hello dvyukov@google.com (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://khr%40golang.org@code.google.com/p/go/
11 years, 4 months ago (2014-02-23 08:57:48 UTC) #3
dvyukov
On 2014/02/23 08:57:08, khr wrote: > On 2014/02/15 06:43:09, dvyukov wrote: > > https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c > ...
11 years, 4 months ago (2014-02-23 10:21:04 UTC) #4
dvyukov
> https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c#newcode357 > > src/pkg/runtime/stack.c:357: if(t != nil && (t->size > PtrSize || (t->kind & ...
11 years, 4 months ago (2014-02-23 10:30:44 UTC) #5
dvyukov
https://codereview.appspot.com/54650044/diff/240001/src/pkg/runtime/mgc0.c File src/pkg/runtime/mgc0.c (right): https://codereview.appspot.com/54650044/diff/240001/src/pkg/runtime/mgc0.c#newcode1614 src/pkg/runtime/mgc0.c:1614: runtime·shrinkstack(gp); I would put this after "runtime·throw("can't scan gchelper ...
11 years, 4 months ago (2014-02-23 13:19:52 UTC) #6
dvyukov
do add new tests I am sure that all.bash does some growing/shrinking, but it's unclear ...
11 years, 4 months ago (2014-02-23 13:38:48 UTC) #7
dvyukov
https://codereview.appspot.com/54650044/diff/240001/src/pkg/runtime/stack.c File src/pkg/runtime/stack.c (right): https://codereview.appspot.com/54650044/diff/240001/src/pkg/runtime/stack.c#newcode103 src/pkg/runtime/stack.c:103: // Stacks are usually allocated with a fixed-size free-list ...
11 years, 4 months ago (2014-02-25 13:46:58 UTC) #8
rsc
https://codereview.appspot.com/54650044/diff/260001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): https://codereview.appspot.com/54650044/diff/260001/src/pkg/runtime/proc.c#newcode198 src/pkg/runtime/proc.c:198: // is stored in a Defer, not in the ...
11 years, 4 months ago (2014-02-25 19:49:42 UTC) #9
rsc
I'd like to try to get this in today or tomorrow. We can add more ...
11 years, 4 months ago (2014-02-25 20:26:20 UTC) #10
khr
On 2014/02/23 10:21:04, dvyukov wrote: > On 2014/02/23 08:57:08, khr wrote: > > On 2014/02/15 ...
11 years, 3 months ago (2014-02-26 22:17:11 UTC) #11
khr
On 2014/02/23 10:30:44, dvyukov wrote: > > > https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c#newcode357 > > > src/pkg/runtime/stack.c:357: if(t != ...
11 years, 3 months ago (2014-02-26 22:43:17 UTC) #12
khr
On 2014/02/23 13:19:52, dvyukov wrote: > https://codereview.appspot.com/54650044/diff/240001/src/pkg/runtime/mgc0.c > File src/pkg/runtime/mgc0.c (right): > > https://codereview.appspot.com/54650044/diff/240001/src/pkg/runtime/mgc0.c#newcode1614 > ...
11 years, 3 months ago (2014-02-26 22:48:33 UTC) #13
khr
On 2014/02/23 13:38:48, dvyukov wrote: > do add new tests > I am sure that ...
11 years, 3 months ago (2014-02-26 22:49:13 UTC) #14
khr
On 2014/02/25 13:46:58, dvyukov wrote: > https://codereview.appspot.com/54650044/diff/240001/src/pkg/runtime/stack.c > File src/pkg/runtime/stack.c (right): > > https://codereview.appspot.com/54650044/diff/240001/src/pkg/runtime/stack.c#newcode103 > ...
11 years, 3 months ago (2014-02-26 22:49:34 UTC) #15
khr
On 2014/02/25 19:49:42, rsc wrote: > https://codereview.appspot.com/54650044/diff/260001/src/pkg/runtime/proc.c > File src/pkg/runtime/proc.c (right): > > https://codereview.appspot.com/54650044/diff/260001/src/pkg/runtime/proc.c#newcode198 > ...
11 years, 3 months ago (2014-02-26 22:55:33 UTC) #16
rsc
LGTM Please submit when you're ready. https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c File src/pkg/runtime/stack.c (right): https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c#newcode357 src/pkg/runtime/stack.c:357: if(t != nil ...
11 years, 3 months ago (2014-02-27 02:35:52 UTC) #17
khr
*** Submitted as https://code.google.com/p/go/source/detail?r=125e69d99b5d *** runtime: grow stack by copying On stack overflow, if all ...
11 years, 3 months ago (2014-02-27 07:28:47 UTC) #18
gobot
This CL appears to have broken the solaris-amd64-solaris11 builder.
11 years, 3 months ago (2014-02-27 07:32:03 UTC) #19
dave_cheney.net
fatal error: sweep of incache span goroutine 41 [running]: runtime.throw(0x7a1dba) /home/dfc/workspace/solaris-amd64-solaris11-125e69d99b5d/go/src/pkg/runtime/panic.c:463 +0x69 fp=0xc208220718 This is ...
11 years, 3 months ago (2014-02-27 07:38:17 UTC) #20
bradfitz
Looks like the whole world's broken, except oddly the linux-race builder. On Wed, Feb 26, ...
11 years, 3 months ago (2014-02-27 08:15:38 UTC) #21
dave_cheney.net
oh dear, so it is. Go linux-race builder, you can do it! On Thu, Feb ...
11 years, 3 months ago (2014-02-27 08:36:38 UTC) #22
bsiegert
Undo maybe?
11 years, 3 months ago (2014-02-27 09:28:57 UTC) #23
khr1
Some facts in issue 7420. I'll revert for the moment, going to bed... On Thu, ...
11 years, 3 months ago (2014-02-27 09:43:22 UTC) #24
dvyukov
On Thu, Feb 27, 2014 at 2:17 AM, <khr@golang.org> wrote: > On 2014/02/23 10:21:04, dvyukov ...
11 years, 3 months ago (2014-02-27 16:05:17 UTC) #25
khr1
#4. Local variables (and args to callee) are in all addresses p such that frame->sp ...
11 years, 3 months ago (2014-02-27 16:14:31 UTC) #26
dvyukov
On 2014/02/23 08:57:08, khr wrote: > On 2014/02/15 06:43:09, dvyukov wrote: > > https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c > ...
11 years, 3 months ago (2014-03-04 06:20:19 UTC) #27
khr1
On Mon, Mar 3, 2014 at 10:20 PM, <dvyukov@google.com> wrote: > On 2014/02/23 08:57:08, khr ...
11 years, 3 months ago (2014-03-04 21:51:49 UTC) #28
dvyukov
11 years ago (2014-05-27 17:55:53 UTC) #29
mailed https://codereview.appspot.com/98640043

On Thu, Feb 27, 2014 at 8:14 PM, Keith Randall <khr@google.com> wrote:
> #4.
>
> Local variables (and args to callee) are in all addresses p such that
> frame->sp <= p < frame->varp.
>
> Return address info is in all addresses p such that frame->varp <= p <
> frame->argp.
>
> Args from the caller are in addresses p with frame->argp <= p.
>
>
> On Thu, Feb 27, 2014 at 8:04 AM, Dmitry Vyukov <dvyukov@google.com> wrote:
>>
>> On Thu, Feb 27, 2014 at 2:17 AM,  <khr@golang.org> wrote:
>> > On 2014/02/23 10:21:04, dvyukov wrote:
>> >>
>> >> On 2014/02/23 08:57:08, khr wrote:
>> >> > On 2014/02/15 06:43:09, dvyukov wrote:
>> >> > >
>> >
>> >
>> >
https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c
>> >>
>> >> > > File src/pkg/runtime/stack.c (right):
>> >> > >
>> >> > >
>> >> >
>> >
>> >
>> >
>> >
https://codereview.appspot.com/54650044/diff/140002/src/pkg/runtime/stack.c#n...
>> >>
>> >> > > src/pkg/runtime/stack.c:227: // +------------------+ <-
>> >
>> > frame->argp
>> >>
>> >> > > This is useful.
>> >> > > Please make it clear whether argp (varp/sp) points to the first
>> >
>> > word of
>> >>
>> >> "args
>> >> > > from caller" or to the "return address". Obviously it cannot point
>> >
>> > in
>> >>
>> >> between
>> >> > > words :)
>> >> >
>> >> > Argp does point "in between".  It marks the separation point between
>> >
>> > the
>> >>
>> >> return
>> >> > address and the args.  I'd be happy to make this clearer but I'm not
>> >
>> > sure what
>> >>
>> >> > about
>> >> > it is confusing.
>> >
>> >
>> >> Pointers can't point in between words. A pointer can point either at
>> >
>> > (1) the
>> >>
>> >> first word of argp or at (2) the ret addr or (3) at something in
>> >
>> > between (if
>> >>
>> >> it's the case please add that something to the picture).
>> >> The picture is confusing because it does not allow to me to answer the
>> >
>> > question
>> >>
>> >> -- what I get if I dereference the pointer.
>> >> I mean something along the lines of:
>> >
>> >
>> >
>> >> // +------------------+
>> >> // |  return address  |
>> >> // +------------------+
>> >> // |                          |  <- frame->varp
>> >> // |     locals       |
>> >> // |                          |
>> >> // +------------------+
>> >
>> >
>> > I'd disagree with you here.  The pointers involved (argp,varp,sp) don't
>> > point at particular items in memory.  They demarcate ranges of memory.
>> > You never
>> > dereference them directly; instead you compare them, like sp <= p && p <
>> > varp.
>>
>>
>> Is anything of the following true?
>> 1. varp points to the first word of local variables?
>> 2. varp points to the word right before first word of local variables?
>> 3. varp points to the last word of local variables?
>> 4. varp points to the word right after local variables?
>>
>> I can't understand how it can point nowhere/between words. When we
>> scan frames in GC we need to know whether we need to dereference varp,
>> varp+1 or varp-1.
>
>
Sign in to reply to this message.

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