All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Deegan <tim@xen.org>
To: Andres Lagar Cavilla <andres@lagarcavilla.org>
Cc: zhen shi <bickys1986@gmail.com>, Olaf Hering <olaf@aepfle.de>,
	Keir Fraser <keir.xen@gmail.com>,
	xen-devel@lists.xensource.com,
	Adin Scannell <adin@gridcentric.ca>
Subject: Re: Re: Re: mapping problems in xenpaging
Date: Thu, 20 Oct 2011 16:31:55 +0100	[thread overview]
Message-ID: <20111020153155.GL49983@ocelot.phlegethon.org> (raw)
In-Reply-To: <CADzFZPsk0_aSYzK+Yap208j3r3chpHzBcq+1kYfQc54d-bYkOQ@mail.gmail.com>

At 10:54 -0400 on 20 Oct (1319108045), Andres Lagar Cavilla wrote:
> On Thu, Oct 20, 2011 at 6:13 AM, Tim Deegan <tim@xen.org> wrote:
> > At 13:59 -0400 on 13 Oct (1318514390), Andres Lagar Cavilla wrote:
> >> Good stuff Tim, let me summarize:
> >>
> >>
> >> - The key is to obtain exclusive access to a p2m entry, or range [gfn,
> >> gfn + 1<<order). This exclusive access lasts beyond the actual lookup,
> >> until the caller is finished with modifications, to prevent the p2m
> >> mapping changing underfoot.
> >
> > Yes.  It only excludes concurrent updates, not concurrent lookups, so in
> > that way it's effectively a per-range MRSW lock, implemented with
> > refcounts.  (I feel like I'm working around in a circle to your first
> > suggestion!)
> 
> That's great because ... I'm working around in a circle 180 degrees opposite :)
> 
> I think it's important to untangle page liveness from mapping mutex
> access. That's why I favor Keir's approach of just locking the thing,
> no MSRW. Reasons:
> 1. Very common idiom throughout the code is to get_entry -> set_entry.
> How do we do that in an MSRW, atomically?

Callers that want to do get/set would have to acquire the write lock
during the first lookup.

> 2. You're concerned about foreign mappings, rightly so. With mutex
> access to the p2m mapping, we can ensure the page refcount increases
> atomically in the context of building the foreign mapping. This will
> keep the page alive and unable to be swapped/shared/whatever. We only
> lock the p2m entry while building the p2m mapping.

Ah - that's where we differ.  As far as I can see, in order to be
effective, the p2m entry must remain locked until the foreign mapping is
destroyed.  Otherwise, later p2m updates can make the mapping stale.

> 3. Recursive locking for different purposes is just easier without
> refcounts (generalization of reason 1)
> 4. Note that in your qemu/x86_emulate example, qemu's mapping does not
> prevent x86_emulate from progress, as qemu will have relinquished
> locks once done building the foreign mapping.
> 
> I have a draft implementation of a "tree" of exclusive locks. It's
> still a bit embarrassing to share :)
> The API is more or less
> get_p2m(p2m, gfn, order)
> <do work>
> put_p2m(p2m, gfn, order)
> with recursive get allowed, (unsophisticated) deadlock detection, and
> shortcuts for individual gfn and for global locking (for e.g.
> log_dirty). Give me a couple days for an RFC post.

Great - actual code is always welcome! :)  I might not be able to give
it much attention before next Thursday though.

Tim.

      reply	other threads:[~2011-10-20 15:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10  1:20 Re: mapping problems in xenpaging Andres Lagar Cavilla
2011-10-10  9:21 ` Tim Deegan
2011-10-10 10:06   ` Keir Fraser
2011-10-10 19:31     ` Andres Lagar Cavilla
2011-10-11  6:04       ` Olaf Hering
2011-10-13 15:08       ` Tim Deegan
2011-10-10 19:17   ` Andres Lagar Cavilla
2011-10-13 15:02     ` Tim Deegan
2011-10-13 17:59       ` Andres Lagar Cavilla
2011-10-20 10:13         ` Tim Deegan
2011-10-20 14:54           ` Andres Lagar Cavilla
2011-10-20 15:31             ` Tim Deegan [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=20111020153155.GL49983@ocelot.phlegethon.org \
    --to=tim@xen.org \
    --cc=adin@gridcentric.ca \
    --cc=andres@lagarcavilla.org \
    --cc=bickys1986@gmail.com \
    --cc=keir.xen@gmail.com \
    --cc=olaf@aepfle.de \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.