mm/balloon_compaction: avoid duplicate page removal
Subsystems (2)
Michael S. Tsirkin
maintainerPATCH v3 1/2 mm/balloon_compaction: avoid duplicate page removal
From: Wei Wang <[email protected]>
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.
--- mm/balloon_compaction.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
mm/balloon_compaction.c +9 -3
@@ -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. */ BUG_ON (!trylock_page (page)); -list_del (&page->lru);balloon_page_insert (b_dev_info, page);unlock_page (page);__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);list_for_each_entry_safe (page, tmp, pages, lru) { +list_del (&page->lru);balloon_page_enqueue_one (b_dev_info, page); n_pages++; }
@@ -128,13 +128,19 @@ struct page *balloon_page_alloc(void)EXPORT_SYMBOL_GPL (balloon_page_alloc);/* -* balloon_page_enqueue - allocates a new page and inserts it into the balloon -* page list. +* balloon_page_enqueue - inserts a new page into the balloon page list. +* * @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 enqueue a new allocated balloon page * 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 * NULL in the case we fail to allocate a new page this turn. */
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH v3 2/2 balloon: fix up comments
Lots of comments bitrotted. Fix them up.
--- mm/balloon_compaction.c | 73 +++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 32 deletions(-)
mm/balloon_compaction.c +41 -32
@@ -32,10 +32,10 @@ static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info,* @b_dev_info: balloon device descriptor where we will insert a new page to * @pages: pages to enqueue - allocated using balloon_page_alloc. * -* Driver must call it to properly enqueue a balloon pages before definitively -* removing it from the guest system. +* Driver must call this function to properly enqueue balloon pages before +* definitively removing them from the guest system. * -* Return: number of pages that were enqueued. +* Returns: number of pages that were enqueued. */ size_t balloon_page_list_enqueue (struct balloon_dev_info *b_dev_info,struct list_head *pages)
@@ -63,14 +63,15 @@ EXPORT_SYMBOL_GPL(balloon_page_list_enqueue);* @n_req_pages: number of requested pages. * * Driver must call this function to properly de-allocate a previous enlisted -* balloon pages before definetively releasing it back to the guest system. +* balloon pages before definitively releasing it back to the guest system. * This function tries to remove @n_req_pages from the ballooned pages and * return them to the caller in the @pages list. * -* Note that this function may fail to dequeue some pages temporarily empty due -* to compaction isolated pages. +* Note that this function may fail to dequeue some pages even if the balloon +* isn't empty - since the page list can be temporarily empty due to compaction +* of isolated pages. * -* Return: number of pages that were added to the @pages list. +* Returns: number of pages that were added to the @pages list. */ size_t balloon_page_list_dequeue (struct balloon_dev_info *b_dev_info,struct list_head *pages,size_t n_req_pages)
@@ -112,12 +113,14 @@ EXPORT_SYMBOL_GPL(balloon_page_list_dequeue);/* * balloon_page_alloc - allocates a new page for insertion into the balloon -* page list. +* 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. +* Driver must call this function to properly allocate a new enlisted balloon page. +* Driver must call balloon_page_enqueue before definitively removing the page +* from the guest system. +* +* Returns: struct page address for the allocated page or NULL in case it fails +* to allocate a new page. */ struct page *balloon_page_alloc (void ) {
@@ -130,19 +133,15 @@ EXPORT_SYMBOL_GPL(balloon_page_alloc);/* * balloon_page_enqueue - inserts a new page into the balloon 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 * @page: new page to enqueue - allocated using balloon_page_alloc. * -* Driver must call it to properly enqueue a new allocated balloon page -* before definitively removing it from the guest system. +* Drivers must call this function to properly enqueue a new allocated balloon +* page before definitively removing the page 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 -* NULL in the case we fail to allocate a new page this turn. +* 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 +* enqueue all pages on a list, use balloon_page_list_enqueue instead. */ void balloon_page_enqueue (struct balloon_dev_info *b_dev_info,struct page *page)
@@ -157,14 +156,24 @@ EXPORT_SYMBOL_GPL(balloon_page_enqueue);/* * balloon_page_dequeue - removes a page from balloon's page list and returns -* the its address to allow the driver release the page. +* its address to allow the driver to release the page. * @b_dev_info: balloon device decriptor where we will grab a page from. * -* Driver must call it to properly de-allocate a previous enlisted balloon page -* before definetively releasing it back to the guest system. -* This function returns the page address for the recently dequeued page or -* NULL in the case we find balloon's page list temporarily empty due to -* compaction isolated pages. +* Driver must call this to properly dequeue a previously enqueued page +* before definitively releasing it back to the guest system. +* +* Caller must perform its own accounting to ensure that this +* function is called only if some pages are actually enqueued. +* +* Note that this function may fail to dequeue some pages even if there are +* some enqueued pages - since the page list can be temporarily empty due to +* the compaction of isolated pages. +* +* TODO: remove the caller accounting requirements, and allow caller to wait +* until all pages can be dequeued. +* +* Returns: struct page address for the dequeued page, or NULL if it fails to +* dequeue any pages. */ struct page *balloon_page_dequeue (struct balloon_dev_info *b_dev_info) {
@@ -177,9 +186,9 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info)if (n_pages !=1 ) {/* * If we are unable to dequeue a balloon page because the page -* list is empty and there is no isolated pages, then something +* list is empty and there are no isolated pages, then something * went out of track and some balloon pages are lost. -* BUG() here, otherwise the balloon driver may get stuck into +* BUG() here, otherwise the balloon driver may get stuck in * an infinite loop while attempting to release all its pages. */ spin_lock_irqsave (&b_dev_info->pages_lock, flags);
@@ -230,8 +239,8 @@ int balloon_page_migrate(struct address_space *mapping,/* * We can not easily support the no copy case here so ignore it as it -* is unlikely to be use with ballon pages. See include/linux/hmm.h for -* user of the MIGRATE_SYNC_NO_COPY mode. +* is unlikely to be used with ballon pages. See include/linux/hmm.h for +* a user of the MIGRATE_SYNC_NO_COPY mode. */ if (mode ==MIGRATE_SYNC_NO_COPY )return -EINVAL ;
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH v3 2/2 balloon: fix up comments
In reply to Michael S. TsirkinLots of comments bitrotted. Fix them up.
--- mm/balloon_compaction.c | 73 +++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 32 deletions(-)
mm/balloon_compaction.c +41 -32
@@ -32,10 +32,10 @@ static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info,* @b_dev_info: balloon device descriptor where we will insert a new page to * @pages: pages to enqueue - allocated using balloon_page_alloc. * -* Driver must call it to properly enqueue a balloon pages before definitively -* removing it from the guest system. +* Driver must call this function to properly enqueue balloon pages before +* definitively removing them from the guest system. * -* Return: number of pages that were enqueued. +* Returns: number of pages that were enqueued. */ size_t balloon_page_list_enqueue (struct balloon_dev_info *b_dev_info,struct list_head *pages)
@@ -63,14 +63,15 @@ EXPORT_SYMBOL_GPL(balloon_page_list_enqueue);* @n_req_pages: number of requested pages. * * Driver must call this function to properly de-allocate a previous enlisted -* balloon pages before definetively releasing it back to the guest system. +* balloon pages before definitively releasing it back to the guest system. * This function tries to remove @n_req_pages from the ballooned pages and * return them to the caller in the @pages list. * -* Note that this function may fail to dequeue some pages temporarily empty due -* to compaction isolated pages. +* Note that this function may fail to dequeue some pages even if the balloon +* isn't empty - since the page list can be temporarily empty due to compaction +* of isolated pages. * -* Return: number of pages that were added to the @pages list. +* Returns: number of pages that were added to the @pages list. */ size_t balloon_page_list_dequeue (struct balloon_dev_info *b_dev_info,struct list_head *pages,size_t n_req_pages)
@@ -112,12 +113,14 @@ EXPORT_SYMBOL_GPL(balloon_page_list_dequeue);/* * balloon_page_alloc - allocates a new page for insertion into the balloon -* page list. +* 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. +* Driver must call this function to properly allocate a new enlisted balloon page. +* Driver must call balloon_page_enqueue before definitively removing the page +* from the guest system. +* +* Returns: struct page address for the allocated page or NULL in case it fails +* to allocate a new page. */ struct page *balloon_page_alloc (void ) {
@@ -130,19 +133,15 @@ EXPORT_SYMBOL_GPL(balloon_page_alloc);/* * balloon_page_enqueue - inserts a new page into the balloon 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 * @page: new page to enqueue - allocated using balloon_page_alloc. * -* Driver must call it to properly enqueue a new allocated balloon page -* before definitively removing it from the guest system. +* Drivers must call this function to properly enqueue a new allocated balloon +* page before definitively removing the page 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 -* NULL in the case we fail to allocate a new page this turn. +* 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 +* enqueue all pages on a list, use balloon_page_list_enqueue instead. */ void balloon_page_enqueue (struct balloon_dev_info *b_dev_info,struct page *page)
@@ -157,14 +156,24 @@ EXPORT_SYMBOL_GPL(balloon_page_enqueue);/* * balloon_page_dequeue - removes a page from balloon's page list and returns -* the its address to allow the driver release the page. +* its address to allow the driver to release the page. * @b_dev_info: balloon device decriptor where we will grab a page from. * -* Driver must call it to properly de-allocate a previous enlisted balloon page -* before definetively releasing it back to the guest system. -* This function returns the page address for the recently dequeued page or -* NULL in the case we find balloon's page list temporarily empty due to -* compaction isolated pages. +* Driver must call this to properly dequeue a previously enqueued page +* before definitively releasing it back to the guest system. +* +* Caller must perform its own accounting to ensure that this +* function is called only if some pages are actually enqueued. +* +* Note that this function may fail to dequeue some pages even if there are +* some enqueued pages - since the page list can be temporarily empty due to +* the compaction of isolated pages. +* +* TODO: remove the caller accounting requirements, and allow caller to wait +* until all pages can be dequeued. +* +* Returns: struct page address for the dequeued page, or NULL if it fails to +* dequeue any pages. */ struct page *balloon_page_dequeue (struct balloon_dev_info *b_dev_info) {
@@ -177,9 +186,9 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info)if (n_pages !=1 ) {/* * If we are unable to dequeue a balloon page because the page -* list is empty and there is no isolated pages, then something +* list is empty and there are no isolated pages, then something * went out of track and some balloon pages are lost. -* BUG() here, otherwise the balloon driver may get stuck into +* BUG() here, otherwise the balloon driver may get stuck in * an infinite loop while attempting to release all its pages. */ spin_lock_irqsave (&b_dev_info->pages_lock, flags);
@@ -230,8 +239,8 @@ int balloon_page_migrate(struct address_space *mapping,/* * We can not easily support the no copy case here so ignore it as it -* is unlikely to be use with ballon pages. See include/linux/hmm.h for -* user of the MIGRATE_SYNC_NO_COPY mode. +* is unlikely to be used with ballon pages. See include/linux/hmm.h for +* a user of the MIGRATE_SYNC_NO_COPY mode. */ if (mode ==MIGRATE_SYNC_NO_COPY )return -EINVAL ;
Signature · 1 line
MST
RE: [PATCH v3 2/2] balloon: fix up comments
Quoted 4 lines · Michael S. Tsirkin
/*
*balloon_page_alloc- allocates a new page for insertion into the balloon
- * page list.
+ * page list.
Quoted 8 lines
*
- * Driver must call it to properly allocate a new enlisted balloon page.
- * Driver must callballoon_page_enqueuebefore 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.
+ * Driver must call this function to properly allocate a new enlisted balloon page.
Probably better to say "allocate a new balloon page to enlist" ? "enlisted page" implies that the allocated page has been added to the list, which might be misleading.
Quoted 7 lines
+ * Driver must call
balloon_page_enqueuebefore definitively removing
+ the page
+ * from the guest system.
+ *
+ * Returns: struct page address for the allocated page or NULL in case it fails
+ * to allocate a new page.
*/
Returns: pointer to the page struct of the allocated page, or NULL if allocation fails.
Quoted 22 lines
struct page
*balloon_page_alloc(void)
{mm/balloon_compaction.c +0
-1@@ -130,19 +133,15 @@ EXPORT_SYMBOL_GPL(balloon_page_alloc);/* * balloon_page_enqueue - inserts a new page into the balloon 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
* @page: new page to enqueue - allocated usingballoon_page_alloc. *
- * Driver must call it to properly enqueue a new allocated balloon page
- * before definitively removing it from the guest system.
+ * Drivers must call this function to properly enqueue a new allocated
+ balloon
+ * page before definitively removing the page from the guest system. *
- * Drivers must not callballoon_page_enqueueon pages that have been
- * pushed to a list withballoon_page_pushbefore removing them with
- *balloon_page_pop. To all pages on a list, useballoon_page_list_enqueue
- * instead.
Quoted 8 lines
- *
- * 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.
+ * Drivers must not callballoon_page_enqueueon pages that have been
+ pushed to
+ * a list withballoon_page_pushbefore removing them with
+balloon_page_pop. To
+ * enqueue all pages on a list, useballoon_page_list_enqueueinstead.
"To enqueue a list of pages" ?
Quoted 11 lines
*/
void balloon_page_enqueue(structballoon_dev_info*b_dev_info,mm/balloon_compaction.c +0
-0struct page *page)@@ -157,14 +156,24 @@ EXPORT_SYMBOL_GPL(balloon_page_enqueue);/* * balloon_page_dequeue - removes a page from balloon's page list and returns
- * the its address to allow the driver release the page.
+ * its address to allow the driver to release the page.
* @b_dev_info: balloon device decriptor where we will grab a page from.
Quoted 8 lines
*
- * Driver must call it to properly de-allocate a previous enlisted balloon page
- * before definetively releasing it back to the guest system.
- * This function returns the page address for the recently dequeued page or
- * NULL in the case we find balloon's page list temporarily empty due to
- * compaction isolated pages.
+ * Driver must call this to properly dequeue a previously enqueued page
"call this function"?
Quoted 4 lines
+ * before definitively releasing it back to the guest system.
+ *
+ * Caller must perform its own accounting to ensure that this
+ * function is called only if some pages are actually enqueued.
"only when" ?
Quoted 2 lines
+ *
+ * Note that this function may fail to dequeue some pages even if there
"even when" ?
Quoted 11 lines
+ are
+ * some enqueued pages - since the page list can be temporarily empty
+ due to
+ * the compaction of isolated pages.
+ *
+ * TODO: remove the caller accounting requirements, and allow caller to
+ wait
+ * until all pages can be dequeued.
+ *
+ * Returns: struct page address for the dequeued page, or NULL if it fails to
+ * dequeue any pages.
Returns: pointer to the page struct of the dequeued page, or NULL if no page gets dequeued.
Quoted 21 lines
*/
struct page *balloon_page_dequeue(structballoon_dev_info*b_dev_info)
{ @@ -177,9 +186,9 @@ struct page *balloon_page_dequeue(structballoon_dev_info*b_dev_info)mm/balloon_compaction.c +0
-0if (n_pages !=1 ) {/* * If we are unable to dequeue a balloon page because the page
(quoted diff) +0
-1- * list is empty and there is no isolated pages, thensomething
(quoted diff) +1
-0+ * list is empty and there are no isolated pages, thensomething
(quoted diff) +0
-1* went out of track and some balloon pages are lost. - * BUG() here, otherwise the balloon driver may get stuckinto
mm/balloon_compaction.c +1
-0+* BUG() here, otherwise the balloon driver may get stuck in * an infinite loop while attempting to release all its pages. */ spin_lock_irqsave(&b_dev_info->pages_lock, flags); @@ -230,8 +239,8 @@ int balloon_page_migrate(struct
address_space*mapping,
mm/balloon_compaction.c int balloon_page_migrate(struct address_space *mapping, · line 241
Quoted 2 lines
mm/balloon_compaction.c +0
-0/* * We can not easily support the no copy case here so ignore it as it
"cannot"
Review
Quoted 4 lines
(quoted diff) +0
-1- * is unlikely to be use with ballon pages. See include/linux/hmm.hfor
(quoted diff) +1
-1- * user of the MIGRATE_SYNC_NO_COPY mode. + * is unlikely to be used with ballon pages. See include/linux/hmm.h
"ballon" -> "balloon"
mm/balloon_compaction.c int balloon_page_migrate(struct address_space *mapping, · line 243
Quoted 2 lines
for
mm/balloon_compaction.c +1
-0+* a user of the MIGRATE_SYNC_NO_COPY mode.
"for the usage of" ?
Other parts look good to me.
Best,
Wei
RE: [PATCH v3 2/2] balloon: fix up comments
In reply to Michael S. TsirkinQuoted 4 lines · Michael S. Tsirkin
/*
*balloon_page_alloc- allocates a new page for insertion into the balloon
- * page list.
+ * page list.
Quoted 8 lines
*
- * Driver must call it to properly allocate a new enlisted balloon page.
- * Driver must callballoon_page_enqueuebefore 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.
+ * Driver must call this function to properly allocate a new enlisted balloon page.
Probably better to say "allocate a new balloon page to enlist" ? "enlisted page" implies that the allocated page has been added to the list, which might be misleading.
Quoted 7 lines
+ * Driver must call
balloon_page_enqueuebefore definitively removing
+ the page
+ * from the guest system.
+ *
+ * Returns: struct page address for the allocated page or NULL in case it fails
+ * to allocate a new page.
*/
Returns: pointer to the page struct of the allocated page, or NULL if allocation fails.
Quoted 22 lines
struct page
*balloon_page_alloc(void)
{mm/balloon_compaction.c +0
-1@@ -130,19 +133,15 @@ EXPORT_SYMBOL_GPL(balloon_page_alloc);/* * balloon_page_enqueue - inserts a new page into the balloon 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
* @page: new page to enqueue - allocated usingballoon_page_alloc. *
- * Driver must call it to properly enqueue a new allocated balloon page
- * before definitively removing it from the guest system.
+ * Drivers must call this function to properly enqueue a new allocated
+ balloon
+ * page before definitively removing the page from the guest system. *
- * Drivers must not callballoon_page_enqueueon pages that have been
- * pushed to a list withballoon_page_pushbefore removing them with
- *balloon_page_pop. To all pages on a list, useballoon_page_list_enqueue
- * instead.
Quoted 8 lines
- *
- * 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.
+ * Drivers must not callballoon_page_enqueueon pages that have been
+ pushed to
+ * a list withballoon_page_pushbefore removing them with
+balloon_page_pop. To
+ * enqueue all pages on a list, useballoon_page_list_enqueueinstead.
"To enqueue a list of pages" ?
Quoted 11 lines
*/
void balloon_page_enqueue(structballoon_dev_info*b_dev_info,mm/balloon_compaction.c +0
-0struct page *page)@@ -157,14 +156,24 @@ EXPORT_SYMBOL_GPL(balloon_page_enqueue);/* * balloon_page_dequeue - removes a page from balloon's page list and returns
- * the its address to allow the driver release the page.
+ * its address to allow the driver to release the page.
* @b_dev_info: balloon device decriptor where we will grab a page from.
Quoted 8 lines
*
- * Driver must call it to properly de-allocate a previous enlisted balloon page
- * before definetively releasing it back to the guest system.
- * This function returns the page address for the recently dequeued page or
- * NULL in the case we find balloon's page list temporarily empty due to
- * compaction isolated pages.
+ * Driver must call this to properly dequeue a previously enqueued page
"call this function"?
Quoted 4 lines
+ * before definitively releasing it back to the guest system.
+ *
+ * Caller must perform its own accounting to ensure that this
+ * function is called only if some pages are actually enqueued.
"only when" ?
Quoted 2 lines
+ *
+ * Note that this function may fail to dequeue some pages even if there
"even when" ?
Quoted 11 lines
+ are
+ * some enqueued pages - since the page list can be temporarily empty
+ due to
+ * the compaction of isolated pages.
+ *
+ * TODO: remove the caller accounting requirements, and allow caller to
+ wait
+ * until all pages can be dequeued.
+ *
+ * Returns: struct page address for the dequeued page, or NULL if it fails to
+ * dequeue any pages.
Returns: pointer to the page struct of the dequeued page, or NULL if no page gets dequeued.
Quoted 21 lines
*/
struct page *balloon_page_dequeue(structballoon_dev_info*b_dev_info)
{ @@ -177,9 +186,9 @@ struct page *balloon_page_dequeue(structballoon_dev_info*b_dev_info)mm/balloon_compaction.c +0
-0if (n_pages !=1 ) {/* * If we are unable to dequeue a balloon page because the page
(quoted diff) +0
-1- * list is empty and there is no isolated pages, thensomething
(quoted diff) +1
-0+ * list is empty and there are no isolated pages, thensomething
(quoted diff) +0
-1* went out of track and some balloon pages are lost. - * BUG() here, otherwise the balloon driver may get stuckinto
mm/balloon_compaction.c +1
-0+* BUG() here, otherwise the balloon driver may get stuck in * an infinite loop while attempting to release all its pages. */ spin_lock_irqsave(&b_dev_info->pages_lock, flags); @@ -230,8 +239,8 @@ int balloon_page_migrate(struct
address_space*mapping,
mm/balloon_compaction.c int balloon_page_migrate(struct address_space *mapping, · line 241
Quoted 2 lines
mm/balloon_compaction.c +0
-0/* * We can not easily support the no copy case here so ignore it as it
"cannot"
Review
Quoted 4 lines
(quoted diff) +0
-1- * is unlikely to be use with ballon pages. See include/linux/hmm.hfor
(quoted diff) +1
-1- * user of the MIGRATE_SYNC_NO_COPY mode. + * is unlikely to be used with ballon pages. See include/linux/hmm.h
"ballon" -> "balloon"
mm/balloon_compaction.c int balloon_page_migrate(struct address_space *mapping, · line 243
Quoted 2 lines
for
mm/balloon_compaction.c +1
-0+* a user of the MIGRATE_SYNC_NO_COPY mode.
"for the usage of" ?
Other parts look good to me.
Best,
Wei
Michael S. Tsirkin
maintainerRe: [PATCH v3 2/2] balloon: fix up comments
Quoted 14 lines · Wei W
Quoted 4 lines · Michael S. Tsirkin
/*
*balloon_page_alloc- allocates a new page for insertion into the balloon
- * page list.
+ * page list.Quoted 8 lines
*
- * Driver must call it to properly allocate a new enlisted balloon page.
- * Driver must callballoon_page_enqueuebefore 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.
+ * Driver must call this function to properly allocate a new enlisted balloon page.
Quoted 3 lines
Probably better to say "allocate a new balloon page to enlist" ? "enlisted page" implies that the allocated page has been added to the list, which might be misleading.
right should be just a new balloon page.
Quoted 10 lines
Quoted 8 lines
+ * Driver must call
balloon_page_enqueuebefore definitively removing
+ the page
+ * from the guest system.
+ *
+ * Returns: struct page address for the allocated page or NULL in case it fails
+ * to allocate a new page.
*/Returns: pointer to the page struct of the allocated page, or NULL if allocation fails.
ok
Quoted 26 lines
Quoted 26 lines
struct page
*balloon_page_alloc(void)
{mm/balloon_compaction.c +0
-1@@ -130,19 +133,15 @@ EXPORT_SYMBOL_GPL(balloon_page_alloc);/* * balloon_page_enqueue - inserts a new page into the balloon 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
* @page: new page to enqueue - allocated usingballoon_page_alloc. *
- * Driver must call it to properly enqueue a new allocated balloon page
- * before definitively removing it from the guest system.
+ * Drivers must call this function to properly enqueue a new allocated
+ balloon
+ * page before definitively removing the page from the guest system. *
- * Drivers must not callballoon_page_enqueueon pages that have been
- * pushed to a list withballoon_page_pushbefore removing them with
- *balloon_page_pop. To all pages on a list, useballoon_page_list_enqueue
- * instead.
- *
- * This function returns the page address for the recently enqueued page or
Quoted 8 lines
Quoted 6 lines
- * NULL in the case we fail to allocate a new page this turn.
+ * Drivers must not callballoon_page_enqueueon pages that have been
+ pushed to
+ * a list withballoon_page_pushbefore removing them with
+balloon_page_pop. To
+ * enqueue all pages on a list, useballoon_page_list_enqueueinstead."To enqueue a list of pages" ?
ok
Quoted 6 lines
Quoted 6 lines
*/
void balloon_page_enqueue(structballoon_dev_info*b_dev_info,mm/balloon_compaction.c +0
-0struct page *page)@@ -157,14 +156,24 @@ EXPORT_SYMBOL_GPL(balloon_page_enqueue);
Quoted 16 lines
Quoted 6 lines
(quoted diff) +0
-0/* * balloon_page_dequeue - removes a page from balloon's page list andreturns
- * the its address to allow the driver release the page.
+ * its address to allow the driver to release the page.
* @b_dev_info: balloon device decriptor where we will grab a page from.Quoted 8 lines
*
- * Driver must call it to properly de-allocate a previous enlisted balloon page
- * before definetively releasing it back to the guest system.
- * This function returns the page address for the recently dequeued page or
- * NULL in the case we find balloon's page list temporarily empty due to
- * compaction isolated pages.
+ * Driver must call this to properly dequeue a previously enqueued page"call this function"?
ok
Quoted 8 lines
Quoted 5 lines
+ * before definitively releasing it back to the guest system.
+ *
+ * Caller must perform its own accounting to ensure that this
+ * function is called only if some pages are actually enqueued."only when" ?
I think when would be confusing here since this function is called significantly after pages are first enqueued.
Quoted 4 lines
Quoted 2 lines
+ *
+ * Note that this function may fail to dequeue some pages even if there"even when" ?
same
Quoted 12 lines
Quoted 11 lines
+ are
+ * some enqueued pages - since the page list can be temporarily empty
+ due to
+ * the compaction of isolated pages.
+ *
+ * TODO: remove the caller accounting requirements, and allow caller to
+ wait
+ * until all pages can be dequeued.
+ *
+ * Returns: struct page address for the dequeued page, or NULL if it fails to
+ * dequeue any pages.
Quoted 2 lines
Returns: pointer to the page struct of the dequeued page, or NULL if no page gets dequeued.
was dequeued.
Quoted 26 lines
Quoted 21 lines
*/
struct page *balloon_page_dequeue(structballoon_dev_info*b_dev_info)
{ @@ -177,9 +186,9 @@ struct page *balloon_page_dequeue(structballoon_dev_info*b_dev_info)mm/balloon_compaction.c +0
-0if (n_pages !=1 ) {/* * If we are unable to dequeue a balloon page because the page
(quoted diff) +0
-1- * list is empty and there is no isolated pages, thensomething
(quoted diff) +1
-0+ * list is empty and there are no isolated pages, thensomething
(quoted diff) +0
-1* went out of track and some balloon pages are lost. - * BUG() here, otherwise the balloon driver may get stuckinto
mm/balloon_compaction.c +1
-0+* BUG() here, otherwise the balloon driver may get stuck in * an infinite loop while attempting to release all its pages. */ spin_lock_irqsave(&b_dev_info->pages_lock, flags); @@ -230,8 +239,8 @@ int balloon_page_migrate(struct
address_space*mapping,mm/balloon_compaction.c int balloon_page_migrate(struct address_space *mapping, · line 241
Quoted 2 lines
mm/balloon_compaction.c +0
-0/* * We can not easily support the no copy case here so ignore it as it "cannot"
Quoted 7 lines
Review
Quoted 4 lines
(quoted diff) +0
-1- * is unlikely to be use with ballon pages. See include/linux/hmm.hfor
(quoted diff) +1
-1- * user of the MIGRATE_SYNC_NO_COPY mode. + * is unlikely to be used with ballon pages. See include/linux/hmm.h"ballon" -> "balloon"
ok
Quoted 5 lines
mm/balloon_compaction.c int balloon_page_migrate(struct address_space *mapping, · line 243
Quoted 3 lines
for
mm/balloon_compaction.c +1
-0+* a user of the MIGRATE_SYNC_NO_COPY mode. "for the usage of" ?
Not really I think, it's an example user but does not document usage.
Quoted 6 lines
Other parts look good to me.
Reviewed-by Wei Wang <[email protected]>Best,
Wei
Michael S. Tsirkin
maintainerRe: [PATCH v3 2/2] balloon: fix up comments
In reply to Wang, Wei WQuoted 14 lines · Wei W
Quoted 4 lines · Michael S. Tsirkin
/*
*balloon_page_alloc- allocates a new page for insertion into the balloon
- * page list.
+ * page list.Quoted 8 lines
*
- * Driver must call it to properly allocate a new enlisted balloon page.
- * Driver must callballoon_page_enqueuebefore 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.
+ * Driver must call this function to properly allocate a new enlisted balloon page.
Quoted 3 lines
Probably better to say "allocate a new balloon page to enlist" ? "enlisted page" implies that the allocated page has been added to the list, which might be misleading.
right should be just a new balloon page.
Quoted 10 lines
Quoted 8 lines
+ * Driver must call
balloon_page_enqueuebefore definitively removing
+ the page
+ * from the guest system.
+ *
+ * Returns: struct page address for the allocated page or NULL in case it fails
+ * to allocate a new page.
*/Returns: pointer to the page struct of the allocated page, or NULL if allocation fails.
ok
Quoted 26 lines
Quoted 26 lines
struct page
*balloon_page_alloc(void)
{mm/balloon_compaction.c +0
-1@@ -130,19 +133,15 @@ EXPORT_SYMBOL_GPL(balloon_page_alloc);/* * balloon_page_enqueue - inserts a new page into the balloon 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
* @page: new page to enqueue - allocated usingballoon_page_alloc. *
- * Driver must call it to properly enqueue a new allocated balloon page
- * before definitively removing it from the guest system.
+ * Drivers must call this function to properly enqueue a new allocated
+ balloon
+ * page before definitively removing the page from the guest system. *
- * Drivers must not callballoon_page_enqueueon pages that have been
- * pushed to a list withballoon_page_pushbefore removing them with
- *balloon_page_pop. To all pages on a list, useballoon_page_list_enqueue
- * instead.
- *
- * This function returns the page address for the recently enqueued page or
Quoted 8 lines
Quoted 6 lines
- * NULL in the case we fail to allocate a new page this turn.
+ * Drivers must not callballoon_page_enqueueon pages that have been
+ pushed to
+ * a list withballoon_page_pushbefore removing them with
+balloon_page_pop. To
+ * enqueue all pages on a list, useballoon_page_list_enqueueinstead."To enqueue a list of pages" ?
ok
Quoted 6 lines
Quoted 6 lines
*/
void balloon_page_enqueue(structballoon_dev_info*b_dev_info,mm/balloon_compaction.c +0
-0struct page *page)@@ -157,14 +156,24 @@ EXPORT_SYMBOL_GPL(balloon_page_enqueue);
Quoted 16 lines
Quoted 6 lines
(quoted diff) +0
-0/* * balloon_page_dequeue - removes a page from balloon's page list andreturns
- * the its address to allow the driver release the page.
+ * its address to allow the driver to release the page.
* @b_dev_info: balloon device decriptor where we will grab a page from.Quoted 8 lines
*
- * Driver must call it to properly de-allocate a previous enlisted balloon page
- * before definetively releasing it back to the guest system.
- * This function returns the page address for the recently dequeued page or
- * NULL in the case we find balloon's page list temporarily empty due to
- * compaction isolated pages.
+ * Driver must call this to properly dequeue a previously enqueued page"call this function"?
ok
Quoted 8 lines
Quoted 5 lines
+ * before definitively releasing it back to the guest system.
+ *
+ * Caller must perform its own accounting to ensure that this
+ * function is called only if some pages are actually enqueued."only when" ?
I think when would be confusing here since this function is called significantly after pages are first enqueued.
Quoted 4 lines
Quoted 2 lines
+ *
+ * Note that this function may fail to dequeue some pages even if there"even when" ?
same
Quoted 12 lines
Quoted 11 lines
+ are
+ * some enqueued pages - since the page list can be temporarily empty
+ due to
+ * the compaction of isolated pages.
+ *
+ * TODO: remove the caller accounting requirements, and allow caller to
+ wait
+ * until all pages can be dequeued.
+ *
+ * Returns: struct page address for the dequeued page, or NULL if it fails to
+ * dequeue any pages.
Quoted 2 lines
Returns: pointer to the page struct of the dequeued page, or NULL if no page gets dequeued.
was dequeued.
Quoted 26 lines
Quoted 21 lines
*/
struct page *balloon_page_dequeue(structballoon_dev_info*b_dev_info)
{ @@ -177,9 +186,9 @@ struct page *balloon_page_dequeue(structballoon_dev_info*b_dev_info)mm/balloon_compaction.c +0
-0if (n_pages !=1 ) {/* * If we are unable to dequeue a balloon page because the page
(quoted diff) +0
-1- * list is empty and there is no isolated pages, thensomething
(quoted diff) +1
-0+ * list is empty and there are no isolated pages, thensomething
(quoted diff) +0
-1* went out of track and some balloon pages are lost. - * BUG() here, otherwise the balloon driver may get stuckinto
mm/balloon_compaction.c +1
-0+* BUG() here, otherwise the balloon driver may get stuck in * an infinite loop while attempting to release all its pages. */ spin_lock_irqsave(&b_dev_info->pages_lock, flags); @@ -230,8 +239,8 @@ int balloon_page_migrate(struct
address_space*mapping,mm/balloon_compaction.c int balloon_page_migrate(struct address_space *mapping, · line 241
Quoted 2 lines
mm/balloon_compaction.c +0
-0/* * We can not easily support the no copy case here so ignore it as it "cannot"
Quoted 7 lines
Review
Quoted 4 lines
(quoted diff) +0
-1- * is unlikely to be use with ballon pages. See include/linux/hmm.hfor
(quoted diff) +1
-1- * user of the MIGRATE_SYNC_NO_COPY mode. + * is unlikely to be used with ballon pages. See include/linux/hmm.h"ballon" -> "balloon"
ok
Quoted 5 lines
mm/balloon_compaction.c int balloon_page_migrate(struct address_space *mapping, · line 243
Quoted 3 lines
for
mm/balloon_compaction.c +1
-0+* a user of the MIGRATE_SYNC_NO_COPY mode. "for the usage of" ?
Not really I think, it's an example user but does not document usage.
Quoted 6 lines
Other parts look good to me.
Reviewed-by Wei Wang <[email protected]>Best,
Wei