All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: David Vrabel <david.vrabel@citrix.com>
Cc: dcrisan@flexiant.com, xen-devel@lists.xensource.com,
	Ian.Campbell@citrix.com, alex@alex.org.uk,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH v2 1/2] xen/balloon: set a mapping for ballooned out pages
Date: Tue, 23 Jul 2013 09:58:26 -0400	[thread overview]
Message-ID: <20130723135826.GB3795@phenom.dumpdata.com> (raw)
In-Reply-To: <51ED6317.2060707@citrix.com>

On Mon, Jul 22, 2013 at 05:51:35PM +0100, David Vrabel wrote:
> On 22/07/13 17:28, Stefano Stabellini wrote:
> > Currently ballooned out pages are mapped to 0 and have INVALID_P2M_ENTRY
> > in the p2m. These ballooned out pages are used to map foreign grants
> > by gntdev and blkback (see alloc_xenballooned_pages).
> > 
> > Allocate a page per cpu and map all the ballooned out pages to the
> > corresponding mfn. Set the p2m accordingly. This way reading from a
> > ballooned out page won't cause a kernel crash (see
> > http://lists.xen.org/archives/html/xen-devel/2012-12/msg01154.html).
> 
> Generally in favour of this approach.
> 
> I can't help thinking the "trade page" doesn't really mean anything but
> I can't think of a better, more descriptive name.

scratch page?

> 
> > --- a/drivers/xen/balloon.c
> > +++ b/drivers/xen/balloon.c
> > @@ -36,6 +36,7 @@
> >   * IN THE SOFTWARE.
> >   */
> >  
> > +#include <linux/cpu.h>
> >  #include <linux/kernel.h>
> >  #include <linux/sched.h>
> >  #include <linux/errno.h>
> > @@ -88,6 +89,8 @@ EXPORT_SYMBOL_GPL(balloon_stats);
> >  
> >  /* We increase/decrease in batches which fit in a page */
> >  static xen_pfn_t frame_list[PAGE_SIZE / sizeof(unsigned long)];
> > +static struct page** balloon_trade_pages;
> 
> static DECLARE_PER_CPU(struct page *, balloon_trade_pages);
> 
> >  #ifdef CONFIG_HIGHMEM
> >  #define inc_totalhigh_pages() (totalhigh_pages++)
> > @@ -423,7 +426,8 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
> >  		if (xen_pv_domain() && !PageHighMem(page)) {
> >  			ret = HYPERVISOR_update_va_mapping(
> >  				(unsigned long)__va(pfn << PAGE_SHIFT),
> > -				__pte_ma(0), 0);
> > +				pfn_pte(page_to_pfn(get_balloon_trade_page()),
> > +					PAGE_KERNEL_RO), 0);
> 
> Preemption needs to be disabled while using the trade page, see
> suggestion below.
> 
> > +struct page* get_balloon_trade_page(void)
> > +{
> > +	BUG_ON(balloon_trade_pages[smp_processor_id()] == NULL);
> > +	return balloon_trade_pages[smp_processor_id()];
> > +}
> 
> I think you need a get_balloon_trade_page() and put_balloon_trade_page()
> pair that call get_cpu_var() and put_cpu_var() to ensure that preemption
> is disabled while using it.
> 
> David

  parent reply	other threads:[~2013-07-23 13:58 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22 16:21 [PATCH v2 0/2] make ballooned out pages have a valid mapping at all times Stefano Stabellini
2013-07-22 16:28 ` [PATCH v2 1/2] xen/balloon: set a mapping for ballooned out pages Stefano Stabellini
2013-07-22 16:51   ` David Vrabel
2013-07-22 17:22     ` Ian Campbell
2013-07-22 17:26       ` David Vrabel
2013-07-22 17:32         ` Ian Campbell
2013-07-23  9:58           ` David Vrabel
2013-07-23 14:27             ` Ian Campbell
2013-07-23 15:03               ` David Vrabel
2013-07-23 17:04                 ` Ian Campbell
2013-07-23 17:20                 ` Stefano Stabellini
2013-07-23 17:33                   ` David Vrabel
2013-07-23 12:49           ` Stefano Stabellini
2013-07-23 14:24             ` Ian Campbell
2013-07-23 13:58     ` Konrad Rzeszutek Wilk [this message]
2013-07-22 16:28 ` [PATCH v2 2/2] xen/m2p: use GNTTABOP_unmap_and_replace to reinstate the original mapping Stefano Stabellini
2013-07-22 17:02   ` David Vrabel
2013-07-23 10:35     ` Roger Pau Monné
2013-07-23 12:37       ` Stefano Stabellini
2013-07-23 12:47     ` Stefano Stabellini
2013-07-23 13:57     ` Konrad Rzeszutek Wilk
2013-07-23 14:23       ` Ian Campbell
2013-07-23 14:48         ` Alex Bligh
2013-07-23 14:51           ` Ian Campbell
2013-07-23 15:06             ` Alex Bligh

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=20130723135826.GB3795@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=alex@alex.org.uk \
    --cc=david.vrabel@citrix.com \
    --cc=dcrisan@flexiant.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --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.