mm/balloon_compaction: avoid duplicate page removal

A #GP is reported in the guest when requesting balloon inflation via
virtio-balloon. The reason is that the virtio-balloon driver has
removed the page from its internal page list (via balloon_page_pop),
but balloon_page_enqueue_one also calls "list_del"  to do the removal.
This is necessary when it's used from balloon_page_enqueue_list, but
not from balloon_page_enqueue.

Move list_del to balloon_page_enqueue, and update comments accordingly.

Fixes: 418a3ab1e7 (mm/balloon_compaction: List interfaces)
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Wei Wang 2019-07-18 17:27:20 +08:00 committed by Michael S. Tsirkin
parent 5f9e832c13
commit dd42290679
1 changed files with 9 additions and 3 deletions

View File

@ -21,7 +21,6 @@ static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info,
* memory corruption is possible and we should stop execution. * memory corruption is possible and we should stop execution.
*/ */
BUG_ON(!trylock_page(page)); BUG_ON(!trylock_page(page));
list_del(&page->lru);
balloon_page_insert(b_dev_info, page); balloon_page_insert(b_dev_info, page);
unlock_page(page); unlock_page(page);
__count_vm_event(BALLOON_INFLATE); __count_vm_event(BALLOON_INFLATE);
@ -47,6 +46,7 @@ size_t balloon_page_list_enqueue(struct balloon_dev_info *b_dev_info,
spin_lock_irqsave(&b_dev_info->pages_lock, flags); spin_lock_irqsave(&b_dev_info->pages_lock, flags);
list_for_each_entry_safe(page, tmp, pages, lru) { list_for_each_entry_safe(page, tmp, pages, lru) {
list_del(&page->lru);
balloon_page_enqueue_one(b_dev_info, page); balloon_page_enqueue_one(b_dev_info, page);
n_pages++; n_pages++;
} }
@ -128,13 +128,19 @@ struct page *balloon_page_alloc(void)
EXPORT_SYMBOL_GPL(balloon_page_alloc); EXPORT_SYMBOL_GPL(balloon_page_alloc);
/* /*
* balloon_page_enqueue - allocates a new page and inserts it into the balloon * balloon_page_enqueue - inserts a new page 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. * @page: new page to enqueue - allocated using balloon_page_alloc.
* *
* Driver must call it to properly enqueue a new allocated 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.
*
* Drivers must not call balloon_page_enqueue on pages that have been
* pushed to a list with balloon_page_push before removing them with
* balloon_page_pop. To all pages on a list, use balloon_page_list_enqueue
* instead.
*
* 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.
*/ */