Skip to content

Commit d1df458

Browse files
vittyvkliuw
authored andcommitted
hv_balloon: do adjust_managed_page_count() when ballooning/un-ballooning
Unlike virtio_balloon/virtio_mem/xen balloon drivers, Hyper-V balloon driver does not adjust managed pages count when ballooning/un-ballooning and this leads to incorrect stats being reported, e.g. unexpected 'free' output. Note, the calculation in post_status() seems to remain correct: ballooned out pages are never 'available' and we manually add dm->num_pages_ballooned to 'commited'. Suggested-by: David Hildenbrand <[email protected]> Signed-off-by: Vitaly Kuznetsov <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent 7f3f227 commit d1df458

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/hv/hv_balloon.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,7 @@ static void free_balloon_pages(struct hv_dynmem_device *dm,
11981198
__ClearPageOffline(pg);
11991199
__free_page(pg);
12001200
dm->num_pages_ballooned--;
1201+
adjust_managed_page_count(pg, 1);
12011202
}
12021203
}
12031204

@@ -1238,8 +1239,10 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm,
12381239
split_page(pg, get_order(alloc_unit << PAGE_SHIFT));
12391240

12401241
/* mark all pages offline */
1241-
for (j = 0; j < alloc_unit; j++)
1242+
for (j = 0; j < alloc_unit; j++) {
12421243
__SetPageOffline(pg + j);
1244+
adjust_managed_page_count(pg + j, -1);
1245+
}
12431246

12441247
bl_resp->range_count++;
12451248
bl_resp->range_array[i].finfo.start_page =

0 commit comments

Comments
 (0)