On Tue Sep  1 19:24:33 EDT 2009, r...@swtch.com wrote:
> I believe that the Stack line in /proc/$pid/segment
> tells you the lowest possible stack address, not
> the amount in use right now.  I looked in the kernel
> source and tried it in 9vx and it confirms my belief.
> I don't have a Plan 9 kernel to try it on right now,
> so maybe I'm wrong.
> 
> Do you have two different /proc/$pid/segment
> with different lowest stack addresses on the Stack line?

evidently i misread /proc/$pid/segment.
and i guess this should have been obvious.
segments don't grow on demand.  but inside
a segment, you can have demand zero fill.

aside: from the overcommit vm discussion.
in http://9fans.net/archive/2000/06/634 rob
says that plan 9 doesn't overcommit vm.
what's the history here?

- erik

---
#include <u.h>
#include <libc.h>

enum {
        Stack   = 15*1024*1024,
};

char *runargv[] = {"/bin/sed", "1q", 0, 0};

void
run(char **argv)
{
        switch(fork()){
        case -1:
                sysfatal("fork: %r");
        case 0:
                exec(*argv, argv);
                sysfatal("exec: %r");
        default:
                waitpid();
        }
}

void
bigstack(void)
{
        char big[Stack];

        memset(big, 0, sizeof big);
        run(runargv);
}

void
main(void)
{
        char buf[64];

        snprint(buf, sizeof buf, "/proc/%ud/segment", getpid());
        runargv[2] = buf;

        run(runargv);
        bigstack();
        exits("");
}

Reply via email to