diff mbox

[1/2,LTS,Utopic,SRU] virtio_balloon: return the amount of freed memory from leak_balloon()

Message ID 1465402218-31985-1-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner June 8, 2016, 4:10 p.m. UTC
From: Raushaniya Maksudova <rmaksudova@parallels.com>

BugLink: http://bugs.launchpad.net/bugs/1587087

This value would be useful in the next patch to provide the amount of
the freed memory for OOM killer.

Signed-off-by: Raushaniya Maksudova <rmaksudova@parallels.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(back ported from commit 1fd9c67203af91977bf3b964ff3744cf74fc6f3f)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

Conflicts:
	drivers/virtio/virtio_balloon.c
---
 drivers/virtio/virtio_balloon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Kamal Mostafa June 14, 2016, 7:43 p.m. UTC | #1

Seth Forshee June 22, 2016, 2:38 p.m. UTC | #2

Kamal Mostafa June 22, 2016, 2:45 p.m. UTC | #3
Applied to LTS-Utopic.

 -Kamal
diff mbox

Patch

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index eb35e3f..8c579c3 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -168,8 +168,9 @@  static void release_pages_by_pfn(const u32 pfns[], unsigned int num)
 	}
 }
 
-static void leak_balloon(struct virtio_balloon *vb, size_t num)
+static unsigned leak_balloon(struct virtio_balloon *vb, size_t num)
 {
+	unsigned num_freed_pages;
 	struct page *page;
 	struct balloon_dev_info *vb_dev_info = vb->vb_dev_info;
 
@@ -186,6 +187,7 @@  static void leak_balloon(struct virtio_balloon *vb, size_t num)
 		vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
 	}
 
+	num_freed_pages = vb->num_pfns;
 	/*
 	 * Note that if
 	 * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
@@ -195,6 +197,7 @@  static void leak_balloon(struct virtio_balloon *vb, size_t num)
 		tell_host(vb, vb->deflate_vq);
 	release_pages_by_pfn(vb->pfns, vb->num_pfns);
 	mutex_unlock(&vb->balloon_lock);
+	return num_freed_pages;
 }
 
 static inline void update_stat(struct virtio_balloon *vb, int idx,