[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [RFC/PATCH v5 1/2] hypervisor: XENMEM_claim_pages (subop of existing) hypercall



On Tue, Nov 20, 2012 at 10:27 AM, Dan Magenheimer
<dan.magenheimer@xxxxxxxxxx> wrote:
> @@ -680,7 +680,7 @@ static int page_make_private(struct domain *d, struct 
> page_info *page)
>      ASSERT(page_get_owner(page) == dom_cow);
>      page_set_owner(page, d);
>
> -    if ( d->tot_pages++ == 0 )
> +    if ( domain_increase_tot_pages(d, 1) == 0 )

Here, the pre-incremented value of tot_pages is expected to be used in
the expression..

> @@ -1656,7 +1656,7 @@ gnttab_transfer(
>          }
>
>          /* Okay, add the page to 'e'. */
> -        if ( unlikely(e->tot_pages++ == 0) )
> +        if ( unlikely(domain_increase_tot_pages(e, 1) == 0) )

.. likewise ..

> +unsigned long domain_increase_tot_pages(struct domain *d, unsigned long 
> pages)
> +{
> +    long dom_before, dom_after, dom_claimed, sys_before, sys_after;
> +
> +    ASSERT(spin_is_locked(&d->page_alloc_lock));
> +    if ( !d->unclaimed_pages )
> +        return d->tot_pages += pages;

.. but the post-incremented value is used instead.

> +    spin_lock(&heap_lock);
> +    dom_before = d->unclaimed_pages;
> +    dom_after = dom_before - pages;
> +    if ( (dom_before > 0) && (dom_after < 0) )
> +        dom_claimed = 0;
> +    else
> +        dom_claimed = dom_after;
> +    sys_before = total_unclaimed_pages;
> +    sys_after = sys_before - (dom_before - dom_claimed);
> +    BUG_ON( (sys_before > 0) && (sys_after < 0) );
> +    total_unclaimed_pages = sys_after;
> +    d->unclaimed_pages = dom_claimed;
> +    spin_unlock(&heap_lock);
> +    return d->tot_pages;
> +}

- Matthew Daley

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.