virtio_balloon: fix shrinker count
authorWei Wang <wei.w.wang@intel.com>
Tue, 19 Nov 2019 10:02:33 +0000 (05:02 -0500)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 20 Nov 2019 07:15:57 +0000 (02:15 -0500)
Instead of multiplying by page order, virtio balloon divided by page
order. The result is that it can return 0 if there are a bit less
than MAX_ORDER - 1 pages in use, and then shrinker scan won't be called.

Cc: stable@vger.kernel.org
Fixes: 71994620bb25 ("virtio_balloon: replace oom notifier with shrinker")
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
drivers/virtio/virtio_balloon.c

index 51134f9a3ee7f93cc8a88719e3f542a62d60c8a4..e05679c478e2b3b22b3d9048d0c5f866ef2ac5ed 100644 (file)
@@ -826,7 +826,7 @@ static unsigned long virtio_balloon_shrinker_count(struct shrinker *shrinker,
        unsigned long count;
 
        count = vb->num_pages / VIRTIO_BALLOON_PAGES_PER_PAGE;
-       count += vb->num_free_page_blocks >> VIRTIO_BALLOON_FREE_PAGE_ORDER;
+       count += vb->num_free_page_blocks << VIRTIO_BALLOON_FREE_PAGE_ORDER;
 
        return count;
 }