Skip to content

Commit c3f86ae

Browse files
fbqgregkh
authored andcommitted
Drivers: hv: balloon: Disable balloon and hot-add accordingly
[ Upstream commit be58027 ] 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 <boqun.feng@gmail.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/20220325023212.1570049-3-boqun.feng@gmail.com Signed-off-by: Wei Liu <wei.liu@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1c9fdb9 commit c3f86ae

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
@@ -1653,6 +1653,38 @@ static void disable_page_reporting(void)
16531653
}
16541654
}
16551655

1656+
static int ballooning_enabled(void)
1657+
{
1658+
/*
1659+
* Disable ballooning if the page size is not 4k (HV_HYP_PAGE_SIZE),
1660+
* since currently it's unclear to us whether an unballoon request can
1661+
* make sure all page ranges are guest page size aligned.
1662+
*/
1663+
if (PAGE_SIZE != HV_HYP_PAGE_SIZE) {
1664+
pr_info("Ballooning disabled because page size is not 4096 bytes\n");
1665+
return 0;
1666+
}
1667+
1668+
return 1;
1669+
}
1670+
1671+
static int hot_add_enabled(void)
1672+
{
1673+
/*
1674+
* Disable hot add on ARM64, because we currently rely on
1675+
* memory_add_physaddr_to_nid() to get a node id of a hot add range,
1676+
* however ARM64's memory_add_physaddr_to_nid() always return 0 and
1677+
* DM_MEM_HOT_ADD_REQUEST doesn't have the NUMA node information for
1678+
* add_memory().
1679+
*/
1680+
if (IS_ENABLED(CONFIG_ARM64)) {
1681+
pr_info("Memory hot add disabled on ARM64\n");
1682+
return 0;
1683+
}
1684+
1685+
return 1;
1686+
}
1687+
16561688
static int balloon_connect_vsp(struct hv_device *dev)
16571689
{
16581690
struct dm_version_request version_req;
@@ -1724,8 +1756,8 @@ static int balloon_connect_vsp(struct hv_device *dev)
17241756
* currently still requires the bits to be set, so we have to add code
17251757
* to fail the host's hot-add and balloon up/down requests, if any.
17261758
*/
1727-
cap_msg.caps.cap_bits.balloon = 1;
1728-
cap_msg.caps.cap_bits.hot_add = 1;
1759+
cap_msg.caps.cap_bits.balloon = ballooning_enabled();
1760+
cap_msg.caps.cap_bits.hot_add = hot_add_enabled();
17291761

17301762
/*
17311763
* Specify our alignment requirements as it relates

0 commit comments

Comments
 (0)