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 <david@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20201202161245.2406143-3-vkuznets@redhat.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
 
                __ClearPageOffline(pg);
                __free_page(pg);
                dm->num_pages_ballooned--;
+               adjust_managed_page_count(pg, 1);
        }
 }
 
                        split_page(pg, get_order(alloc_unit << PAGE_SHIFT));
 
                /* mark all pages offline */
-               for (j = 0; j < alloc_unit; j++)
+               for (j = 0; j < alloc_unit; j++) {
                        __SetPageOffline(pg + j);
+                       adjust_managed_page_count(pg + j, -1);
+               }
 
                bl_resp->range_count++;
                bl_resp->range_array[i].finfo.start_page =