Skip to content

Commit be58027

Browse files
fbqliuw
authored andcommitted
Drivers: hv: balloon: Disable balloon and hot-add accordingly
Currently there are known potential issues for balloon and hot-add on ARM64: * Unballoon requests from Hyper-V should only unballoon ranges that are guest page size aligned, otherwise guests cannot handle because it's impossible to partially free a page. This is a problem when guest page size > 4096 bytes. * Memory hot-add requests from Hyper-V should provide the NUMA node id of the added ranges or ARM64 should have a functional memory_add_physaddr_to_nid(), otherwise the node id is missing for add_memory(). These issues require discussions on design and implementation. In the meanwhile, post_status() is working and essential to guest monitoring. Therefore instead of disabling the entire hv_balloon driver, the ballooning (when page size > 4096 bytes) and hot-add are disabled accordingly for now. Once the issues are fixed, they can be re-enable in these cases. 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 b3d6dd0 commit be58027

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

drivers/hv/hv_balloon.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,38 @@ static void disable_page_reporting(void)
16601660
}
16611661
}
16621662

1663+
static int ballooning_enabled(void)
1664+
{
1665+
/*
1666+
* Disable ballooning if the page size is not 4k (HV_HYP_PAGE_SIZE),
1667+
* since currently it's unclear to us whether an unballoon request can
1668+
* make sure all page ranges are guest page size aligned.
1669+
*/
1670+
if (PAGE_SIZE != HV_HYP_PAGE_SIZE) {
1671+
pr_info("Ballooning disabled because page size is not 4096 bytes\n");
1672+
return 0;
1673+
}
1674+
1675+
return 1;
1676+
}
1677+
1678+
static int hot_add_enabled(void)
1679+
{
1680+
/*
1681+
* Disable hot add on ARM64, because we currently rely on
1682+
* memory_add_physaddr_to_nid() to get a node id of a hot add range,
1683+
* however ARM64's memory_add_physaddr_to_nid() always return 0 and
1684+
* DM_MEM_HOT_ADD_REQUEST doesn't have the NUMA node information for
1685+
* add_memory().
1686+
*/
1687+
if (IS_ENABLED(CONFIG_ARM64)) {
1688+
pr_info("Memory hot add disabled on ARM64\n");
1689+
return 0;
1690+
}
1691+
1692+
return 1;
1693+
}
1694+
16631695
static int balloon_connect_vsp(struct hv_device *dev)
16641696
{
16651697
struct dm_version_request version_req;
@@ -1731,8 +1763,8 @@ static int balloon_connect_vsp(struct hv_device *dev)
17311763
* currently still requires the bits to be set, so we have to add code
17321764
* to fail the host's hot-add and balloon up/down requests, if any.
17331765
*/
1734-
cap_msg.caps.cap_bits.balloon = 1;
1735-
cap_msg.caps.cap_bits.hot_add = 1;
1766+
cap_msg.caps.cap_bits.balloon = ballooning_enabled();
1767+
cap_msg.caps.cap_bits.hot_add = hot_add_enabled();
17361768

17371769
/*
17381770
* Specify our alignment requirements as it relates

0 commit comments

Comments
 (0)