linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm/balloon_compaction: avoid duplicate page removal
@ 2019-07-18  9:27 Wei Wang
  2019-07-18 11:37 ` Michael S. Tsirkin
  2019-07-18 12:26 ` Michael S. Tsirkin
  0 siblings, 2 replies; 7+ messages in thread
From: Wei Wang @ 2019-07-18  9:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel, kvm, mst, xdeguillard, namit
  Cc: akpm, pagupta, riel, dave.hansen, david, konrad.wilk,
	yang.zhang.wz, nitesh, lcapitulino, aarcange, pbonzini,
	alexander.h.duyck, dan.j.williams

Fixes: 418a3ab1e778 (mm/balloon_compaction: List interfaces)

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_one.

So remove the list_del balloon_page_enqueue_one, and update some
comments as a reminder.

Signed-off-by: Wei Wang <wei.w.wang@intel.com>
---
ChangeLong:
v1->v2: updated some comments

 mm/balloon_compaction.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index 83a7b61..8639bfc 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -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);
@@ -33,7 +32,7 @@ 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
+ * Driver must call it to properly enqueue balloon pages before definitively
  * removing it from the guest system.
  *
  * Return: number of pages that were enqueued.
@@ -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.
  */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mm/balloon_compaction: avoid duplicate page removal
  2019-07-18  9:27 [PATCH v2] mm/balloon_compaction: avoid duplicate page removal Wei Wang
@ 2019-07-18 11:37 ` Michael S. Tsirkin
  2019-07-18 12:26 ` Michael S. Tsirkin
  1 sibling, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2019-07-18 11:37 UTC (permalink / raw)
  To: Wei Wang
  Cc: linux-mm, linux-kernel, kvm, xdeguillard, namit, akpm, pagupta,
	riel, dave.hansen, david, konrad.wilk, yang.zhang.wz, nitesh,
	lcapitulino, aarcange, pbonzini, alexander.h.duyck,
	dan.j.williams

OK almost. Bunch of typos but I fixed them. Thanks!

On Thu, Jul 18, 2019 at 05:27:20PM +0800, Wei Wang wrote:
> Fixes: 418a3ab1e778 (mm/balloon_compaction: List interfaces)
> 
> 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_one.
> 
> So remove the list_del balloon_page_enqueue_one, and update some
> comments as a reminder.
> 
> Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> ---
> ChangeLong:
> v1->v2: updated some comments
> 
>  mm/balloon_compaction.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
> index 83a7b61..8639bfc 100644
> --- a/mm/balloon_compaction.c
> +++ b/mm/balloon_compaction.c
> @@ -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);
> @@ -33,7 +32,7 @@ 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
> + * Driver must call it to properly enqueue balloon pages before definitively
>   * removing it from the guest system.
>   *
>   * Return: number of pages that were enqueued.
> @@ -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.
>   */
> -- 
> 2.7.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mm/balloon_compaction: avoid duplicate page removal
  2019-07-18  9:27 [PATCH v2] mm/balloon_compaction: avoid duplicate page removal Wei Wang
  2019-07-18 11:37 ` Michael S. Tsirkin
@ 2019-07-18 12:26 ` Michael S. Tsirkin
  2019-07-18 17:02   ` Nadav Amit
  2019-07-18 20:36   ` Andrew Morton
  1 sibling, 2 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2019-07-18 12:26 UTC (permalink / raw)
  To: Wei Wang
  Cc: linux-mm, linux-kernel, kvm, xdeguillard, namit, akpm, pagupta,
	riel, dave.hansen, david, konrad.wilk, yang.zhang.wz, nitesh,
	lcapitulino, aarcange, pbonzini, alexander.h.duyck,
	dan.j.williams

On Thu, Jul 18, 2019 at 05:27:20PM +0800, Wei Wang wrote:
> Fixes: 418a3ab1e778 (mm/balloon_compaction: List interfaces)
> 
> 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_one.
> 
> So remove the list_del balloon_page_enqueue_one, and update some
> comments as a reminder.
> 
> Signed-off-by: Wei Wang <wei.w.wang@intel.com>


ok I posted v3 with typo fixes. 1/2 is this patch with comment changes. Pls take a look.

> ---
> ChangeLong:
> v1->v2: updated some comments
> 
>  mm/balloon_compaction.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
> index 83a7b61..8639bfc 100644
> --- a/mm/balloon_compaction.c
> +++ b/mm/balloon_compaction.c
> @@ -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);
> @@ -33,7 +32,7 @@ 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
> + * Driver must call it to properly enqueue balloon pages before definitively
>   * removing it from the guest system.
>   *
>   * Return: number of pages that were enqueued.
> @@ -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.
>   */
> -- 
> 2.7.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mm/balloon_compaction: avoid duplicate page removal
  2019-07-18 12:26 ` Michael S. Tsirkin
@ 2019-07-18 17:02   ` Nadav Amit
  2019-07-18 20:36   ` Andrew Morton
  1 sibling, 0 replies; 7+ messages in thread
From: Nadav Amit @ 2019-07-18 17:02 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Wei Wang, Linux-MM, LKML, kvm list, Xavier Deguillard,
	Andrew Morton, pagupta, Rik van Riel, Dave Hansen,
	David Hildenbrand, Konrad Rzeszutek Wilk, yang.zhang.wz, nitesh,
	lcapitulino, aarcange, pbonzini, alexander.h.duyck,
	dan.j.williams

> On Jul 18, 2019, at 5:26 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> 
> On Thu, Jul 18, 2019 at 05:27:20PM +0800, Wei Wang wrote:
>> Fixes: 418a3ab1e778 (mm/balloon_compaction: List interfaces)
>> 
>> 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_one.
>> 
>> So remove the list_del balloon_page_enqueue_one, and update some
>> comments as a reminder.
>> 
>> Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> 
> 
> ok I posted v3 with typo fixes. 1/2 is this patch with comment changes. Pls take a look.

Thanks (Wei, Michael) for taking care of it. Please cc me on future
iterations of the patch.

Acked-by: Nadav Amit <namit@vmware.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mm/balloon_compaction: avoid duplicate page removal
  2019-07-18 12:26 ` Michael S. Tsirkin
  2019-07-18 17:02   ` Nadav Amit
@ 2019-07-18 20:36   ` Andrew Morton
  2019-07-18 20:42     ` Michael S. Tsirkin
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2019-07-18 20:36 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Wei Wang, linux-mm, linux-kernel, kvm, xdeguillard, namit,
	pagupta, riel, dave.hansen, david, konrad.wilk, yang.zhang.wz,
	nitesh, lcapitulino, aarcange, pbonzini, alexander.h.duyck,
	dan.j.williams

On Thu, 18 Jul 2019 08:26:11 -0400 "Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Thu, Jul 18, 2019 at 05:27:20PM +0800, Wei Wang wrote:
> > Fixes: 418a3ab1e778 (mm/balloon_compaction: List interfaces)
> > 
> > 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_one.
> > 
> > So remove the list_del balloon_page_enqueue_one, and update some
> > comments as a reminder.
> > 
> > Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> 
> 
> ok I posted v3 with typo fixes. 1/2 is this patch with comment changes. Pls take a look.

I really have no idea what you're talking about here :(.  Some other
discussion and patch thread, I suppose.

You're OK with this patch?

Should this patch have cc:stable?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mm/balloon_compaction: avoid duplicate page removal
  2019-07-18 20:36   ` Andrew Morton
@ 2019-07-18 20:42     ` Michael S. Tsirkin
  2019-07-18 20:46       ` Michael S. Tsirkin
  0 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2019-07-18 20:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Wei Wang, linux-mm, linux-kernel, kvm, xdeguillard, namit,
	pagupta, riel, dave.hansen, david, konrad.wilk, yang.zhang.wz,
	nitesh, lcapitulino, aarcange, pbonzini, alexander.h.duyck,
	dan.j.williams

On Thu, Jul 18, 2019 at 01:36:26PM -0700, Andrew Morton wrote:
> On Thu, 18 Jul 2019 08:26:11 -0400 "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > On Thu, Jul 18, 2019 at 05:27:20PM +0800, Wei Wang wrote:
> > > Fixes: 418a3ab1e778 (mm/balloon_compaction: List interfaces)
> > > 
> > > 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_one.
> > > 
> > > So remove the list_del balloon_page_enqueue_one, and update some
> > > comments as a reminder.
> > > 
> > > Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> > 
> > 
> > ok I posted v3 with typo fixes. 1/2 is this patch with comment changes. Pls take a look.
> 
> I really have no idea what you're talking about here :(.  Some other
> discussion and patch thread, I suppose.
> 
> You're OK with this patch?

Not exactly. I will send v5 soon, you will be CC'd.

> Should this patch have cc:stable?

Yes. Sorry.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mm/balloon_compaction: avoid duplicate page removal
  2019-07-18 20:42     ` Michael S. Tsirkin
@ 2019-07-18 20:46       ` Michael S. Tsirkin
  0 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2019-07-18 20:46 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Wei Wang, linux-mm, linux-kernel, kvm, xdeguillard, namit,
	pagupta, riel, dave.hansen, david, konrad.wilk, yang.zhang.wz,
	nitesh, lcapitulino, aarcange, pbonzini, alexander.h.duyck,
	dan.j.williams

On Thu, Jul 18, 2019 at 04:42:50PM -0400, Michael S. Tsirkin wrote:
> On Thu, Jul 18, 2019 at 01:36:26PM -0700, Andrew Morton wrote:
> > On Thu, 18 Jul 2019 08:26:11 -0400 "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > 
> > > On Thu, Jul 18, 2019 at 05:27:20PM +0800, Wei Wang wrote:
> > > > Fixes: 418a3ab1e778 (mm/balloon_compaction: List interfaces)
> > > > 
> > > > 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_one.
> > > > 
> > > > So remove the list_del balloon_page_enqueue_one, and update some
> > > > comments as a reminder.
> > > > 
> > > > Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> > > 
> > > 
> > > ok I posted v3 with typo fixes. 1/2 is this patch with comment changes. Pls take a look.
> > 
> > I really have no idea what you're talking about here :(.  Some other
> > discussion and patch thread, I suppose.
> > 
> > You're OK with this patch?
> 
> Not exactly. I will send v5 soon, you will be CC'd.

Just done. Do you see it?

> > Should this patch have cc:stable?
> 
> Yes. Sorry.

Actually no - 418a3ab1e778 is new since 5.2.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-07-18 20:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-18  9:27 [PATCH v2] mm/balloon_compaction: avoid duplicate page removal Wei Wang
2019-07-18 11:37 ` Michael S. Tsirkin
2019-07-18 12:26 ` Michael S. Tsirkin
2019-07-18 17:02   ` Nadav Amit
2019-07-18 20:36   ` Andrew Morton
2019-07-18 20:42     ` Michael S. Tsirkin
2019-07-18 20:46       ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).