cx231xx: fix GPIOs for Pixelview SBTVD hybrid
[pandora-kernel.git] / drivers / virtio / virtio_balloon.c
index e058ace..2975c50 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/freezer.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
+#include <linux/module.h>
 
 struct virtio_balloon
 {
@@ -141,6 +142,8 @@ static void leak_balloon(struct virtio_balloon *vb, size_t num)
        /* We can only do one array worth at a time. */
        num = min(num, ARRAY_SIZE(vb->pfns));
 
+       /* We can't release more pages than taken */
+       num = min(num, (size_t)vb->num_pages);
        for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns++) {
                page = list_first_entry(&vb->pages, struct page, lru);
                list_del(&page->lru);
@@ -270,6 +273,12 @@ static int balloon(void *_vballoon)
                else if (diff < 0)
                        leak_balloon(vb, -diff);
                update_balloon_size(vb);
+
+               /*
+                * For large balloon changes, we could spend a lot of time
+                * and always have work to do.  Be nice if preempt disabled.
+                */
+               cond_resched();
        }
        return 0;
 }