public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: "David Chinner" <dgc@sgi.com>,
	xfs@oss.sgi.com, Xen-devel <xen-devel@lists.xensource.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Mark Williamson" <mark.williamson@cl.cam.ac.uk>,
	"Morten Bøgeskov" <xen-users@morten.bogeskov.dk>,
	xfs-masters@oss.sgi.com
Subject: Re: Interaction between Xen and XFS: stray RW mappings
Date: Sun, 14 Oct 2007 17:57:41 -0700	[thread overview]
Message-ID: <4712BB05.1020701@goop.org> (raw)
In-Reply-To: <200710151415.07248.nickpiggin@yahoo.com.au>

Nick Piggin wrote:
> Yes, as Dave said, vmap (more specifically: vunmap) is very expensive
> because it generally has to invalidate TLBs on all CPUs.
>   

I see.

> I'm looking at some more general solutions to this (already have some
> batching / lazy unmapping that replaces the XFS specific one), however
> they are still likely going to leave vmap mappings around after freeing
> the page.
>   

Hm.  Could there be a call to shoot down any lazy mappings of a page, so
the Xen pagetable code could use it on any pagetable page?  Ideally one
that could be used on any page, but only causes expensive operations
where needed.

> We _could_ hold on to the pages as well, but that's pretty inefficient.
> The memory cost of keeping the mappings around tends to be well under
> 1% the cost of the page itself. OTOH we could also avoid lazy flushes
> on architectures where it is not costly. Either way, it probably would
> require an arch hook or even a couple of ifdefs in mm/vmalloc.c for
> Xen. Although... it would be nice if Xen could take advantage of some
> of these optimisations as well.
>   

In general the lazy unmappings won't worry Xen.  It's only for the
specific case of allocating memory for pagetables.  Xen can do a bit of
extra optimisation for cross-cpu tlb flushes (if the target vcpus are
not currently running, then you don't need to do anything), but they're
still an expensive operation, so the optimisation is definitely useful.

> What's the actual problem for Xen? Anything that can be changed?
>   

Not easily.  Xen doesn't use shadow pagetables.  Instead, it gives the
guest domains direct access to the real CPU's pagetable, but makes sure
they're always mapped RO so that the hypervisor can control updates to
the pagetables (either by trapping writes or via explicit hypercalls). 
This means that when constructing a new pagetable, Xen will verify that
all the mappings of pages making up the new pagetable are RO before
allowing it to be used.  If there are stray RW mappings of those pages,
pagetable construction will fail.

Aside from XFS, the only other case I've found where there could be
stray RW mappings is when using high pages which are still in the kmap
cache; I added an explicit call to flush the kmap cache to handle this. 
If vmap and kmap can be unified (at least the lazy unmap aspects of
them), then that would be a nice little cleanup.

    J

  reply	other threads:[~2007-10-15  0:57 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-12 16:58 Interaction between Xen and XFS: stray RW mappings Jeremy Fitzhardinge
2007-10-12 17:08 ` Jeremy Fitzhardinge
2007-10-14 22:56 ` David Chinner
2007-10-14 23:12   ` Jeremy Fitzhardinge
2007-10-14 23:33     ` David Chinner
2007-10-15  4:15     ` Nick Piggin
2007-10-15  0:57       ` Jeremy Fitzhardinge [this message]
2007-10-15  7:26         ` Nick Piggin
2007-10-15  3:42           ` Jeremy Fitzhardinge
2007-10-15  4:11             ` David Chinner
2007-10-15  4:18               ` Jeremy Fitzhardinge
2007-10-15  4:25                 ` David Chinner
2007-10-15  8:31                   ` [xfs-masters] " Christoph Hellwig
2007-10-22  3:18       ` dean gaudet
2007-10-22  3:34         ` Jeremy Fitzhardinge
2007-10-22  4:28           ` dean gaudet
2007-10-22  4:39             ` Nick Piggin
2007-10-22 18:37               ` Jeremy Fitzhardinge
2007-10-22 18:32             ` Jeremy Fitzhardinge
2007-10-22 13:47           ` Andi Kleen
2007-10-22 18:40             ` Jeremy Fitzhardinge
2007-10-22 19:07               ` Andi Kleen
2007-10-22 19:11                 ` Jeremy Fitzhardinge
2007-10-22 22:32                 ` David Chinner
2007-10-22 23:35                   ` Andi Kleen
2007-10-23  0:16                     ` Zachary Amsden
2007-10-23  0:36                     ` David Chinner
2007-10-23  7:04                       ` [patch] " David Chinner
2007-10-23  9:30                         ` Andi Kleen
2007-10-23 12:41                           ` David Chinner
2007-10-23 14:33                             ` Jeremy Fitzhardinge
2007-10-24  4:36                           ` [PATCH] Allow lazy unmapping by taking extra page references V2 David Chinner
2007-10-24  5:08                             ` Jeremy Fitzhardinge
2007-10-24 21:48                               ` [PATCH] Allow lazy unmapping by taking extra page references V3 David Chinner
2007-10-24 22:46                                 ` Jeremy Fitzhardinge
2007-10-24 23:21                                   ` David Chinner
2007-10-23  9:28                       ` Interaction between Xen and XFS: stray RW mappings Andi Kleen
2007-10-15  9:36   ` Andi Kleen
2007-10-15 14:56     ` Nick Piggin
2007-10-15 11:07       ` Andi Kleen
2007-10-15 11:28         ` Nick Piggin
2007-10-15 12:54           ` Andi Kleen
2007-10-21 12:17             ` Dave Airlie
2007-10-21 22:16         ` Benjamin Herrenschmidt
2007-10-22  9:49           ` Andi Kleen

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=4712BB05.1020701@goop.org \
    --to=jeremy@goop.org \
    --cc=dgc@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.williamson@cl.cam.ac.uk \
    --cc=nickpiggin@yahoo.com.au \
    --cc=xen-devel@lists.xensource.com \
    --cc=xen-users@morten.bogeskov.dk \
    --cc=xfs-masters@oss.sgi.com \
    --cc=xfs@oss.sgi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox