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] rio leak
Date: Thu,  5 Dec 2013 20:51:37 -0500	[thread overview]
Message-ID: <a6fb96b0cdd3e20d85658349f968dbac@brasstown.quanstro.net> (raw)
In-Reply-To: <af4b600c70d2c88d71c96e6b980e9e74@felloff.net>

On Thu Dec  5 18:01:07 EST 2013, cinap_lenrek@felloff.net wrote:
> i just tried something out. it appears that _schedexecwait()'s
> purpose is to serve thredwaitchan():
>
>           Threadwaitchan returns a channel of pointers to Waitmsg
>           structures (see wait(2)). When an exec'ed process exits, a
>           pointer to a Waitmsg is sent to this channel.  These Waitmsg
>           structures have been allocated with malloc(2) and should be
>           freed after use.
>
> when threadwaitchan isnt used, we can rfork the execing child
> with RFNOWAIT which will make the process doing the original
> procexecl() not wait for the child.
>
> i just tried this out with rio (and abaco) and it seems to work fine.
>
> diff -r 42807d2e3f4b sys/src/libthread/main.c
> --- a/sys/src/libthread/main.c	Thu Dec 05 22:43:44 2013 +0100
> +++ b/sys/src/libthread/main.c	Fri Dec 06 23:50:34 2013 +0100
> @@ -121,9 +121,10 @@
>  int
>  _schedexec(Execargs *e)
>  {
> -	int pid;
> +	int pid, flag;
>
> -	switch(pid = rfork(RFREND|RFNOTEG|RFFDG|RFMEM|RFPROC)){
> +	flag = (_threadwaitchan == nil) ? RFNOWAIT : 0;
> +	switch(pid = rfork(RFREND|RFNOTEG|RFFDG|RFMEM|RFPROC|flag)){
>  	case 0:
>  		efork(e);
>  	default:
>
> this is saving a couple of few processes. is it worth it?

hey, that's pretty cool.  i'll bet that with this change the leaked memory
actually shows up as leaked.

- erik



      reply	other threads:[~2013-12-06  1:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05  3:22 erik quanstrom
2013-12-05 22:59 ` cinap_lenrek
2013-12-06  1:51   ` erik quanstrom [this message]

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=a6fb96b0cdd3e20d85658349f968dbac@brasstown.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).