Skip to contentSkip to conversation

virtio_balloon: fix shrinker count

PATCH In review Michael S. Tsirkin 2 participants 2 messages Nov 19, 2019

Subsystems (3)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 virtio_balloon: fix shrinker count

From: Wei Wang <[email protected]>

Instead of multiplying by page order, virtio balloon divided by page order. The result is that it can often return 0 if there are a bit less than MAX_ORDER - 1 pages in use, and then shrinker scan won't be called.

Fixes 71994620bb25 ("virtio_balloon: replace oom notifier with shrinker")
---
 drivers/virtio/virtio_balloon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +1 -1
index 7cee05cdf3fb..65df40f261ab 100644
@@ -825,7 +825,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;
 }
Signature · 1 line
MST
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Michael S. Tsirkin

From: Wei Wang <[email protected]>

Instead of multiplying by page order, virtio balloon divided by page order. The result is that it can often return 0 if there are a bit less than MAX_ORDER - 1 pages in use, and then shrinker scan won't be called.

Fixes 71994620bb25 ("virtio_balloon: replace oom notifier with shrinker")
---
  drivers/virtio/virtio_balloon.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +0 -0
index 7cee05cdf3fb..65df40f261ab 100644

drivers/virtio/virtio_balloon.c static unsigned long virtio_balloon_shrinker_count(struct shrinker *shrinker, · line 831

Quoted 8 lines
drivers/virtio/virtio_balloon.c +1 -1
@@ -825,7 +825,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;
  }
Signature · 3 lines
Thanks,

David / dhildenb