9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: cinap_lenrek@gmx.de
To: 9fans@9fans.net
Subject: Re: [9fans] duppage
Date: Wed, 29 Feb 2012 15:14:57 +0100	[thread overview]
Message-ID: <7d7ee33e0ce036134194a640c6b2cc81@gmx.de> (raw)
In-Reply-To: <1439e4e1393f1910df845c17ed9eb0bc@hamnavoe.com>

no, this is different.

the XXX - there's a bug is about the new page that
duppage() makes. it explains a race where the new
page is on the freelist and the image cache.
whats important is that when someone (lookpage)
locks the page, its refcount and image/daddr is
consistent wich should be the case as far as i can
see.

if you are paranoid, you can just check in newpage()
auxpage() and duppage() what the refcount of the page
is you just grabbed from the freelist is. if its anything
other than 0, then we hit that XXX bug. (done that,
never triggered)

at the point when duppage unlocks(np), the following
things are possible:

lookpage() could succeed locking np, finding its ref
to be 0 and incrementing its ref and unchaining it
from the freelist. (all while holding palloc lock
so it wont interfere with newpage() or auxpage())

if newpage(), auxpage() or duppage() got the lock first,
the page will be uncached, or point to a differnt
image/daddr (duppage). (with some luck, it might even
point to the same image/daddr, then it just doesnt matter :))

or

someone like newpage() or auxpage() succeeding locking it,
incrementing its ref and removing it from the image cache. the
cachepage() is done by duppage() while holding lock on np
so theres no race.

or

duppage() on another process succeeds with locking np,
removing it from the image cache, and filling it with
contents of the to be duped page and putting it back
in the image cache.

all this looks safe to me, but i might be missing something
of course... anyway, thats about all i know about the
XXX comment :)

back to the duppage bug i was talking about...

the bug that i see is that when duppage() is called,
p has to have a ref of 1. the whole duppage approach
will not work if p is shared with other segments
already.

in the normal case of duppage() when we have p locked,
and p->ref is 1, and we are calling uncachepage(p); before
unlocking p we are safe.

because even if someone like lookpage finds the page in the
image cache, it has to lock it first. when it succeeds
locking p, then lookpage() will find p->image != i because
duppage called uncachepage(p) before unlocking it. so it wont
get shared ever again.

the problem we have is that we temporarily unlock
p to acquire palloc lock, wich opens a chance for
someone to take a ref on p, but duppage doesnt
recheck after reqcquiering the p lock.

if this happens, duppage() has to return and let
fixfault() make a copy for its segment.

--
cinap



  reply	other threads:[~2012-02-29 14:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-25  3:29 cinap_lenrek
2012-02-25 20:09 ` Charles Forsyth
2012-02-26  4:13 ` erik quanstrom
2012-02-29 10:31 ` Richard Miller
2012-02-29 14:14   ` cinap_lenrek [this message]
2012-02-29 19:35     ` Richard Miller
2012-02-29 19:50       ` cinap_lenrek
2012-03-03  9:58         ` Richard Miller
2012-03-03 19:30           ` cinap_lenrek
2012-03-13 23:55 erik quanstrom
2014-06-08 14:53 erik quanstrom
2014-06-08 17:15 ` cinap_lenrek
2014-06-08 17:22 ` Charles Forsyth
2014-06-08 17:34   ` erik quanstrom
2014-06-08 17:50     ` Charles Forsyth
2014-06-08 17:53       ` erik quanstrom
2014-06-08 17:54       ` cinap_lenrek
2014-06-08 18:15         ` erik quanstrom
2014-06-08 18:37           ` Charles Forsyth
2014-06-09  8:23             ` Charles Forsyth
2014-06-09 13:21               ` erik quanstrom
2014-06-10  1:35               ` erik quanstrom
2014-06-10  3:53                 ` cinap_lenrek
2014-06-10 12:58                   ` erik quanstrom
2014-06-10 13:56                     ` Steve Simon
2014-06-10 15:30                       ` erik quanstrom
2014-06-10 14:06                     ` cinap_lenrek
2014-06-11 18:04           ` erik quanstrom
2014-06-08 17:49   ` cinap_lenrek

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=7d7ee33e0ce036134194a640c6b2cc81@gmx.de \
    --to=cinap_lenrek@gmx.de \
    --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).