[PATCH v2 2/2] virtio-balloon: improve update_balloon_size_func

Wei Wang
Fri, 04 Jan 2019 07:11:53 -0000

There is no need to update the balloon actual register when there is no
ballooning request. This patch avoids update_balloon_size when diff is 0.

Signed-off-by: Wei Wang <wei.w.wang at intel.com>
Reviewed-by: Cornelia Huck <cohuck at redhat.com>
Reviewed-by: Halil Pasic <pasic at linux.ibm.com>
---
 drivers/virtio/virtio_balloon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 35ee762..af1e6d9 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -453,9 +453,12 @@ static void update_balloon_size_func(struct work_struct
*work)
 			  update_balloon_size_work);
 	diff = towards_target(vb);

+	if (!diff)
+		return;
+
 	if (diff > 0)
 		diff -= fill_balloon(vb, diff);
-	else if (diff < 0)
+	else
 		diff += leak_balloon(vb, -diff);
 	update_balloon_size(vb);

--
2.7.4