9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] lowest valid stack address
Date: Tue,  1 Sep 2009 19:49:33 -0400	[thread overview]
Message-ID: <a3d8f244f00be51b2b9f80895be0be93@quanstro.net> (raw)
In-Reply-To: <dd6fe68a0909011622l20f9e6abv2f3ebf75254b3e1e@mail.gmail.com>

On Tue Sep  1 19:24:33 EDT 2009, rsc@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	other threads:[~2009-09-01 23:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-01 15:08 erik quanstrom
2009-09-01 16:52 ` cinap_lenrek
2009-09-01 16:55   ` erik quanstrom
2009-09-01 17:47     ` erik quanstrom
2009-09-01 23:22       ` Russ Cox
2009-09-01 23:49         ` erik quanstrom [this message]
2009-09-01 23:59           ` Russ Cox
2009-09-02  0:18             ` Devon H. O'Dell
2009-09-02  8:01           ` Andrés Domínguez
2009-09-02  8:58             ` Gorka Guardiola
2009-09-02 13:32               ` erik quanstrom
2009-09-02 13:28             ` Devon H. O'Dell
2009-09-02 13:35               ` erik quanstrom
2009-09-02 14:17                 ` Devon H. O'Dell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a3d8f244f00be51b2b9f80895be0be93@quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).