WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH 2/3 v2] xen-balloon: Add interface to retrieve ba

To: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH 2/3 v2] xen-balloon: Add interface to retrieve ballooned pages
From: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Date: Tue, 8 Mar 2011 16:36:18 +0000
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, "konrad.wilk@xxxxxxxxxx" <konrad.wilk@xxxxxxxxxx>
Delivery-date: Tue, 08 Mar 2011 08:36:55 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1299601445-31128-1-git-send-email-dgdegra@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <1299521208-8531-1-git-send-email-dgdegra@xxxxxxxxxxxxx> <1299601445-31128-1-git-send-email-dgdegra@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Tue, 2011-03-08 at 16:24 +0000, Daniel De Graaf wrote:
> Pages that have been ballooned are useful for other Xen drivers doing
> grant table actions, because these pages have valid struct page/PFNs but
> have no valid MFN so are available for remapping.

The new functions duplicate parts of balloon_retrieve and balloon_append
but without adjusting the various stats, I'm not sure that's right. I
think you should probably just use those functions.

Ian.

> 
> Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
> ---
>  drivers/xen/balloon.c |   60 
> +++++++++++++++++++++++++++++++++++++++++++++++++
>  include/xen/balloon.h |    3 ++
>  2 files changed, 63 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
> index b0a7a92..ec75f26 100644
> --- a/drivers/xen/balloon.c
> +++ b/drivers/xen/balloon.c
> @@ -328,6 +328,66 @@ void balloon_set_new_target(unsigned long target)
>  }
>  EXPORT_SYMBOL_GPL(balloon_set_new_target);
>  
> +/**
> + * alloc_xenballooned_pages - get pages that have been ballooned out
> + * @nr_pages: Number of pages to get
> + * @pages: pages returned
> + * @return number of pages retrieved
> + */
> +int alloc_xenballooned_pages(int nr_pages, struct page** pages)
> +{
> +     int rv = 0;
> +     int alloc_failed = 0;
> +     struct page* page;
> +     mutex_lock(&balloon_mutex);
> +     /* Pages are pulled off the back of the queue to prefer highmem */
> +     while (rv < nr_pages) {
> +             if (list_empty(&ballooned_pages)) {
> +                     if (alloc_failed)
> +                             break;
> +                     if (decrease_reservation(nr_pages - rv))
> +                             alloc_failed = 1;
> +             } else {
> +                     page = list_entry(ballooned_pages.prev,
> +                             struct page, lru);
> +                     list_del(&page->lru);
> +                     pages[rv++] = page;
> +             }
> +     }
> +     mutex_unlock(&balloon_mutex);
> +     return rv;
> +}
> +EXPORT_SYMBOL(alloc_xenballooned_pages);
> +
> +/**
> + * free_xenballooned_pages - return pages retrieved with get_ballooned_pages
> + * @nr_pages: Number of pages
> + * @pages: pages to return
> + */
> +void free_xenballooned_pages(int nr_pages, struct page** pages)
> +{
> +     int i;
> +
> +     mutex_lock(&balloon_mutex);
> +
> +     for (i = 0; i < nr_pages; i++) {
> +             if (!pages[i])
> +                     continue;
> +             if (PageHighMem(pages[i])) {
> +                     list_add_tail(&pages[i]->lru, &ballooned_pages);
> +             } else {
> +                     list_add(&pages[i]->lru, &ballooned_pages);
> +             }
> +     }
> +
> +     /* The balloon may be too large now. Shrink it if needed. */
> +     if (current_target() != balloon_stats.current_pages)
> +             schedule_work(&balloon_worker);
> +
> +     mutex_unlock(&balloon_mutex);
> +}
> +EXPORT_SYMBOL(free_xenballooned_pages);
> +
>  static int __init balloon_init(void)
>  {
>       unsigned long pfn, nr_pages, extra_pfn_end;
> diff --git a/include/xen/balloon.h b/include/xen/balloon.h
> index b2b7c21..72a6927 100644
> --- a/include/xen/balloon.h
> +++ b/include/xen/balloon.h
> @@ -19,3 +19,6 @@ struct balloon_stats {
>  extern struct balloon_stats balloon_stats;
>  
>  void balloon_set_new_target(unsigned long target);
> +
> +int alloc_xenballooned_pages(int nr_pages, struct page** pages);
> +void free_xenballooned_pages(int nr_pages, struct page** pages);



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>