Skip to content

Commit b3d6dd0

Browse files
fbqliuw
authored andcommitted
Drivers: hv: balloon: Support status report for larger page sizes
DM_STATUS_REPORT expects the numbers of pages in the unit of 4k pages (HV_HYP_PAGE) instead of guest pages, so to make it work when guest page sizes are larger than 4k, convert the numbers of guest pages into the numbers of HV_HYP_PAGEs. Note that the numbers of guest pages are still used for tracing because tracing is internal to the guest kernel. Reported-by: Vitaly Kuznetsov <[email protected]> Signed-off-by: Boqun Feng <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent b6cae15 commit b3d6dd0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/hv/hv_balloon.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/slab.h>
1818
#include <linux/kthread.h>
1919
#include <linux/completion.h>
20+
#include <linux/count_zeros.h>
2021
#include <linux/memory_hotplug.h>
2122
#include <linux/memory.h>
2223
#include <linux/notifier.h>
@@ -1130,6 +1131,7 @@ static void post_status(struct hv_dynmem_device *dm)
11301131
struct dm_status status;
11311132
unsigned long now = jiffies;
11321133
unsigned long last_post = last_post_time;
1134+
unsigned long num_pages_avail, num_pages_committed;
11331135

11341136
if (pressure_report_delay > 0) {
11351137
--pressure_report_delay;
@@ -1154,16 +1156,21 @@ static void post_status(struct hv_dynmem_device *dm)
11541156
* num_pages_onlined) as committed to the host, otherwise it can try
11551157
* asking us to balloon them out.
11561158
*/
1157-
status.num_avail = si_mem_available();
1158-
status.num_committed = vm_memory_committed() +
1159+
num_pages_avail = si_mem_available();
1160+
num_pages_committed = vm_memory_committed() +
11591161
dm->num_pages_ballooned +
11601162
(dm->num_pages_added > dm->num_pages_onlined ?
11611163
dm->num_pages_added - dm->num_pages_onlined : 0) +
11621164
compute_balloon_floor();
11631165

1164-
trace_balloon_status(status.num_avail, status.num_committed,
1166+
trace_balloon_status(num_pages_avail, num_pages_committed,
11651167
vm_memory_committed(), dm->num_pages_ballooned,
11661168
dm->num_pages_added, dm->num_pages_onlined);
1169+
1170+
/* Convert numbers of pages into numbers of HV_HYP_PAGEs. */
1171+
status.num_avail = num_pages_avail * NR_HV_HYP_PAGES_IN_PAGE;
1172+
status.num_committed = num_pages_committed * NR_HV_HYP_PAGES_IN_PAGE;
1173+
11671174
/*
11681175
* If our transaction ID is no longer current, just don't
11691176
* send the status. This can happen if we were interrupted

0 commit comments

Comments
 (0)