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] imagereclaim()
Date: Sat,  1 Mar 2014 23:05:19 -0500	[thread overview]
Message-ID: <0b927c978635da089774a72c0af3de19@mikro.quanstro.net> (raw)
In-Reply-To: <122a1b862278abf61a07a806168993ac@felloff.net>

On Sat Mar  1 22:56:25 EST 2014, cinap_lenrek@felloff.net wrote:
> checked nix/port/page.c. your duppage() is wrong.
>
> 	/* don't dup pages with no image */
> 	if(p->ref == 0 || p->image == nil || p->image->notext)
> 		return 0;
>
> 	/*
> 	 *  normal lock ordering is to call
> 	 *  lock(&pga) before lock(p).
> 	 *  To avoid deadlock, we have to drop
> 	 *  our locks and try again.
> 	 */
> 	if(!canlock(&pga)){
> 		unlock(p);
> 		if(up)
> 			sched();
> 		lock(p);
> 		goto retry;
> 	}
>
> you need to check p->ref != 1 instead of p->ref == 0. the page
> passed to duppage() is still cached. after you unlock(p), someone
> can come in and take a reference to the page from the image
> cache (lookpage()), making p->ref > 1 once you get the lock back.
>
> put an assert or print in there after the if(!canlock(&pga){} block
> to check p->ref.

why do i need an assert or print after the unlock?  it should go back
through the loop and notice p->ref != 1.

- erik



  reply	other threads:[~2014-03-02  4:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-01 21:46 cinap_lenrek
2014-03-01 21:55 ` erik quanstrom
2014-03-01 22:22   ` cinap_lenrek
2014-03-01 22:52     ` erik quanstrom
2014-03-01 23:05       ` cinap_lenrek
2014-03-01 23:11         ` erik quanstrom
2014-03-01 23:14         ` Charles Forsyth
2014-03-02  1:21           ` cinap_lenrek
2014-03-02  3:14             ` erik quanstrom
2014-03-02  3:55               ` cinap_lenrek
2014-03-02  4:05                 ` erik quanstrom [this message]
2014-03-02  4:30                   ` cinap_lenrek
2014-03-02  9:48                 ` Charles Forsyth
2014-03-02 18:46                   ` cinap_lenrek
2014-03-02 18:53                     ` Charles Forsyth
2014-03-02 22:59                       ` Anthony Martin
2014-03-03  1:00                         ` erik quanstrom
2014-03-01 23:09     ` Charles Forsyth

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=0b927c978635da089774a72c0af3de19@mikro.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).