From nobody Sat Jun 20 00:55:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAA01C433EF for ; Fri, 25 Mar 2022 02:33:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347240AbiCYCey (ORCPT ); Thu, 24 Mar 2022 22:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357782AbiCYCeo (ORCPT ); Thu, 24 Mar 2022 22:34:44 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F7C0CD6; Thu, 24 Mar 2022 19:33:07 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id b189so5031216qkf.11; Thu, 24 Mar 2022 19:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vw/ACGTLfd24TEwOsMtKP4JjvUnmGhYZJwx+5xNDMTo=; b=aTFV1PR6CO4w0h+dPvEkd94PPa5+MUuVTFoV2GN6oOUNO1CE6g4mQCQa9qxVo61907 hktftE9csq6AtkHwwvFp10OR0ijgnn2yRpCXTk6Mmz8J+uV4FIU8pAz1ScaigtQZ3eEn ZH3C2ihv8yDLtzyPKgbW7m9MEaRPUanFV6HipTzAcjVXsa2cTqR5n5NDK+LsqCg45OBe H+7n5+WgTVIEKZP7jgpcTiZ3QIQrVgX6coZ9OXQdvJvDyvMVSsr1XPj/lIhi9C7EHYqC RgGnlhDfqr8PBXZif7l9+2tK2XxGJsY9soT4sDTXEUrdwqa43HNNeHzBMMLUJm9tCGp7 EdkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vw/ACGTLfd24TEwOsMtKP4JjvUnmGhYZJwx+5xNDMTo=; b=QPgI0fygTXPyVLaEYhex2UOiZ4N0Tv5X+chASHm6SOlziM9QHfPnzLeJsSSocUx6zU AR8H3abmtkOl1Q/TMyKHKo7V9zCcQyk301ttj254h4NHTFab+1uGgOdGWrWqFSIyFVNL UPNnvXLiMk5y3wzA4UEJDarGdIZdbTz2EAXxg/dEfrkFMt2mGSr5AkeHoUnbgKBqocKv EVH7RpMT2SVYhE/F99gdwTLQPVF4DtuwvYHIBPTxjFTFk30NIeA7Ard4XFzIPL3GYmW0 iYGqC+YfpRrnrKXTwm9yQ0fShOnOWLsRbYxOn6bt9eyjTIdn5rQQ21Z4D9GJkMa0elsl GgIg== X-Gm-Message-State: AOAM532J0Wf+S7j7z+ht88/4nm0foh0EpPQjViU7flNI3AnSLhGKzkkL ME5d4KFnehefWcD5qqAMI3Q= X-Google-Smtp-Source: ABdhPJwVZhPntslu4pfq0kZWLhN5okKsenhhKKE3cL+8rlT/JWxJfPbEdlo2o8CtuJ7/kX6wvCHKrg== X-Received: by 2002:a05:620a:b43:b0:67d:942c:2e03 with SMTP id x3-20020a05620a0b4300b0067d942c2e03mr5427638qkg.303.1648175586629; Thu, 24 Mar 2022 19:33:06 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id y15-20020a05622a004f00b002e1aaa1738dsm4009736qtw.12.2022.03.24.19.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 19:33:05 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id 7C3F827C005A; Thu, 24 Mar 2022 22:33:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 24 Mar 2022 22:33:04 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudehtddggeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsg hoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtieeg qddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhigi hmvgdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 24 Mar 2022 22:33:03 -0400 (EDT) From: Boqun Feng To: Wei Liu Cc: Vitaly Kuznetsov , linux-hyperv@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Dexuan Cui , Michael Kelley , David Hildenbrand , linux-kernel@vger.kernel.org, Boqun Feng Subject: [PATCH v2 1/2] Drivers: hv: balloon: Support status report for larger page sizes Date: Fri, 25 Mar 2022 10:32:11 +0800 Message-Id: <20220325023212.1570049-2-boqun.feng@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325023212.1570049-1-boqun.feng@gmail.com> References: <20220325023212.1570049-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Boqun Feng Reviewed-by: Michael Kelley --- drivers/hv/hv_balloon.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index f2d05bff4245..062156b88a87 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1130,6 +1131,7 @@ static void post_status(struct hv_dynmem_device *dm) struct dm_status status; unsigned long now =3D jiffies; unsigned long last_post =3D last_post_time; + unsigned long num_pages_avail, num_pages_committed; =20 if (pressure_report_delay > 0) { --pressure_report_delay; @@ -1154,16 +1156,21 @@ static void post_status(struct hv_dynmem_device *dm) * num_pages_onlined) as committed to the host, otherwise it can try * asking us to balloon them out. */ - status.num_avail =3D si_mem_available(); - status.num_committed =3D vm_memory_committed() + + num_pages_avail =3D si_mem_available(); + num_pages_committed =3D vm_memory_committed() + dm->num_pages_ballooned + (dm->num_pages_added > dm->num_pages_onlined ? dm->num_pages_added - dm->num_pages_onlined : 0) + compute_balloon_floor(); =20 - trace_balloon_status(status.num_avail, status.num_committed, + trace_balloon_status(num_pages_avail, num_pages_committed, vm_memory_committed(), dm->num_pages_ballooned, dm->num_pages_added, dm->num_pages_onlined); + + /* Convert numbers of pages into numbers of HV_HYP_PAGEs. */ + status.num_avail =3D num_pages_avail * NR_HV_HYP_PAGES_IN_PAGE; + status.num_committed =3D num_pages_committed * NR_HV_HYP_PAGES_IN_PAGE; + /* * If our transaction ID is no longer current, just don't * send the status. This can happen if we were interrupted --=20 2.35.1 From nobody Sat Jun 20 00:55:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2753DC433EF for ; Fri, 25 Mar 2022 02:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357788AbiCYCeq (ORCPT ); Thu, 24 Mar 2022 22:34:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357774AbiCYCem (ORCPT ); Thu, 24 Mar 2022 22:34:42 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E46AE1A; Thu, 24 Mar 2022 19:33:08 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id d65so1563785qke.5; Thu, 24 Mar 2022 19:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IXFrpdSrsWxPJJKP0L3fMCW4KHzAGEDahZ4BTeY25yA=; b=Q9pj/sZr5QY+q11G2WBBcCqSkmfQvsi70r24pAGLdOMDRpZ6IWjI8npDn67bPSf1wE oSy39cN+T/NitKrQRrw44b8NQdE41dDRLno4F3fLQGe9rbwo+rg0FBuXXYlqpLEnzuo7 aCYIF5U22rsDXy0sCTfhj6rr5TTi9CPNWlcy1/Tgkf1BWBtv5Rf3tdUKfMOxwYsBb29N HzewAy8WR+4b7HHI7R4SlmFkGT60EoUcC51YNJvNqkmo5VerJ4GhxExM3BAc36yYtebU yOlru3me8lMHMHFm+XvAzYo+se5C7NV2P/aA+/mCoPE7xO8vE+RBJSJGZO3eyPrBLTq9 eLng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IXFrpdSrsWxPJJKP0L3fMCW4KHzAGEDahZ4BTeY25yA=; b=DSaj9Ibg4ggRXk9LturNVMNKQtfXKwM+T8z76Yva9xf0gyu1y2xP38Sylef2HwmXB6 4kyIBzjLch8Kbipb0v9xhUautJymbtSDCAR4BYA/tGQS+MNDPjWYBhK6rWoj7MGG2L++ bvOf0n/TlZfpDycw6SJYvzW1btJOfJL++PWV8flHyjapXfNgI/qOvvt5vhHyQgdXbhX9 +sBkGWrDP41VkfPxLNuPW5hitnciyhyWy7XMAD1iFDfcot0fs2AuOvKO75h4z6kGIAiq 0xnxsAzKX1lu82CXnr//VdieJHkQzd7oX962MnQnC3Fe4qUIMYawE80ccM2r0bL/ZO1+ r64Q== X-Gm-Message-State: AOAM532obIhCLV27TV8eO5JE/1FxwNqM1dif3i663r7H23alT2C/iIjs nVNX6VsogNq4wz9tRdK+/BI= X-Google-Smtp-Source: ABdhPJwRIkBJF3/tva+2snizZ+0mfh59yzMMWS3os+L8hOlcezIpErwoN/IZd/GREGBdesLN/1l/yw== X-Received: by 2002:a05:620a:4142:b0:67b:3150:219e with SMTP id k2-20020a05620a414200b0067b3150219emr5543922qko.189.1648175587692; Thu, 24 Mar 2022 19:33:07 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id j188-20020a3755c5000000b0067d1c76a09fsm2588391qkb.74.2022.03.24.19.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 19:33:06 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id C55CC27C0054; Thu, 24 Mar 2022 22:33:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 24 Mar 2022 22:33:05 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudehtddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsg hoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtieeg qddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhigi hmvgdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 24 Mar 2022 22:33:05 -0400 (EDT) From: Boqun Feng To: Wei Liu Cc: Vitaly Kuznetsov , linux-hyperv@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Dexuan Cui , Michael Kelley , David Hildenbrand , linux-kernel@vger.kernel.org, Boqun Feng Subject: [PATCH v2 2/2] Drivers: hv: balloon: Disable balloon and hot-add accordingly Date: Fri, 25 Mar 2022 10:32:12 +0800 Message-Id: <20220325023212.1570049-3-boqun.feng@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325023212.1570049-1-boqun.feng@gmail.com> References: <20220325023212.1570049-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Michael Kelley --- drivers/hv/hv_balloon.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 062156b88a87..eee7402cfc02 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -1660,6 +1660,38 @@ static void disable_page_reporting(void) } } =20 +static int ballooning_enabled(void) +{ + /* + * Disable ballooning if the page size is not 4k (HV_HYP_PAGE_SIZE), + * since currently it's unclear to us whether an unballoon request can + * make sure all page ranges are guest page size aligned. + */ + if (PAGE_SIZE !=3D HV_HYP_PAGE_SIZE) { + pr_info("Ballooning disabled because page size is not 4096 bytes\n"); + return 0; + } + + return 1; +} + +static int hot_add_enabled(void) +{ + /* + * Disable hot add on ARM64, because we currently rely on + * memory_add_physaddr_to_nid() to get a node id of a hot add range, + * however ARM64's memory_add_physaddr_to_nid() always return 0 and + * DM_MEM_HOT_ADD_REQUEST doesn't have the NUMA node information for + * add_memory(). + */ + if (IS_ENABLED(CONFIG_ARM64)) { + pr_info("Memory hot add disabled on ARM64\n"); + return 0; + } + + return 1; +} + static int balloon_connect_vsp(struct hv_device *dev) { struct dm_version_request version_req; @@ -1731,8 +1763,8 @@ static int balloon_connect_vsp(struct hv_device *dev) * currently still requires the bits to be set, so we have to add code * to fail the host's hot-add and balloon up/down requests, if any. */ - cap_msg.caps.cap_bits.balloon =3D 1; - cap_msg.caps.cap_bits.hot_add =3D 1; + cap_msg.caps.cap_bits.balloon =3D ballooning_enabled(); + cap_msg.caps.cap_bits.hot_add =3D hot_add_enabled(); =20 /* * Specify our alignment requirements as it relates --=20 2.35.1