Commit 1fd9c672 authored by Raushaniya Maksudova's avatar Raushaniya Maksudova Committed by Rusty Russell

virtio_balloon: return the amount of freed memory from leak_balloon()

This value would be useful in the next patch to provide the amount of
the freed memory for OOM killer.
Signed-off-by: default avatarRaushaniya Maksudova <rmaksudova@parallels.com>
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 46652a86
...@@ -168,8 +168,9 @@ static void release_pages_by_pfn(const u32 pfns[], unsigned int num) ...@@ -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 page *page;
struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info; 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) ...@@ -186,6 +187,7 @@ static void leak_balloon(struct virtio_balloon *vb, size_t num)
vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE; vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
} }
num_freed_pages = vb->num_pfns;
/* /*
* Note that if * Note that if
* virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST); * 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) ...@@ -195,6 +197,7 @@ static void leak_balloon(struct virtio_balloon *vb, size_t num)
tell_host(vb, vb->deflate_vq); tell_host(vb, vb->deflate_vq);
mutex_unlock(&vb->balloon_lock); mutex_unlock(&vb->balloon_lock);
release_pages_by_pfn(vb->pfns, vb->num_pfns); release_pages_by_pfn(vb->pfns, vb->num_pfns);
return num_freed_pages;
} }
static inline void update_stat(struct virtio_balloon *vb, int idx, static inline void update_stat(struct virtio_balloon *vb, int idx,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment