xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xensource.com, tim@xen.org, Ian.Campbell@citrix.com
Subject: Re: [PATCH v3 1/3] xen/arm: implement steal_page
Date: Fri, 9 Aug 2013 11:46:28 -0400	[thread overview]
Message-ID: <20130809154628.GH5637@phenom.dumpdata.com> (raw)
In-Reply-To: <1375720856-8593-1-git-send-email-stefano.stabellini@eu.citrix.com>

On Mon, Aug 05, 2013 at 05:40:54PM +0100, Stefano Stabellini wrote:
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
>  xen/arch/arm/mm.c |   43 +++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 43 insertions(+), 0 deletions(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index f301e65..ea64c03 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -751,6 +751,49 @@ int donate_page(struct domain *d, struct page_info *page, unsigned int memflags)
>  int steal_page(
>      struct domain *d, struct page_info *page, unsigned int memflags)
>  {
> +    unsigned long x, y;
> +    bool_t drop_dom_ref = 0;

Shouldn't this be true or false?

> +
> +    spin_lock(&d->page_alloc_lock);
> +
> +    if ( is_xen_heap_page(page) || (page_get_owner(page) != d) )
> +        goto fail;
> +
> +    /*
> +     * We require there is just one reference (PGC_allocated). We temporarily
> +     * drop this reference now so that we can safely swizzle the owner.
> +     */
> +    y = page->count_info;
> +    do {
> +        x = y;
> +        if ( (x & (PGC_count_mask|PGC_allocated)) != (1 | PGC_allocated) )
> +            goto fail;
> +        y = cmpxchg(&page->count_info, x, x & ~PGC_count_mask);
> +    } while ( y != x );
> +
> +    /* Swizzle the owner then reinstate the PGC_allocated reference. */
> +    page_set_owner(page, NULL);
> +    y = page->count_info;
> +    do {
> +        x = y;
> +        BUG_ON((x & (PGC_count_mask|PGC_allocated)) != PGC_allocated);
> +    } while ( (y = cmpxchg(&page->count_info, x, x | 1)) != x );
> +
> +    /* Unlink from original owner. */
> +    if ( !(memflags & MEMF_no_refcount) && !domain_adjust_tot_pages(d, -1) )
> +        drop_dom_ref = 1;
> +    page_list_del(page, &d->page_list);
> +
> +    spin_unlock(&d->page_alloc_lock);
> +    if ( unlikely(drop_dom_ref) )
> +        put_domain(d);
> +    return 0;
> +
> + fail:
> +    spin_unlock(&d->page_alloc_lock);
> +    printk("Bad page %p: ed=%p(%u), sd=%p, caf=%08lx, taf=%lx\n",
> +            (void *)page_to_mfn(page), d, d->domain_id,
> +            page_get_owner(page), page->count_info, page->u.inuse.type_info);
>      return -1;
>  }
>  
> -- 
> 1.7.2.5
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

  parent reply	other threads:[~2013-08-09 15:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-05 16:40 [PATCH v3 0/3] introduce XENMEM_get_dma_buf and XENMEM_put_dma_buf Stefano Stabellini
2013-08-05 16:40 ` [PATCH v3 1/3] xen/arm: implement steal_page Stefano Stabellini
2013-08-08  9:55   ` Ian Campbell
2013-08-08 10:37     ` Stefano Stabellini
2013-08-09 15:46   ` Konrad Rzeszutek Wilk [this message]
2013-08-14 13:40     ` Stefano Stabellini
2013-08-05 16:40 ` [PATCH v3 2/3] xen: implement guest_physmap_(un)pin_range Stefano Stabellini
2013-08-08 10:52   ` Ian Campbell
2013-08-14 16:08     ` Stefano Stabellini
2013-08-15 14:32       ` Ian Campbell
2013-08-05 16:40 ` [PATCH v3 3/3] xen: introduce XENMEM_get_dma_buf and XENMEM_put_dma_buf Stefano Stabellini
2013-08-08 10:40   ` Ian Campbell
2013-08-08 14:12     ` Keir Fraser
2013-08-08 14:16       ` Stefano Stabellini
2013-08-08 14:26         ` Tim Deegan
2013-08-08 15:04           ` Stefano Stabellini
2013-08-08 14:27         ` Ian Campbell
2013-08-08 14:47         ` Keir Fraser
2013-08-13 16:05     ` Stefano Stabellini
2013-08-13 22:07       ` Ian Campbell
2013-08-08 11:43   ` Jan Beulich
2013-08-08 14:12     ` Stefano Stabellini
2013-08-08 14:38       ` Jan Beulich
2013-08-08 14:44         ` Stefano Stabellini
2013-08-08 14:50           ` Jan Beulich
2013-08-08 14:54             ` Stefano Stabellini
2013-08-08 14:58               ` Jan Beulich
2013-08-08 15:25   ` Ian Campbell
2013-08-14 16:17     ` Stefano Stabellini
2013-08-15 14:32       ` Ian Campbell

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=20130809154628.GH5637@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --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 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).