Drivers: hv: balloon: hide the inflated balloon pages
PATCH 1/1 Drivers: hv: balloon: hide the inflated balloon pages
When the balloon is inflated we see it as kernel allocated memory and this is confusing especially when it is used as a replacement for memory hot unplug. Hide the balloon with adjust_managed_page_count(). Virtio ballooning driver does this already.
compute_balloon_floor() is adjusted to keep the existing behavior.
Signed-off-by Vitaly Kuznetsov <[email protected]>
--- drivers/hv/hv_balloon.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/hv/hv_balloon.c +14 -9
@@ -1049,7 +1049,10 @@ static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg)static unsigned long compute_balloon_floor (void ) { +unsigned long curram_pages = totalram_pages + + dm_device.num_pages_ballooned;unsigned long min_pages; +#define MB2PAGES (mb) ((mb) << (20 - PAGE_SHIFT))/* Simple continuous piecewiese linear function: * max MiB -> min MiB gradient
@@ -1062,16 +1065,16 @@ static unsigned long compute_balloon_floor(void)* 8192 744 (1/16) * 32768 1512 (1/32) */ -if (totalram_pages <MB2PAGES (128 )) - min_pages =MB2PAGES (8 ) + (totalram_pages >>1 ); -else if (totalram_pages <MB2PAGES (512 )) - min_pages =MB2PAGES (40 ) + (totalram_pages >>2 ); -else if (totalram_pages <MB2PAGES (2048 )) - min_pages =MB2PAGES (104 ) + (totalram_pages >>3 ); -else if (totalram_pages <MB2PAGES (8192 )) - min_pages =MB2PAGES (232 ) + (totalram_pages >>4 ); +if (curram_pages <MB2PAGES (128 )) + min_pages =MB2PAGES (8 ) + (curram_pages >>1 ); +else if (curram_pages <MB2PAGES (512 )) + min_pages =MB2PAGES (40 ) + (curram_pages >>2 ); +else if (curram_pages <MB2PAGES (2048 )) + min_pages =MB2PAGES (104 ) + (curram_pages >>3 ); +else if (curram_pages <MB2PAGES (8192 )) + min_pages =MB2PAGES (232 ) + (curram_pages >>4 );else - min_pages =MB2PAGES (488 ) + (totalram_pages >>5 ); + min_pages =MB2PAGES (488 ) + (curram_pages >>5 );#undef MB2PAGESreturn min_pages; }
@@ -1156,6 +1159,7 @@ static void free_balloon_pages(struct hv_dynmem_device *dm,for (i =0 ; i < num_pages; i++) { pg =pfn_to_page (i + start_frame);__free_page (pg); +adjust_managed_page_count (pg,1 ); dm->num_pages_ballooned--; } }
@@ -1190,6 +1194,7 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm,return i * alloc_unit; dm->num_pages_ballooned += alloc_unit; +adjust_managed_page_count (pg, -alloc_unit);/* * If we allocatted 2M pages; split them so we
Signature · 1 line
2.9.3