|
@@ -10,23 +10,38 @@
|
|
#include <linux/export.h>
|
|
#include <linux/export.h>
|
|
#include <linux/balloon_compaction.h>
|
|
#include <linux/balloon_compaction.h>
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * balloon_page_alloc - allocates a new page for insertion into the balloon
|
|
|
|
+ * page list.
|
|
|
|
+ *
|
|
|
|
+ * Driver must call it to properly allocate a new enlisted balloon page.
|
|
|
|
+ * Driver must call balloon_page_enqueue before definitively removing it from
|
|
|
|
+ * the guest system. This function returns the page address for the recently
|
|
|
|
+ * allocated page or NULL in the case we fail to allocate a new page this turn.
|
|
|
|
+ */
|
|
|
|
+struct page *balloon_page_alloc(void)
|
|
|
|
+{
|
|
|
|
+ struct page *page = alloc_page(balloon_mapping_gfp_mask() |
|
|
|
|
+ __GFP_NOMEMALLOC | __GFP_NORETRY);
|
|
|
|
+ return page;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL_GPL(balloon_page_alloc);
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* balloon_page_enqueue - allocates a new page and inserts it into the balloon
|
|
* balloon_page_enqueue - allocates a new page and inserts it into the balloon
|
|
* page list.
|
|
* page list.
|
|
* @b_dev_info: balloon device descriptor where we will insert a new page to
|
|
* @b_dev_info: balloon device descriptor where we will insert a new page to
|
|
|
|
+ * @page: new page to enqueue - allocated using balloon_page_alloc.
|
|
*
|
|
*
|
|
- * Driver must call it to properly allocate a new enlisted balloon page
|
|
|
|
|
|
+ * Driver must call it to properly enqueue a new allocated balloon page
|
|
* before definitively removing it from the guest system.
|
|
* before definitively removing it from the guest system.
|
|
* This function returns the page address for the recently enqueued page or
|
|
* This function returns the page address for the recently enqueued page or
|
|
* NULL in the case we fail to allocate a new page this turn.
|
|
* NULL in the case we fail to allocate a new page this turn.
|
|
*/
|
|
*/
|
|
-struct page *balloon_page_enqueue(struct balloon_dev_info *b_dev_info)
|
|
|
|
|
|
+void balloon_page_enqueue(struct balloon_dev_info *b_dev_info,
|
|
|
|
+ struct page *page)
|
|
{
|
|
{
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
- struct page *page = alloc_page(balloon_mapping_gfp_mask() |
|
|
|
|
- __GFP_NOMEMALLOC | __GFP_NORETRY);
|
|
|
|
- if (!page)
|
|
|
|
- return NULL;
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
* Block others from accessing the 'page' when we get around to
|
|
* Block others from accessing the 'page' when we get around to
|
|
@@ -39,7 +54,6 @@ struct page *balloon_page_enqueue(struct balloon_dev_info *b_dev_info)
|
|
__count_vm_event(BALLOON_INFLATE);
|
|
__count_vm_event(BALLOON_INFLATE);
|
|
spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
|
|
spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
|
|
unlock_page(page);
|
|
unlock_page(page);
|
|
- return page;
|
|
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(balloon_page_enqueue);
|
|
EXPORT_SYMBOL_GPL(balloon_page_enqueue);
|
|
|
|
|