From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C0EE1B81D3; Mon, 19 Jan 2026 23:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863709; cv=none; b=gyqZtvvDWVbPkTM60VMG5LNRgsGPs5LZvpkSPbArC8L9fxTUixj6hNfo7gMMM8Z7An4VwSf0Lkm10eJqh53kyOuQgMsfbgCjaHBMX3KzeJKBTKtRDzF5Un1ExJ1iUxcsTfZUln/fef40bBZWuDFiQg0t+R1R4Z3vGzHCV8C3bA8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863709; c=relaxed/simple; bh=luihl3MbyU6omYSiSWj4BOo3mmNqgAivFPTCpm64S5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q20iWzPgigxAbnQUfhymW4eY+7AM8nmvYTYPRyo3w+cnvUJMHMIkyI/qGOUtmyroKAA4lXc2y8Fr6zBkOlGh2hmnbJuewckaUuz6Kb+qZcqiEPf9zAKsRKBej1mZ08GCV8quY3bCIaAjtMM5uO/64ySQzeYFvQNzO0HPti8q4Ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ty14IhFY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ty14IhFY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 531E9C19423; Mon, 19 Jan 2026 23:01:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863709; bh=luihl3MbyU6omYSiSWj4BOo3mmNqgAivFPTCpm64S5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ty14IhFYRg1l/2Ez+3EIhcGA92inZASN9By1yGWpfoCYQQoaXhF9GeSHpXh/4o7wh rv2jd1KqUv7sxbQENf3+a93+kiHs6Pt5G9xfUtig2LlyAvg5fqgjrRlYOU451DxdQV xFS/6MQL9QO4d/tcIUcQUVkk5Ga5MkYY1UtDOLULiGw7WY4N60Pad45nIyjD3Ohaa7 1u8b3HPjwXFqvexE1sUgx5Pa9UxBfNk4UNre7uxGAjjqz0uqzNWWM+n6+PIJW/KZC+ PdVBqArgnZb/xbX+khcmpQlrZp1iBBmSTeD10FX6KYq5s943DkILJgOIVYjGLYJiq6 qwGIPnllyT+GA== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan , SeongJae Park Subject: [PATCH v3 01/24] vmw_balloon: adjust BALLOON_DEFLATE when deflating while migrating Date: Tue, 20 Jan 2026 00:01:09 +0100 Message-ID: <20260119230133.3551867-2-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When we're effectively deflating the balloon while migrating a page because inflating the new page failed, we're not adjusting BALLOON_DEFLATE. Let's do that. This is a preparation for factoring out this handling to the core code, making it work in a similar way first. As this (deflating while migrating because of inflation error) is a corner case that I don't really expect to happen in practice and the stats are not that crucial, this likely doesn't classify as a fix. Reviewed-by: SeongJae Park Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- drivers/misc/vmw_balloon.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index cc1d18b3df5ca..2cc34c4968fac 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1818,6 +1818,8 @@ static int vmballoon_migratepage(struct balloon_dev_i= nfo *b_dev_info, if (status =3D=3D VMW_BALLOON_SUCCESS) { balloon_page_insert(&b->b_dev_info, newpage); __count_vm_event(BALLOON_MIGRATE); + } else { + __count_vm_event(BALLOON_DEFLATE); } =20 /* --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 274131D5174; Mon, 19 Jan 2026 23:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863716; cv=none; b=TUIwcMGsCttbynka/LcStq73HINjqgRciKvEMnKOl+Ffrkm82m9gfuH70W/MnDcfbU7Q5KPS2TBe1gBuVpRgs4dFnszvqWdsJf1SQtvv2f/DNFuklrLLLsIIkcAeV9zrHd1c34ZRnTLWL2uXO5QOtpRqBOtwSpzWuC6rE1/z2P0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863716; c=relaxed/simple; bh=zu0MlNB3uojZ+XY2eNxlLUaMnPt4RrYT1MRY12QCzSY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WWkogP1FmLcAj2EljsXDTm3mHreV9c/fj0iSYYAHaYP1vYpWDHjE+8f1iT/nB87xZAjSPwb4O/RDW2TKANaHVYZJOhKaIZIVqkyUcFj+Q43BglfxTM+sUlCjYFLJfc3I+DvPpYowRfcys46I/ZFVKgRIIJj65fjHt4wFK9V3AJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=it6JXTLD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="it6JXTLD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A858AC19424; Mon, 19 Jan 2026 23:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863716; bh=zu0MlNB3uojZ+XY2eNxlLUaMnPt4RrYT1MRY12QCzSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=it6JXTLDKt1WuNFXQ9Ce1X7YpHetBL19JtOQyj2tZ93grW6ScBDmXXEOP5WPBzLwR xQ4EvMwIVRU3DGciBAEfChSWKPMiG3WcY6iGQxfhEv6ldblsZoy3hkwEtm1zhAY//i zzS5ZbisMo5WLMJuUzvfKOr0asy6qJZoYH9hIniyfin1T+JY18S+HTHiU1p51xcLPJ HhvLlwhAEQ0vWvQMhMNmumzc8AyZhR+8sWHtcZ1t38HBXWFLct4D9EdXXm0KrLuR9J w9qfUy0JmLPcO48+ptAY7t/Yvn8CpMKvaSayoObgChDoH6uXNGimWjcswTRPrSslUV x58d/Nlt99UJQ== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 02/24] vmw_balloon: remove vmballoon_compaction_init() Date: Tue, 20 Jan 2026 00:01:10 +0100 Message-ID: <20260119230133.3551867-3-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that there is not a lot of logic left, let's just inline setting up the migration function and drop all these excessive comments that are not really required (or true) anymore. To avoid #ifdef in the caller we can instead use IS_ENABLED() and make the compiler happy by only providing the function declaration. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- drivers/misc/vmw_balloon.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 2cc34c4968fac..07e60a4b846aa 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1833,27 +1833,10 @@ static int vmballoon_migratepage(struct balloon_dev= _info *b_dev_info, up_read(&b->conf_sem); return ret; } - -/** - * vmballoon_compaction_init() - initialized compaction for the balloon. - * - * @b: pointer to the balloon. - * - * If during the initialization a failure occurred, this function does not - * perform cleanup. The caller must call vmballoon_compaction_deinit() in = this - * case. - * - * Return: zero on success or error code on failure. - */ -static __init void vmballoon_compaction_init(struct vmballoon *b) -{ - b->b_dev_info.migratepage =3D vmballoon_migratepage; -} - #else /* CONFIG_BALLOON_COMPACTION */ -static inline void vmballoon_compaction_init(struct vmballoon *b) -{ -} +int vmballoon_migratepage(struct balloon_dev_info *b_dev_info, + struct page *newpage, struct page *page, + enum migrate_mode mode); #endif /* CONFIG_BALLOON_COMPACTION */ =20 static int __init vmballoon_init(void) @@ -1873,12 +1856,9 @@ static int __init vmballoon_init(void) if (error) return error; =20 - /* - * Initialization of compaction must be done after the call to - * balloon_devinfo_init() . - */ balloon_devinfo_init(&balloon.b_dev_info); - vmballoon_compaction_init(&balloon); + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) + balloon.b_dev_info.migratepage =3D vmballoon_migratepage; =20 INIT_LIST_HEAD(&balloon.huge_pages); spin_lock_init(&balloon.comm_lock); --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0374D1B142D; Mon, 19 Jan 2026 23:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863723; cv=none; b=IgOCtEX1o2pYE5vJcvVfsEmOMgcgPIjdQga7s3/2WgMEe4STELLhiodvQyUu6xm0n1WpzQKCo/chWr82D3K70l6W2wR4glq5qo1Shxbllbowv25IcaW/IT8U6M6+VtRzyPKEd+6+8D3NHzUvNq2xEXneMe7P0a1v8Munc9ufZco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863723; c=relaxed/simple; bh=U9h/5fXRDF7W7U0nEHjVvjxN0NehshCtdso7ivmglXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NrhEWib92OZDCBJ9fqR4fHn+N3f//NGZTgtxuj6KSuQqkaOg9dPX2qchiZ+KMDf9kDCGFQIp7OlFxGHyPBthj72dNkqu8gteFp+cqn4tXv9kyYNeAuNrZ36Rxgp7k/bC0rlZ8c+atrwVjDO0OKVdnUXv40hLVRaSlpfqynMX6Bo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KcsvvCSb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KcsvvCSb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FE18C19424; Mon, 19 Jan 2026 23:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863722; bh=U9h/5fXRDF7W7U0nEHjVvjxN0NehshCtdso7ivmglXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KcsvvCSbK+FAI50L4LUCy7S8qMDHa7BZczOG8V34OArhg9CDqc2V99o7JHKrpTQjV zNbzikPTwWbtWAipBQP/qpedmcfzVJZniN847kfNIHb0ueiGuxV02dEsCdufUu0Mgm 7pYwd3/ivc1I1KVKmPt9HnVuL7asbQd50TAani06TICtRE0Kpxx/9Cd6D394B3sHIl +XEoM4GL1jrLJTrKt3yYImBndcgY+WEVGXogMP3gOlor6Nbs8cICwyWE/en7a+Be30 FhUclUMPBHmYBJcwElvhXgr6nfEQnR6KQS1JuRWMg6JPVtw4oGhiy/LoIeUJSN5crc vqAXwFaQSWUKQ== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 03/24] powerpc/pseries/cmm: remove cmm_balloon_compaction_init() Date: Tue, 20 Jan 2026 00:01:11 +0100 Message-ID: <20260119230133.3551867-4-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that there is not a lot of logic left, let's just inline setting up the migration function. To avoid #ifdef in the caller we can instead use IS_ENABLED() and make the compiler happy by only providing the function declaration. Now that the function is gone, drop the "out_balloon_compaction" label. Note that before commit 68f2736a8583 ("mm: Convert all PageMovable users to movable_operations") we actually had to undo something, now not anymore. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- arch/powerpc/platforms/pseries/cmm.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/= pseries/cmm.c index 4cbbe2ee58aba..9a6efbc80d2ad 100644 --- a/arch/powerpc/platforms/pseries/cmm.c +++ b/arch/powerpc/platforms/pseries/cmm.c @@ -548,15 +548,9 @@ static int cmm_migratepage(struct balloon_dev_info *b_= dev_info, =20 return 0; } - -static void cmm_balloon_compaction_init(void) -{ - b_dev_info.migratepage =3D cmm_migratepage; -} #else /* CONFIG_BALLOON_COMPACTION */ -static void cmm_balloon_compaction_init(void) -{ -} +int cmm_migratepage(struct balloon_dev_info *b_dev_info, struct page *newp= age, + struct page *page, enum migrate_mode mode); #endif /* CONFIG_BALLOON_COMPACTION */ =20 /** @@ -573,11 +567,12 @@ static int cmm_init(void) return -EOPNOTSUPP; =20 balloon_devinfo_init(&b_dev_info); - cmm_balloon_compaction_init(); + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) + b_dev_info.migratepage =3D cmm_migratepage; =20 rc =3D register_oom_notifier(&cmm_oom_nb); if (rc < 0) - goto out_balloon_compaction; + return rc; =20 if ((rc =3D register_reboot_notifier(&cmm_reboot_nb))) goto out_oom_notifier; @@ -606,7 +601,6 @@ static int cmm_init(void) unregister_reboot_notifier(&cmm_reboot_nb); out_oom_notifier: unregister_oom_notifier(&cmm_oom_nb); -out_balloon_compaction: return rc; } =20 --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01B4C1B142D; Mon, 19 Jan 2026 23:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863730; cv=none; b=iaRAsfhpjk2csggvuBK7RxqjSpAHDKnOVuxRSp3XzecQ3JWEnFidO2lQpN3UFamCXXn3iKVjY2rvLgI+usIah6cWYy6r0A8cC5oo+JOD8HPkoAX+ezY3bfyIZHACTEotxByzvv3VGoAnJynvd1ufF1R59MjRRzMXYoM+8wMl+TY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863730; c=relaxed/simple; bh=9pFWzYgZbt+YY9kTe1GTcdn6HTneXxM/S/odovyu19w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fOn1F6sOGOPGfke3AdD6nUOQwsUJfRbhtjhOkMEAeCA087qOWetgjEPlFLJ4zNxPSv6hW68/jwzUWPwUVr0tY6vaCGxPSgRYbQDPEhvIyzTLiv/ZW9itXmFwEO2ApJk0eznIMW8NPAqfXvoXlxxOLGS3F5cB0zvTl7o8vjoVYlA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kLe0Khr6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kLe0Khr6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DCECC19424; Mon, 19 Jan 2026 23:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863729; bh=9pFWzYgZbt+YY9kTe1GTcdn6HTneXxM/S/odovyu19w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kLe0Khr6DuCvasNoS6kxGtkTGY8Zw9brt5gCInhq8gLS+Ma4hsIx1369nWwQX1Tvf IB2XumFvNDI5jcl58bu1+Pu0ZrCudk7hz7m2H9Ax2cKzotO5pTZnVWOjCHvr53Owh9 wWCd3vv1ICESWBRIUrkH/QL8obmlOab1LlCb5uNL/xCEid0Q/hukDlzNIqcI0jUX7I MXYVPdAj/l45N6hoQMjhpukfeniE2KS3T4aRad/4Kfdv+ujJfbonv7OhpZdUpJlZdD v88zh6Y7ixYKz5JxWdDwhau0K/zyUQfHaZMYxvUzxiNBuApA2jLrvXlMoViRemVpHh F+IVwVmTXgxow== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 04/24] mm/balloon_compaction: improve comments for WARN_ON_ONCE(!b_dev_info) Date: Tue, 20 Jan 2026 00:01:12 +0100 Message-ID: <20260119230133.3551867-5-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's clarify a bit by extending the comments. Signed-off-by: David Hildenbrand (Red Hat) --- mm/balloon_compaction.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 03c5dbabb1565..85eea88cea083 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -222,7 +222,11 @@ static void balloon_page_putback(struct page *page) struct balloon_dev_info *b_dev_info =3D balloon_page_device(page); unsigned long flags; =20 - /* Isolated balloon pages cannot get deflated. */ + /* + * When we isolated the page, the page was still inflated in a balloon + * device. As isolated balloon pages cannot get deflated, we still have + * a balloon device here. + */ if (WARN_ON_ONCE(!b_dev_info)) return; =20 @@ -241,7 +245,11 @@ static int balloon_page_migrate(struct page *newpage, = struct page *page, VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); =20 - /* Isolated balloon pages cannot get deflated. */ + /* + * When we isolated the page, the page was still inflated in a balloon + * device. As isolated balloon pages cannot get deflated, we still have + * a balloon device here. + */ if (WARN_ON_ONCE(!balloon)) return -EAGAIN; =20 --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0749029994B; Mon, 19 Jan 2026 23:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863737; cv=none; b=mp9yw5gyMLr1hhvo1p9majl2RC0RqQql0u4JIVFikXzK7f8LSymB0qNtk4KTflOQOdZ4semPcd36TmzzpnvLUcm+It1JMiAxJ1H4VHyJmLt0AskD/mjwvFy/jfQTOlyIlPXR1w2A02OrBZlzNXqydjIB9sJNYYz+K2bEjli1E7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863737; c=relaxed/simple; bh=24p8pe28M/olJp8gPe2KI8fAWybhc5W/Q/2dQB8WznY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ec+jfqPKxNqJg92aZcX2JCwAoxru9JtVYhRhSPDRwsNuPrnFUhENd9HjzVRUKZmt0QhEf358FVTXB97slS+aajNlXL8NMQvFywaGXlUgiqx2yDF0DVU58Fl+tOVZ9AWsIc9ZZdzP97/UzqPNWtB3Gm729fcVrbuiJjf05YwOV3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H0Tp7C+Y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H0Tp7C+Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24201C116C6; Mon, 19 Jan 2026 23:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863736; bh=24p8pe28M/olJp8gPe2KI8fAWybhc5W/Q/2dQB8WznY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H0Tp7C+YM+A/uQI/1du9fKf6+JaulSjW6UdekTe82Na5TlGxSOuOiTKnD3PwDOous PXYMwxtHubYDyt9cf3scV8t08VlIVv4mhTg26OY53GrImPwI/atZTPwpPNb0M2FHqE IuoZsEJm81OCwSvJu6hllGNQ/0c4YPN+mfgdwu02cHngSQXSJgQfU+dTCZT6qxlCRa lfr4QlJi9xbT4N1tf9pPnMHnK8uuorGUrTekzGXv91Erq6HSUZJqO2vPp3QIhN3tcg nSDTvOQNKoJ3fOBjWmgV20r9GanLaTbHj5+iTYkNwQqHMk5H5scYu5X/7oFXfbzc10 rXloLqGyhC1lQ== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 05/24] mm/balloon_compaction: centralize basic page migration handling Date: Tue, 20 Jan 2026 00:01:13 +0100 Message-ID: <20260119230133.3551867-6-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's update the balloon page references, the balloon page list, the BALLOON_MIGRATE counter and the isolated-pages counter in balloon_page_migrate(), after letting the balloon->migratepage() callback deal with the actual inflation+deflation. Note that we now perform the balloon list modifications outside of any implementation-specific locks: which is fine, there is nothing special about these page actions that the lock would be protecting. The old page is already no longer in the list (isolated) and the new page is not yet in the list. Let's use -ENOENT to communicate the special "inflation of new page failed after already deflating the old page" to balloon_page_migrate() so it can handle it accordingly. While at it, rename balloon->b_dev_info to make it match the other functions. Also, drop the comment above balloon_page_migrate(), which seems unnecessary. Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- arch/powerpc/platforms/pseries/cmm.c | 16 --------- drivers/misc/vmw_balloon.c | 49 +++++----------------------- drivers/virtio/virtio_balloon.c | 12 ------- mm/balloon_compaction.c | 31 +++++++++++++++--- 4 files changed, 35 insertions(+), 73 deletions(-) diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/= pseries/cmm.c index 9a6efbc80d2ad..15f873f733a41 100644 --- a/arch/powerpc/platforms/pseries/cmm.c +++ b/arch/powerpc/platforms/pseries/cmm.c @@ -501,8 +501,6 @@ static int cmm_migratepage(struct balloon_dev_info *b_d= ev_info, struct page *newpage, struct page *page, enum migrate_mode mode) { - unsigned long flags; - /* * loan/"inflate" the newpage first. * @@ -517,9 +515,6 @@ static int cmm_migratepage(struct balloon_dev_info *b_d= ev_info, return -EBUSY; } =20 - /* balloon page list reference */ - get_page(newpage); - /* * When we migrate a page to a different zone, we have to fixup the * count of both involved zones as we adjusted the managed page count @@ -530,22 +525,11 @@ static int cmm_migratepage(struct balloon_dev_info *b= _dev_info, adjust_managed_page_count(newpage, -1); } =20 - spin_lock_irqsave(&b_dev_info->pages_lock, flags); - balloon_page_insert(b_dev_info, newpage); - __count_vm_event(BALLOON_MIGRATE); - b_dev_info->isolated_pages--; - spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); - /* * activate/"deflate" the old page. We ignore any errors just like the * other callers. */ plpar_page_set_active(page); - - balloon_page_finalize(page); - /* balloon page list reference */ - put_page(page); - return 0; } #else /* CONFIG_BALLOON_COMPACTION */ diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 07e60a4b846aa..52b8c0f1eead7 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1724,18 +1724,17 @@ static inline void vmballoon_debugfs_exit(struct vm= balloon *b) * @page: a ballooned page that should be migrated. * @mode: migration mode, ignored. * - * This function is really open-coded, but that is according to the interf= ace - * that balloon_compaction provides. - * * Return: zero on success, -EAGAIN when migration cannot be performed - * momentarily, and -EBUSY if migration failed and should be retried - * with that specific page. + * momentarily, -EBUSY if migration failed and should be retried + * with that specific page, and -ENOENT when deflating @page + * succeeded but inflating @newpage failed, effectively deflating + * the balloon. */ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info, struct page *newpage, struct page *page, enum migrate_mode mode) { - unsigned long status, flags; + unsigned long status; struct vmballoon *b; int ret =3D 0; =20 @@ -1773,14 +1772,6 @@ static int vmballoon_migratepage(struct balloon_dev_= info *b_dev_info, goto out_unlock; } =20 - /* - * The page is isolated, so it is safe to delete it without holding - * @pages_lock . We keep holding @comm_lock since we will need it in a - * second. - */ - balloon_page_finalize(page); - put_page(page); - /* Inflate */ vmballoon_add_page(b, 0, newpage); status =3D vmballoon_lock_op(b, 1, VMW_BALLOON_4K_PAGE, @@ -1799,36 +1790,12 @@ static int vmballoon_migratepage(struct balloon_dev= _info *b_dev_info, * change. */ atomic64_dec(&b->size); - } else { /* - * Success. Take a reference for the page, and we will add it to - * the list after acquiring the lock. + * Tell the core that we're deflating the old page and don't + * need the new page. */ - get_page(newpage); - } - - /* Update the balloon list under the @pages_lock */ - spin_lock_irqsave(&b->b_dev_info.pages_lock, flags); - - /* - * On inflation success, we already took a reference for the @newpage. - * If we succeed just insert it to the list and update the statistics - * under the lock. - */ - if (status =3D=3D VMW_BALLOON_SUCCESS) { - balloon_page_insert(&b->b_dev_info, newpage); - __count_vm_event(BALLOON_MIGRATE); - } else { - __count_vm_event(BALLOON_DEFLATE); + ret =3D -ENOENT; } - - /* - * We deflated successfully, so regardless to the inflation success, we - * need to reduce the number of isolated_pages. - */ - b->b_dev_info.isolated_pages--; - spin_unlock_irqrestore(&b->b_dev_info.pages_lock, flags); - out_unlock: up_read(&b->conf_sem); return ret; diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloo= n.c index 74fe59f5a78c6..df2756c071dae 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -827,7 +827,6 @@ static int virtballoon_migratepage(struct balloon_dev_i= nfo *vb_dev_info, { struct virtio_balloon *vb =3D container_of(vb_dev_info, struct virtio_balloon, vb_dev_info); - unsigned long flags; =20 /* * In order to avoid lock contention while migrating pages concurrently @@ -840,8 +839,6 @@ static int virtballoon_migratepage(struct balloon_dev_i= nfo *vb_dev_info, if (!mutex_trylock(&vb->balloon_lock)) return -EAGAIN; =20 - get_page(newpage); /* balloon reference */ - /* * When we migrate a page to a different zone and adjusted the * managed page count when inflating, we have to fixup the count of @@ -854,11 +851,6 @@ static int virtballoon_migratepage(struct balloon_dev_= info *vb_dev_info, } =20 /* balloon's page migration 1st step -- inflate "newpage" */ - spin_lock_irqsave(&vb_dev_info->pages_lock, flags); - balloon_page_insert(vb_dev_info, newpage); - vb_dev_info->isolated_pages--; - __count_vm_event(BALLOON_MIGRATE); - spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags); vb->num_pfns =3D VIRTIO_BALLOON_PAGES_PER_PAGE; set_page_pfns(vb, vb->pfns, newpage); tell_host(vb, vb->inflate_vq); @@ -869,10 +861,6 @@ static int virtballoon_migratepage(struct balloon_dev_= info *vb_dev_info, tell_host(vb, vb->deflate_vq); =20 mutex_unlock(&vb->balloon_lock); - - balloon_page_finalize(page); - put_page(page); /* balloon reference */ - return 0; } #endif /* CONFIG_BALLOON_COMPACTION */ diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 85eea88cea083..764fa25dc4bd1 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -236,11 +236,12 @@ static void balloon_page_putback(struct page *page) spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); } =20 -/* move_to_new_page() counterpart for a ballooned page */ static int balloon_page_migrate(struct page *newpage, struct page *page, enum migrate_mode mode) { - struct balloon_dev_info *balloon =3D balloon_page_device(page); + struct balloon_dev_info *b_dev_info =3D balloon_page_device(page); + unsigned long flags; + int rc; =20 VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); @@ -250,10 +251,32 @@ static int balloon_page_migrate(struct page *newpage,= struct page *page, * device. As isolated balloon pages cannot get deflated, we still have * a balloon device here. */ - if (WARN_ON_ONCE(!balloon)) + if (WARN_ON_ONCE(!b_dev_info)) return -EAGAIN; =20 - return balloon->migratepage(balloon, newpage, page, mode); + rc =3D b_dev_info->migratepage(b_dev_info, newpage, page, mode); + if (rc < 0 && rc !=3D -ENOENT) + return rc; + + spin_lock_irqsave(&b_dev_info->pages_lock, flags); + if (!rc) { + /* Insert the new page into the balloon list. */ + get_page(newpage); + balloon_page_insert(b_dev_info, newpage); + __count_vm_event(BALLOON_MIGRATE); + } else { + /* Old page was deflated but new page not inflated. */ + __count_vm_event(BALLOON_DEFLATE); + } + + b_dev_info->isolated_pages--; + spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); + + /* Free the now-deflated page we isolated in balloon_page_isolate(). */ + balloon_page_finalize(page); + put_page(page); + + return 0; } =20 const struct movable_operations balloon_mops =3D { --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CBFB241665; Mon, 19 Jan 2026 23:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863748; cv=none; b=K7IBI2bPKEbPPUxyj2qZJ4MIug9ZjlGcDWocq+wSeYYU7FmrOhHXqBMCBNgFum+W9+NIXaU28G8aXtgEwd+drYGXqBHudtRHVmceghhBCufOAR98RYQ9l4NqkSQ5XMVcdFyvE+OxX+mu5JV2QU6MFmh4jD8eUjH81GNx9281f6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863748; c=relaxed/simple; bh=SnhMKeXWJjdrWLtSbqKw7V4EMXVK/pgfK7VZwhJNF9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o/1nTsnIG+17l7TpZfNjxktP0kxhPyT/GIzEegBwGqKWkZXN6QweXldCdrOvHhKweEVR0heQXSZKAxxgK+CZBDpR7Sx7mZ38we5Xznf1GNJZ2RyIgjWoaSg9Xf7ZahgwqszTSOvu98V9QFPjw5+pFCxdJDpbMmoPRkXZPRtxjw0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Cwpscc+r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Cwpscc+r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E383C19424; Mon, 19 Jan 2026 23:02:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863743; bh=SnhMKeXWJjdrWLtSbqKw7V4EMXVK/pgfK7VZwhJNF9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cwpscc+r+ZQnX9sK8UbIxMV80FOtiD0YmfSvImeyZ1PRPQH2lLEE20JaD3ObyynTS EGuheGjlkJBQOTWpsnYX+6heM102tLpDu6hT5riS/StPirtxFNFhQIt+gXzAzu7kUT Uzc4AuZlWiPVtXJnQFd63BCCJMA5kq3Amhls8qWKE7JNdROfRWhZztXHKUFcrYZNRw cVB+zSGrii6PulRMvxLEhh/ZRNUvVNnIvhFuWUFz+Uvo0liKLJgMoJUzmbMyXFccU9 /FyQCbCpzZq84lBXHcsEEz5XJxyaDrhzSquDZ/IjDQFhLnqPjvyS+ROF1QKGZ/ITAv Bphv7kbjcZ1ew== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 06/24] mm/balloon_compaction: centralize adjust_managed_page_count() handling Date: Tue, 20 Jan 2026 00:01:14 +0100 Message-ID: <20260119230133.3551867-7-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's centralize it, by allowing for the driver to enable this handling through a new flag (bool for now) in the balloon device info. Note that we now adjust the counter when adding/removing a page into the balloon list: when removing a page to deflate it, it will now happen before the driver communicated with hypervisor, not afterwards. This shouldn't make a difference in practice. Acked-by: Liam R. Howlett Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- arch/powerpc/platforms/pseries/cmm.c | 13 +------------ drivers/virtio/virtio_balloon.c | 19 ++----------------- include/linux/balloon_compaction.h | 2 ++ mm/balloon_compaction.c | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/= pseries/cmm.c index 15f873f733a41..7fd8b3d7e7637 100644 --- a/arch/powerpc/platforms/pseries/cmm.c +++ b/arch/powerpc/platforms/pseries/cmm.c @@ -165,7 +165,6 @@ static long cmm_alloc_pages(long nr) =20 balloon_page_enqueue(&b_dev_info, page); atomic_long_inc(&loaned_pages); - adjust_managed_page_count(page, -1); nr--; } =20 @@ -190,7 +189,6 @@ static long cmm_free_pages(long nr) if (!page) break; plpar_page_set_active(page); - adjust_managed_page_count(page, 1); __free_page(page); atomic_long_dec(&loaned_pages); nr--; @@ -515,16 +513,6 @@ static int cmm_migratepage(struct balloon_dev_info *b_= dev_info, return -EBUSY; } =20 - /* - * When we migrate a page to a different zone, we have to fixup the - * count of both involved zones as we adjusted the managed page count - * when inflating. - */ - if (page_zone(page) !=3D page_zone(newpage)) { - adjust_managed_page_count(page, 1); - adjust_managed_page_count(newpage, -1); - } - /* * activate/"deflate" the old page. We ignore any errors just like the * other callers. @@ -551,6 +539,7 @@ static int cmm_init(void) return -EOPNOTSUPP; =20 balloon_devinfo_init(&b_dev_info); + b_dev_info.adjust_managed_page_count =3D true; if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) b_dev_info.migratepage =3D cmm_migratepage; =20 diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloo= n.c index df2756c071dae..15c1cf5fd249c 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -274,9 +274,6 @@ static unsigned int fill_balloon(struct virtio_balloon = *vb, size_t num) =20 set_page_pfns(vb, vb->pfns + vb->num_pfns, page); vb->num_pages +=3D VIRTIO_BALLOON_PAGES_PER_PAGE; - if (!virtio_has_feature(vb->vdev, - VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) - adjust_managed_page_count(page, -1); vb->num_pfns +=3D VIRTIO_BALLOON_PAGES_PER_PAGE; } =20 @@ -295,9 +292,6 @@ static void release_pages_balloon(struct virtio_balloon= *vb, struct page *page, *next; =20 list_for_each_entry_safe(page, next, pages, lru) { - if (!virtio_has_feature(vb->vdev, - VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) - adjust_managed_page_count(page, 1); list_del(&page->lru); put_page(page); /* balloon reference */ } @@ -839,17 +833,6 @@ static int virtballoon_migratepage(struct balloon_dev_= info *vb_dev_info, if (!mutex_trylock(&vb->balloon_lock)) return -EAGAIN; =20 - /* - * When we migrate a page to a different zone and adjusted the - * managed page count when inflating, we have to fixup the count of - * both involved zones. - */ - if (!virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM) && - page_zone(page) !=3D page_zone(newpage)) { - adjust_managed_page_count(page, 1); - adjust_managed_page_count(newpage, -1); - } - /* balloon's page migration 1st step -- inflate "newpage" */ vb->num_pfns =3D VIRTIO_BALLOON_PAGES_PER_PAGE; set_page_pfns(vb, vb->pfns, newpage); @@ -958,6 +941,8 @@ static int virtballoon_probe(struct virtio_device *vdev) if (err) goto out_free_vb; =20 + if (!virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) + vb->vb_dev_info.adjust_managed_page_count =3D true; #ifdef CONFIG_BALLOON_COMPACTION vb->vb_dev_info.migratepage =3D virtballoon_migratepage; #endif diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index 7cfe48769239e..3109d3c43d306 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -56,6 +56,7 @@ struct balloon_dev_info { struct list_head pages; /* Pages enqueued & handled to Host */ int (*migratepage)(struct balloon_dev_info *, struct page *newpage, struct page *page, enum migrate_mode mode); + bool adjust_managed_page_count; }; =20 extern struct page *balloon_page_alloc(void); @@ -73,6 +74,7 @@ static inline void balloon_devinfo_init(struct balloon_de= v_info *balloon) spin_lock_init(&balloon->pages_lock); INIT_LIST_HEAD(&balloon->pages); balloon->migratepage =3D NULL; + balloon->adjust_managed_page_count =3D false; } =20 #ifdef CONFIG_BALLOON_COMPACTION diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 764fa25dc4bd1..4fe2a0cff69ec 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -23,6 +23,8 @@ static void balloon_page_enqueue_one(struct balloon_dev_i= nfo *b_dev_info, BUG_ON(!trylock_page(page)); balloon_page_insert(b_dev_info, page); unlock_page(page); + if (b_dev_info->adjust_managed_page_count) + adjust_managed_page_count(page, -1); __count_vm_event(BALLOON_INFLATE); inc_node_page_state(page, NR_BALLOON_PAGES); } @@ -95,6 +97,8 @@ size_t balloon_page_list_dequeue(struct balloon_dev_info = *b_dev_info, continue; =20 list_del(&page->lru); + if (b_dev_info->adjust_managed_page_count) + adjust_managed_page_count(page, 1); balloon_page_finalize(page); __count_vm_event(BALLOON_DEFLATE); list_add(&page->lru, pages); @@ -264,9 +268,22 @@ static int balloon_page_migrate(struct page *newpage, = struct page *page, get_page(newpage); balloon_page_insert(b_dev_info, newpage); __count_vm_event(BALLOON_MIGRATE); + + if (b_dev_info->adjust_managed_page_count && + page_zone(page) !=3D page_zone(newpage)) { + /* + * When we migrate a page to a different zone we + * have to fixup the count of both involved zones. + */ + adjust_managed_page_count(page, 1); + adjust_managed_page_count(newpage, -1); + } } else { /* Old page was deflated but new page not inflated. */ __count_vm_event(BALLOON_DEFLATE); + + if (b_dev_info->adjust_managed_page_count) + adjust_managed_page_count(page, 1); } =20 b_dev_info->isolated_pages--; --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 113532C08AB; Mon, 19 Jan 2026 23:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863751; cv=none; b=IZaHyZXsW6185r9+MJ8Z5spCZ4vMYa8Xg/rlgGs64qRkX1bA21+yf0J4C8hW6Gdu65XMyQl1a7qYrdmD1g6HS28NkSbwy/4fZNHLYdWSIPLAHd40sq4+Lj5OmQtTud0LDaP/91XO98Eypx5WtQ1261JjO5Lf7il6ZJUD1anGY44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863751; c=relaxed/simple; bh=02rD+PHNM+b5mi9R1g7ROou+G35A+7jKPB0WnczT56k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e7NWoz2Gg4woODzaHYhZArUC5Ue6781yhKonnFls9IQma/1Q6Jt1rrO4carA1dOt5QEOs67BALg0nFkkfsD6pOpj4cIQokf1dDNS9GV22tB0UTzwRE0ov8flOfYB7Q05NsNTI3QX1gkxxozs27tsjJ7epWfXwQ8ro4AL2G7gyUs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SY7D/mYb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SY7D/mYb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A0EAC116C6; Mon, 19 Jan 2026 23:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863750; bh=02rD+PHNM+b5mi9R1g7ROou+G35A+7jKPB0WnczT56k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SY7D/mYbjCn4fSG5EK9Rs05NbqgkjcvZRltvk7rG+REHOYD4VoywWrL8DPMjIlCcY +Anh5u4jPWUZ0WpEcg8Acxj///jncJ2pqp++vuhDmyJIiSltCy9qQNuYkSqwOpbN36 uRcWnbEEo7Rfqk2rOhSMtm7xky6vRVHdXUjBas4Pl3BhRMezTZbRDSV/VUOYmHVOcL WLk7DCCJIIx+cyLjsfkRFfOY3h3tDXL9nJjvWTb7hY+HKaWKvdxcE0BiOTSO2j005n 9XBTUVvE6+aB8dtpNneIWdpY5bowk676SjtHxNTXLEKEA5zl09lwv91vfDW/3Fmu7j J9ZJbQiiEihHQ== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 07/24] vmw_balloon: stop using the balloon_dev_info lock Date: Tue, 20 Jan 2026 00:01:15 +0100 Message-ID: <20260119230133.3551867-8-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's not piggy-back on the existing lock and use a separate lock for the huge page list. Now that we use a separate lock, there is no need to disable interrupts, so use the non-irqsave variants. We only required the irqsave variants because of the balloon device lock. This is a preparation for changing the locking used to protect balloon_dev_info. While at it, talk about "page migration" instead of "page compaction". We'll change that in core code soon as well. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- drivers/misc/vmw_balloon.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 52b8c0f1eead7..53e9335b6718c 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -354,10 +354,15 @@ struct vmballoon { /** * @huge_pages - list of the inflated 2MB pages. * - * Protected by @b_dev_info.pages_lock . + * Protected by @huge_pages_lock. */ struct list_head huge_pages; =20 + /** + * @huge_pages_lock: lock for the list of inflated 2MB pages. + */ + spinlock_t huge_pages_lock; + /** * @vmci_doorbell. * @@ -987,7 +992,6 @@ static void vmballoon_enqueue_page_list(struct vmballoo= n *b, unsigned int *n_pages, enum vmballoon_page_size_type page_size) { - unsigned long flags; struct page *page; =20 if (page_size =3D=3D VMW_BALLOON_4K_PAGE) { @@ -995,9 +999,9 @@ static void vmballoon_enqueue_page_list(struct vmballoo= n *b, } else { /* * Keep the huge pages in a local list which is not available - * for the balloon compaction mechanism. + * for the balloon page migration. */ - spin_lock_irqsave(&b->b_dev_info.pages_lock, flags); + spin_lock(&b->huge_pages_lock); =20 list_for_each_entry(page, pages, lru) { vmballoon_mark_page_offline(page, VMW_BALLOON_2M_PAGE); @@ -1006,7 +1010,7 @@ static void vmballoon_enqueue_page_list(struct vmball= oon *b, list_splice_init(pages, &b->huge_pages); __count_vm_events(BALLOON_INFLATE, *n_pages * vmballoon_page_in_frames(VMW_BALLOON_2M_PAGE)); - spin_unlock_irqrestore(&b->b_dev_info.pages_lock, flags); + spin_unlock(&b->huge_pages_lock); } =20 *n_pages =3D 0; @@ -1033,7 +1037,6 @@ static void vmballoon_dequeue_page_list(struct vmball= oon *b, { struct page *page, *tmp; unsigned int i =3D 0; - unsigned long flags; =20 /* In the case of 4k pages, use the compaction infrastructure */ if (page_size =3D=3D VMW_BALLOON_4K_PAGE) { @@ -1043,7 +1046,7 @@ static void vmballoon_dequeue_page_list(struct vmball= oon *b, } =20 /* 2MB pages */ - spin_lock_irqsave(&b->b_dev_info.pages_lock, flags); + spin_lock(&b->huge_pages_lock); list_for_each_entry_safe(page, tmp, &b->huge_pages, lru) { vmballoon_mark_page_online(page, VMW_BALLOON_2M_PAGE); =20 @@ -1054,7 +1057,7 @@ static void vmballoon_dequeue_page_list(struct vmball= oon *b, =20 __count_vm_events(BALLOON_DEFLATE, i * vmballoon_page_in_frames(VMW_BALLOON_2M_PAGE)); - spin_unlock_irqrestore(&b->b_dev_info.pages_lock, flags); + spin_unlock(&b->huge_pages_lock); *n_pages =3D i; } =20 @@ -1828,6 +1831,7 @@ static int __init vmballoon_init(void) balloon.b_dev_info.migratepage =3D vmballoon_migratepage; =20 INIT_LIST_HEAD(&balloon.huge_pages); + spin_lock_init(&balloon.huge_pages_lock); spin_lock_init(&balloon.comm_lock); init_rwsem(&balloon.conf_sem); balloon.vmci_doorbell =3D VMCI_INVALID_HANDLE; --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D58051DC9B3; Mon, 19 Jan 2026 23:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863757; cv=none; b=EcggJgwUVhklvV6mqtXtso6yL/g8JAxst1VtU34VTLFy78XKwmi0PmmKQKpvjrtcIizydO40vtshbhJy//qT2z939jVSFlbLYaJ+blksD0F2mQ53pmfSQPy/SkPhznXaJEmM2OwlCObgoSRkzWLIOeY5AeH82VTiXwKKPGfevqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863757; c=relaxed/simple; bh=B4TNdno4jEZy7WvDrbla07FpWfPcmSGxCps73N2ttzs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rNQD8aaK9fTzUcwr85v59EerRALwtz7XaInnufX+ivyIqKsxrzjbuR/8XiMcZW/aqpPiEoooGwaYNflhFOfbaDCOS8Qbq2kxbHSdkkBpV3aRNZQs4E+ALTQLsruPBr3riPImaAEJ8/B0fNtTgscUbAJ2k/XvT3RsYe0XKBdb0TI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mdfux5vZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mdfux5vZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27F4DC19423; Mon, 19 Jan 2026 23:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863757; bh=B4TNdno4jEZy7WvDrbla07FpWfPcmSGxCps73N2ttzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mdfux5vZ5n1jk7Bajy/1xc69ZeTQqQnbFi2y1gt5UERRQfxL5CZMsGKqJTBXlAhOK uwS0/uvJ0i0RuQRaRPbSQKJVqIJl5kCtqj0v7fV8X5883AvN1q6YK/w62hSb0OMWo/ geFefvkGbQXLvVddoTri0kLD7uuRfEijWUTBowE9kDpan3/Wq854GpwFVkfbb+rp3K pXZUafSWF6kSJWt51UCzsnSwt7gNlPj4EjTjg0+Jr8VzBifR1e+hg2bKs+DFb/+R2y 5B7WhMN1s3OV75YhtLAU0a2oC0qAxjuuhbPYUH7IsPtXJV1v4Yjrp0WZcNelDBVdpI eKqPibTCPYlXw== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 08/24] mm/balloon_compaction: use a device-independent balloon (list) lock Date: Tue, 20 Jan 2026 00:01:16 +0100 Message-ID: <20260119230133.3551867-9-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In order to remove the dependency on the page lock for balloon pages, we need a lock that is independent of the page. It's crucial that we can handle the scenario where balloon deflation (clearing page->private) can race with page isolation (using page->private to obtain the balloon_dev_info where the lock currently resides). The current lock in balloon_dev_info is therefore not suitable. Fortunately, we never really have more than a single balloon device per VM, so we can just keep it simple and use a static lock to protect all balloon devices. Based on this change we will remove the dependency on the page lock next. Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- include/linux/balloon_compaction.h | 6 ++---- mm/balloon_compaction.c | 34 ++++++++++++++++++------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index 3109d3c43d306..9a8568fcd477d 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -21,10 +21,10 @@ * i. Setting the PG_movable_ops flag and page->private with the followi= ng * lock order * +-page_lock(page); - * +--spin_lock_irq(&b_dev_info->pages_lock); + * +--spin_lock_irq(&balloon_pages_lock); * * ii. isolation or dequeueing procedure must remove the page from balloon - * device page list under b_dev_info->pages_lock. + * device page list under balloon_pages_lock * * The functions provided by this interface are placed to help on coping w= ith * the aforementioned balloon page corner case, as well as to ensure the s= imple @@ -52,7 +52,6 @@ */ struct balloon_dev_info { unsigned long isolated_pages; /* # of isolated pages for migration */ - spinlock_t pages_lock; /* Protection to pages list */ struct list_head pages; /* Pages enqueued & handled to Host */ int (*migratepage)(struct balloon_dev_info *, struct page *newpage, struct page *page, enum migrate_mode mode); @@ -71,7 +70,6 @@ extern size_t balloon_page_list_dequeue(struct balloon_de= v_info *b_dev_info, static inline void balloon_devinfo_init(struct balloon_dev_info *balloon) { balloon->isolated_pages =3D 0; - spin_lock_init(&balloon->pages_lock); INIT_LIST_HEAD(&balloon->pages); balloon->migratepage =3D NULL; balloon->adjust_managed_page_count =3D false; diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 4fe2a0cff69ec..a0fd779bbd012 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -11,6 +11,12 @@ #include #include =20 +/* + * Lock protecting the balloon_dev_info of all devices. We don't really + * expect more than one device. + */ +static DEFINE_SPINLOCK(balloon_pages_lock); + static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info, struct page *page) { @@ -47,13 +53,13 @@ size_t balloon_page_list_enqueue(struct balloon_dev_inf= o *b_dev_info, unsigned long flags; size_t n_pages =3D 0; =20 - spin_lock_irqsave(&b_dev_info->pages_lock, flags); + spin_lock_irqsave(&balloon_pages_lock, flags); list_for_each_entry_safe(page, tmp, pages, lru) { list_del(&page->lru); balloon_page_enqueue_one(b_dev_info, page); n_pages++; } - spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); + spin_unlock_irqrestore(&balloon_pages_lock, flags); return n_pages; } EXPORT_SYMBOL_GPL(balloon_page_list_enqueue); @@ -83,7 +89,7 @@ size_t balloon_page_list_dequeue(struct balloon_dev_info = *b_dev_info, unsigned long flags; size_t n_pages =3D 0; =20 - spin_lock_irqsave(&b_dev_info->pages_lock, flags); + spin_lock_irqsave(&balloon_pages_lock, flags); list_for_each_entry_safe(page, tmp, &b_dev_info->pages, lru) { if (n_pages =3D=3D n_req_pages) break; @@ -106,7 +112,7 @@ size_t balloon_page_list_dequeue(struct balloon_dev_inf= o *b_dev_info, dec_node_page_state(page, NR_BALLOON_PAGES); n_pages++; } - spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); + spin_unlock_irqrestore(&balloon_pages_lock, flags); =20 return n_pages; } @@ -149,9 +155,9 @@ void balloon_page_enqueue(struct balloon_dev_info *b_de= v_info, { unsigned long flags; =20 - spin_lock_irqsave(&b_dev_info->pages_lock, flags); + spin_lock_irqsave(&balloon_pages_lock, flags); balloon_page_enqueue_one(b_dev_info, page); - spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); + spin_unlock_irqrestore(&balloon_pages_lock, flags); } EXPORT_SYMBOL_GPL(balloon_page_enqueue); =20 @@ -191,11 +197,11 @@ struct page *balloon_page_dequeue(struct balloon_dev_= info *b_dev_info) * BUG() here, otherwise the balloon driver may get stuck in * an infinite loop while attempting to release all its pages. */ - spin_lock_irqsave(&b_dev_info->pages_lock, flags); + spin_lock_irqsave(&balloon_pages_lock, flags); if (unlikely(list_empty(&b_dev_info->pages) && !b_dev_info->isolated_pages)) BUG(); - spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); + spin_unlock_irqrestore(&balloon_pages_lock, flags); return NULL; } return list_first_entry(&pages, struct page, lru); @@ -213,10 +219,10 @@ static bool balloon_page_isolate(struct page *page, i= solate_mode_t mode) if (!b_dev_info) return false; =20 - spin_lock_irqsave(&b_dev_info->pages_lock, flags); + spin_lock_irqsave(&balloon_pages_lock, flags); list_del(&page->lru); b_dev_info->isolated_pages++; - spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); + spin_unlock_irqrestore(&balloon_pages_lock, flags); =20 return true; } @@ -234,10 +240,10 @@ static void balloon_page_putback(struct page *page) if (WARN_ON_ONCE(!b_dev_info)) return; =20 - spin_lock_irqsave(&b_dev_info->pages_lock, flags); + spin_lock_irqsave(&balloon_pages_lock, flags); list_add(&page->lru, &b_dev_info->pages); b_dev_info->isolated_pages--; - spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); + spin_unlock_irqrestore(&balloon_pages_lock, flags); } =20 static int balloon_page_migrate(struct page *newpage, struct page *page, @@ -262,7 +268,7 @@ static int balloon_page_migrate(struct page *newpage, s= truct page *page, if (rc < 0 && rc !=3D -ENOENT) return rc; =20 - spin_lock_irqsave(&b_dev_info->pages_lock, flags); + spin_lock_irqsave(&balloon_pages_lock, flags); if (!rc) { /* Insert the new page into the balloon list. */ get_page(newpage); @@ -287,7 +293,7 @@ static int balloon_page_migrate(struct page *newpage, s= truct page *page, } =20 b_dev_info->isolated_pages--; - spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); + spin_unlock_irqrestore(&balloon_pages_lock, flags); =20 /* Free the now-deflated page we isolated in balloon_page_isolate(). */ balloon_page_finalize(page); --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BFAB27A461; Mon, 19 Jan 2026 23:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863764; cv=none; b=OGYv7iXDHgtifcmC1hA6hf96HNDj4WoO6bhtpUnG+0z4eh1FFtLBB3wR/e/DgL23yyECexSpwexr2lIyDiUFo+SuqWbdefW7VEOapCc5PGzsUYy4Hddh7aJErwhzW4vlEICE3avQdYc1cZZ+j2/TXLL+YPFsG0rwSA8axQ+4YYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863764; c=relaxed/simple; bh=Pf5BxzivrH4BXObSIgzNQrUk+URrkIatB5ImogUIjQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NqQ/j6CR58PeuXMB72Az/4r8OM56ghwGp7euKLcUs/c8kowpZZOCViWyL0yHSimhjhwQtK+hAYKR9VnWWz2E7ySbUUyOnVToilUGjKX+VnaUshS+ksFlukAXawhv0SLuluYYH+8qqGVOzkGOaVmol2RrUO0NjWCVHNx0Nh7oN+c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kL3yk/Nx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kL3yk/Nx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05F78C116C6; Mon, 19 Jan 2026 23:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863764; bh=Pf5BxzivrH4BXObSIgzNQrUk+URrkIatB5ImogUIjQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kL3yk/NxqLODZejr8sB3SxDlCN70szrILaWrvJJIW+HQIGg4P/+YP1wzydq+dc68t KOpMP3LxEmZALZci/WwsQshv725k6uY1y/mzahpied33Xva4RzQCSQ7c4gSpPToObs WHeu0YhuZVaaFIUCfvYl74JU71ePBkTm58aBxTYlZRKnfXc5lU+msYNmpB+z+wl4ru JcO2lScUWd+bNcp6qpk53CQ1B0nr/RDBVW8prfZ3gs+4sNo4SQnqA1m8tfxPp79Ua+ lzYTwtGP4Zn+sr2Ljv3uykQLhJsQl+DNAIRP8yHOzwWGaK9v7HUiTIRQVUaiyoqSkK 2Zs3VMw3HZoWg== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 09/24] mm/balloon_compaction: remove dependency on page lock Date: Tue, 20 Jan 2026 00:01:17 +0100 Message-ID: <20260119230133.3551867-10-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's stop using the page lock in balloon code and instead use only the balloon_device_lock. As soon as we set the PG_movable_ops flag, we might now get isolation callbacks for that page as we are no longer holding the page lock. In there, we'll simply synchronize using the balloon_device_lock. So in balloon_page_isolate() lookup the balloon_dev_info through page->private under balloon_device_lock. It's crucial that we update page->private under the balloon_device_lock, so the isolation callback can properly deal with concurrent deflation. Consequently, make sure that balloon_page_finalize() is called under balloon_device_lock as we remove a page from the list and clear page->private. balloon_page_insert() is already called with the balloon_device_lock held. Note that the core will still lock the pages, for example in isolate_movable_ops_page(). The lock is there still relevant for handling the PageMovableOpsIsolated flag, but that can be later changed to use an atomic test-and-set instead, or moved into the movable_ops backends. Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- include/linux/balloon_compaction.h | 25 ++++++++++---------- mm/balloon_compaction.c | 38 ++++++++++-------------------- 2 files changed, 25 insertions(+), 38 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index 9a8568fcd477d..ad594af6ed100 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -12,25 +12,27 @@ * is derived from the page type (PageOffline()) combined with the * PG_movable_ops flag (PageMovableOps()). * + * Once the page type and the PG_movable_ops are set, migration code + * can initiate page isolation by invoking the + * movable_operations()->isolate_page() callback + * + * As long as page->private is set, the page is either on the balloon list + * or isolated for migration. If page->private is not set, the page is + * either still getting inflated, or was deflated to be freed by the ballo= on + * driver soon. Isolation is impossible in both cases. + * * As the page isolation scanning step a compaction thread does is a lockl= ess * procedure (from a page standpoint), it might bring some racy situations= while * performing balloon page compaction. In order to sort out these racy sce= narios * and safely perform balloon's page compaction and migration we must, alw= ays, * ensure following these simple rules: * - * i. Setting the PG_movable_ops flag and page->private with the followi= ng - * lock order - * +-page_lock(page); - * +--spin_lock_irq(&balloon_pages_lock); + * i. Inflation/deflation must set/clear page->private under the + * balloon_pages_lock * * ii. isolation or dequeueing procedure must remove the page from balloon * device page list under balloon_pages_lock * - * The functions provided by this interface are placed to help on coping w= ith - * the aforementioned balloon page corner case, as well as to ensure the s= imple - * set of exposed rules are satisfied while we are dealing with balloon pa= ges - * compaction / migration. - * * Copyright (C) 2012, Red Hat, Inc. Rafael Aquini */ #ifndef _LINUX_BALLOON_COMPACTION_H @@ -93,8 +95,7 @@ static inline struct balloon_dev_info *balloon_page_devic= e(struct page *page) * @balloon : pointer to balloon device * @page : page to be assigned as a 'balloon page' * - * Caller must ensure the page is locked and the spin_lock protecting ball= oon - * pages list is held before inserting a page into the balloon device. + * Caller must ensure the balloon_pages_lock is held. */ static inline void balloon_page_insert(struct balloon_dev_info *balloon, struct page *page) @@ -119,7 +120,7 @@ static inline gfp_t balloon_mapping_gfp_mask(void) * balloon list for release to the page allocator * @page: page to be released to the page allocator * - * Caller must ensure that the page is locked. + * Caller must ensure the balloon_pages_lock is held. */ static inline void balloon_page_finalize(struct page *page) { diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index a0fd779bbd012..75763c73dbd52 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -20,15 +20,7 @@ static DEFINE_SPINLOCK(balloon_pages_lock); static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info, struct page *page) { - /* - * Block others from accessing the 'page' when we get around to - * establishing additional references. We should be the only one - * holding a reference to the 'page' at this point. If we are not, then - * memory corruption is possible and we should stop execution. - */ - BUG_ON(!trylock_page(page)); balloon_page_insert(b_dev_info, page); - unlock_page(page); if (b_dev_info->adjust_managed_page_count) adjust_managed_page_count(page, -1); __count_vm_event(BALLOON_INFLATE); @@ -93,22 +85,12 @@ size_t balloon_page_list_dequeue(struct balloon_dev_inf= o *b_dev_info, list_for_each_entry_safe(page, tmp, &b_dev_info->pages, lru) { if (n_pages =3D=3D n_req_pages) break; - - /* - * Block others from accessing the 'page' while we get around to - * establishing additional references and preparing the 'page' - * to be released by the balloon driver. - */ - if (!trylock_page(page)) - continue; - list_del(&page->lru); if (b_dev_info->adjust_managed_page_count) adjust_managed_page_count(page, 1); balloon_page_finalize(page); __count_vm_event(BALLOON_DEFLATE); list_add(&page->lru, pages); - unlock_page(page); dec_node_page_state(page, NR_BALLOON_PAGES); n_pages++; } @@ -213,13 +195,19 @@ EXPORT_SYMBOL_GPL(balloon_page_dequeue); static bool balloon_page_isolate(struct page *page, isolate_mode_t mode) =20 { - struct balloon_dev_info *b_dev_info =3D balloon_page_device(page); + struct balloon_dev_info *b_dev_info; unsigned long flags; =20 - if (!b_dev_info) - return false; - spin_lock_irqsave(&balloon_pages_lock, flags); + b_dev_info =3D balloon_page_device(page); + if (!b_dev_info) { + /* + * The page already got deflated and removed from the + * balloon list. + */ + spin_unlock_irqrestore(&balloon_pages_lock, flags); + return false; + } list_del(&page->lru); b_dev_info->isolated_pages++; spin_unlock_irqrestore(&balloon_pages_lock, flags); @@ -253,9 +241,6 @@ static int balloon_page_migrate(struct page *newpage, s= truct page *page, unsigned long flags; int rc; =20 - VM_BUG_ON_PAGE(!PageLocked(page), page); - VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); - /* * When we isolated the page, the page was still inflated in a balloon * device. As isolated balloon pages cannot get deflated, we still have @@ -293,10 +278,11 @@ static int balloon_page_migrate(struct page *newpage,= struct page *page, } =20 b_dev_info->isolated_pages--; - spin_unlock_irqrestore(&balloon_pages_lock, flags); =20 /* Free the now-deflated page we isolated in balloon_page_isolate(). */ balloon_page_finalize(page); + spin_unlock_irqrestore(&balloon_pages_lock, flags); + put_page(page); =20 return 0; --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80B821B142D; Mon, 19 Jan 2026 23:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863771; cv=none; b=KWFgJSfXexk426508muaEi/QnnuiPzpkZsq5JOnnrK53qUTH/xetB8WPkYoDnqiDbhlsLlr9Y5l8gsofZh3cgNARYpjf8mn7PzcwlFks5xKZwprBFa7YknQA8wzZknz7znrmEwUHk5CF84m9TYjBYr3FP2TFl/FThtx/kh4K3pQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863771; c=relaxed/simple; bh=L0GQNAdOR/JPbtfKkp93QvUS5ciLoWv5t16Us2SfM7A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ocy3pAjV4JHOXi8Ok+iGJzowI5kk7W2umzvXb/Vp4GE7NH8+kgWex/u2tND+hL/aiCF1u0+t5XaCvyFZLOKkb0eqeGut3VLTLzEQb/nDHOqjOmpnHgHiYiVuFDz3c7aeV7dXVWCcqsrLP+Ku5OfTV3VebYwNKKRxbmduX//+K0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HvOvpttf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HvOvpttf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D84FCC116C6; Mon, 19 Jan 2026 23:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863771; bh=L0GQNAdOR/JPbtfKkp93QvUS5ciLoWv5t16Us2SfM7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HvOvpttf1kAvLfqKLjmfytunK2LOvgBgWZQy98vpmZf7M69HJPyEbpN59hjBYAgAN 5IC6xIovQKda6++cNe2jxPvRgCcQJ+i8VziIHmD+7tQWhJ500BB/Szo1tx1O6Niu0y Qi5Ch2QWUIG2rXheRPalPAahZeIRoYRBP8prE05DO0S7M7eTw7FTcTH84epyfKTlhG dAy/nCWJ9Xevj+prD5Id4gP3Bda+nuYUvOyk7JlBtw/QY79TkePDV3UN9A2wMPFxQy XKgu9yINJPlolyHER1O5vx7qk05ZEiAOV+fLo5L70CTssW7IxUYcfiSq9tAC06TS5H 00IZRTVLUlvPA== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 10/24] mm/balloon_compaction: make balloon_mops static Date: Tue, 20 Jan 2026 00:01:18 +0100 Message-ID: <20260119230133.3551867-11-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is no need to expose this anymore, so let's just make it static. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- include/linux/balloon_compaction.h | 1 - mm/balloon_compaction.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index ad594af6ed100..7db66c2c86cdc 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -78,7 +78,6 @@ static inline void balloon_devinfo_init(struct balloon_de= v_info *balloon) } =20 #ifdef CONFIG_BALLOON_COMPACTION -extern const struct movable_operations balloon_mops; /* * balloon_page_device - get the b_dev_info descriptor for the balloon dev= ice * that enqueues the given page. diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 75763c73dbd52..cf4d931763920 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -288,7 +288,7 @@ static int balloon_page_migrate(struct page *newpage, s= truct page *page, return 0; } =20 -const struct movable_operations balloon_mops =3D { +static const struct movable_operations balloon_mops =3D { .migrate_page =3D balloon_page_migrate, .isolate_page =3D balloon_page_isolate, .putback_page =3D balloon_page_putback, --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1F9329BDAD; Mon, 19 Jan 2026 23:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863780; cv=none; b=n9T98ILd8oReq2kjz+SWm8oQIkr3GaYrCOhUUcjdyTfLfJBc4BZtHK+zewXuYS0GY4HEbIlKEQAE6vpcJ6gDzT/h/bbejXT19BLYaBXGu86p5lB6Bfk05mSB36B38odjyGZ4og/AxJcAsrVPojOnjtaeSJ4d6O0mmZHastn+gWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863780; c=relaxed/simple; bh=QtradRf0GStbdIUHbJa+QxsYtSkr1ee15tID6//kWAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oPGMSXAkHf2SDXUROECGj8K88wOXEgLZTfqoc8gZxSRmDzyoyZdsrX911FoD1jsDkCKV4OLwag59mQlpz7Br0U8W135gkxqQ0my2tPgTObPWA+NmklN8WNDRKuFDhEnjN6Y7MdtNx0/G8QkAd5lW2YfAYL1cGF8Es8Liuqlzp2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Br5khT2B; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Br5khT2B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5F01C116C6; Mon, 19 Jan 2026 23:02:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863778; bh=QtradRf0GStbdIUHbJa+QxsYtSkr1ee15tID6//kWAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Br5khT2BqgdVGETSbAaQu5YrjdjqXAvfXqQO1VMxW81Py8o5g7cf/09LcteyZ+CjP VMkGGAnJ8GPsE1LyANcYOnXfeiSRbDgg7MhrSmwtzPuqS4MgxJRjqVToYtAkXTPVJA 80NtDQhI3xgllJk3hAdxv2JszAzpIuLWMNjNgYDsHPyM1gnGqRaq8jiISVtc3DSKb1 4XUufNGKEG13eLM3e8HEUHsOs6WdQVrPLBpmRGZZS+cPouXUJUplA+4tg7GZ+4ZUma BO4JhKXQUjH3JcydqiW4udhJysaXEMdd7XxhQCej1whSbJaHBvADBiVb/EtAMzsa2t rnfM2VyKYEtZw== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 11/24] mm/balloon_compaction: drop fs.h include from balloon_compaction.h Date: Tue, 20 Jan 2026 00:01:19 +0100 Message-ID: <20260119230133.3551867-12-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Ever since commit 68f2736a8583 ("mm: Convert all PageMovable users to movable_operations") we no longer store an inode in balloon_dev_info, so we can stop including "fs.h". Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- include/linux/balloon_compaction.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index 7db66c2c86cdc..1452ea0635245 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -42,7 +42,6 @@ #include #include #include -#include #include =20 /* --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 747051DFD96; Mon, 19 Jan 2026 23:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863785; cv=none; b=i+mKrVw9XMUY3r7t8paQLE2sdOEbBH4O8gKebF5DuJcYpbpGRzjemZzkBFiJdUaLJJN9Yt2twU7uzvLN7dKQ6xNWN1mE1KpiNyPLpOIBE5serFjsoUuV8H7HQMyD6bzrr6Yf9dcfLVkluOLUBHoDslO7NwaeeWupwWrcpzlTvps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863785; c=relaxed/simple; bh=zj9sKtWRdKX3eQh5DiITmdQ2hR8ll6W7fi9C9Q8cgJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hpjBSqqkQwhhohgI+YcBi7s/UCVTeGgBItOJ0FBKUcXbDvREeEzVFYtoK2vnhVeJWtL8gjaNounk/y8BcJfUa2sJREEklTTGOB+awTo+zNp5KV5nNE3Z1dqV0mNMkcKzne6Q7OEGNHidddiljN5FdMF8zT6ry6WKbRmPyfeDF0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kmYAethO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kmYAethO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADCEAC19423; Mon, 19 Jan 2026 23:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863785; bh=zj9sKtWRdKX3eQh5DiITmdQ2hR8ll6W7fi9C9Q8cgJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kmYAethOA7nMRUFhdBBERTrxwJxKacgPLraITEsM51q/xkAq5MgpSYoRetjELCjTf pVGZC4C7WCra3xxAMTL9T8fnDQ2zTp5N1EdgmR7rCAgofrrFbDHOqRn3u7c10Sa9gT jANs1LZ+LwGchIOXjBKglorB87RFNVM8XFlI1Uqp2fTuIDfd9X9mhLBpit6JevElrF JFOT+2uHzHYISS3Zp0CFmwJy79JYaIJ26eOy+SbJouNGpVhad79c/Mu9FMsnAmElcx 4ebU+qhgPTIMYX/TP8G4jX7GahExH0+5k6idx5iApHdM1lOY370XAIHNAerzmvCZxw F2WUUFU/nU/6g== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 12/24] drivers/virtio/virtio_balloon: stop using balloon_page_push/pop() Date: Tue, 20 Jan 2026 00:01:20 +0100 Message-ID: <20260119230133.3551867-13-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's stop using these functions so we can remove them. They look like belonging to the balloon API for managing the device balloon list when really they are just simple helpers only used by virtio-balloon. Let's just inline them and switch to a proper list_for_each_entry_safe(). Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- drivers/virtio/virtio_balloon.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloo= n.c index 15c1cf5fd249c..6ae00de78b61b 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -242,8 +242,8 @@ static void set_page_pfns(struct virtio_balloon *vb, static unsigned int fill_balloon(struct virtio_balloon *vb, size_t num) { unsigned int num_allocated_pages; + struct page *page, *next; unsigned int num_pfns; - struct page *page; LIST_HEAD(pages); =20 /* We can only do one array worth at a time. */ @@ -262,14 +262,15 @@ static unsigned int fill_balloon(struct virtio_balloo= n *vb, size_t num) break; } =20 - balloon_page_push(&pages, page); + list_add(&page->lru, &pages); } =20 mutex_lock(&vb->balloon_lock); =20 vb->num_pfns =3D 0; =20 - while ((page =3D balloon_page_pop(&pages))) { + list_for_each_entry_safe(page, next, &pages, lru) { + list_del(&page->lru); balloon_page_enqueue(&vb->vb_dev_info, page); =20 set_page_pfns(vb, vb->pfns + vb->num_pfns, page); @@ -474,15 +475,19 @@ static inline s64 towards_target(struct virtio_balloo= n *vb) static unsigned long return_free_pages_to_mm(struct virtio_balloon *vb, unsigned long num_to_return) { - struct page *page; - unsigned long num_returned; + unsigned long num_returned =3D 0; + struct page *page, *next; + + if (unlikely(!num_to_return)) + return 0; =20 spin_lock_irq(&vb->free_page_list_lock); - for (num_returned =3D 0; num_returned < num_to_return; num_returned++) { - page =3D balloon_page_pop(&vb->free_page_list); - if (!page) - break; + + list_for_each_entry_safe(page, next, &vb->free_page_list, lru) { + list_del(&page->lru); __free_pages(page, VIRTIO_BALLOON_HINT_BLOCK_ORDER); + if (++num_returned =3D=3D num_to_return) + break; } vb->num_free_page_blocks -=3D num_returned; spin_unlock_irq(&vb->free_page_list_lock); @@ -717,7 +722,7 @@ static int get_free_page_and_send(struct virtio_balloon= *vb) } virtqueue_kick(vq); spin_lock_irq(&vb->free_page_list_lock); - balloon_page_push(&vb->free_page_list, page); + list_add(&page->lru, &vb->free_page_list); vb->num_free_page_blocks++; spin_unlock_irq(&vb->free_page_list_lock); } else { --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 472B021ABAA; Mon, 19 Jan 2026 23:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863792; cv=none; b=IuJPUpzZY3tFdiU/t6Rmm9jArkI08aQmJP1PBvvQjtygN3dHO8SbXBqnvPNu89R6mOpMxPkArV0cbuOvnzdIVhmShtC/OtbJGzUiSqzMxBiQ+f+YsaH08PsSUlCc9pXG8xQrLK38mj9y972mTcCRorWp0OCOS2ytTM9AjwUsO8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863792; c=relaxed/simple; bh=9+IQR5WDIB0jdvtNuLpX+r92qeOLZrM3xsnr4jLPT3c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o1HB6wwqGFwAAXVLOKnPOn2pKtHSbfHwmL6TWzV6KyCVR2BpdsQ2QaL16M9XQCA+PtdR1XP6LYVpj6RHQcwOQ1Z3J2gLuYZSQDY2HHbBRe4laHQ16TLXQp778Ip5NLnHG9tWFORyzxKmzOOUM6zHzvpqcFft1exiKQG2yJ1ImQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=quVR+O3k; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="quVR+O3k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3D84C19423; Mon, 19 Jan 2026 23:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863791; bh=9+IQR5WDIB0jdvtNuLpX+r92qeOLZrM3xsnr4jLPT3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=quVR+O3kmNVg+5kCP3gsApos7tcKXyU5nQWErVidQm/UYqerGdPB7CnDW0Yw/Rn8U DNFm9sEx96tM8FUQ5/U65G9jxtuBtKC1M+1fV5fezDXwciHUZV5PvD3+3nwa6AhUWb oxHQrOO+KAmpBi7iF4WVwa8A3pr+DGuK8euvz2caPK6MEFEoQWoUrJCmRuG/3twM9l pybklGrw2t4pUH6JWYfh9SbO/DubCvLonb34sekUJy/nyzBjBD16a9SK2l8pIzXpwG 50NkwEfYodwYwicj6e69EDG5crcButKepcpVF5GgnJTg6S6XC93tL1TGe0j/kSIWpM +WYXqkWI1Z1VA== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 13/24] mm/balloon_compaction: remove balloon_page_push/pop() Date: Tue, 20 Jan 2026 00:01:21 +0100 Message-ID: <20260119230133.3551867-14-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's remove these helpers as they are unused now. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- include/linux/balloon_compaction.h | 30 ------------------------------ mm/balloon_compaction.c | 5 ++--- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index 1452ea0635245..e5451cf1f6589 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -126,34 +126,4 @@ static inline void balloon_page_finalize(struct page *= page) set_page_private(page, 0); /* PageOffline is sticky until the page is freed to the buddy. */ } - -/* - * balloon_page_push - insert a page into a page list. - * @head : pointer to list - * @page : page to be added - * - * Caller must ensure the page is private and protect the list. - */ -static inline void balloon_page_push(struct list_head *pages, struct page = *page) -{ - list_add(&page->lru, pages); -} - -/* - * balloon_page_pop - remove a page from a page list. - * @head : pointer to list - * @page : page to be added - * - * Caller must ensure the page is private and protect the list. - */ -static inline struct page *balloon_page_pop(struct list_head *pages) -{ - struct page *page =3D list_first_entry_or_null(pages, struct page, lru); - - if (!page) - return NULL; - - list_del(&page->lru); - return page; -} #endif /* _LINUX_BALLOON_COMPACTION_H */ diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index cf4d931763920..5e1507a13a52f 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -128,9 +128,8 @@ EXPORT_SYMBOL_GPL(balloon_page_alloc); * Drivers must call this function to properly enqueue a new allocated bal= loon * page before definitively removing the page from the guest system. * - * Drivers must not call balloon_page_enqueue on pages that have been push= ed to - * a list with balloon_page_push before removing them with balloon_page_po= p. To - * enqueue a list of pages, use balloon_page_list_enqueue instead. + * Drivers must not enqueue pages while page->lru is still in + * use, and must not use page->lru until a page was unqueued again. */ void balloon_page_enqueue(struct balloon_dev_info *b_dev_info, struct page *page) --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A81F82D1F7B; Mon, 19 Jan 2026 23:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863799; cv=none; b=O9AefXIcQv+gBYYFtCJuIqsQgcYwDjgbCPY+CJVrBMa863QvmIBqgYZDVdlAH9rsoUlM7KR+9Q2tvAoIr56Kuwhs63t7ZnHMvymJ3VKogKQ4kCwtVqJewDT9zW9vhu/bltErIzi/6++gB/jJIqS/M0rlBli7DOF3/Dzs6BuG+QE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863799; c=relaxed/simple; bh=hAWBq8N2XzK189AInPRuJ5pazUVvYkJ/XMbZxTDq6Xg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZNCdy0BoEwibqab6CoK4puBsoUAaL5YaHHtmdYL3U9BpRnyCDqQ50aW/1OD77Tk9Lw4fSZpy7mNLZO1q22zM2On3so+c1YTg8o1CTvz86/Np0esIx9HE7AuwmXkfrvHHs4dY/Vq+4qlxDLdJ1OE+qf+JtKUWUcp9a4MCPDCV7oY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NFA8vN+u; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NFA8vN+u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C5E1C19423; Mon, 19 Jan 2026 23:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863799; bh=hAWBq8N2XzK189AInPRuJ5pazUVvYkJ/XMbZxTDq6Xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NFA8vN+uYHR1P2fcxt6dMoEyzFf4LfnUtoYyt9jx8oJu4wPKt6rnUGaOTyEZYUT6H dwRMcM3AoTHnOBj7Y7SeG8+dLb70NLGg6HzZVhlzoAopdTAJL5pwYzJCUst4v5Nryg LUAQfpNqqCc2x/VlxAiNNMB/3Eg1QT/Tp5j+5Itm9maLATp737NmUvp96+XTGqU5WW SUmW/x5bmEkWKMAH6dTnU9DSZfEc83G8WzB/PDYui+mc+2Bww/LK/PRCNT6Qzfu/dg 0n/5PvsszAJAl61QvjQpjJcfl3ka2RgTgd29liaO1naJSGx2w/SbzGWfP2kTIAK5Vu lvGnoxIaRtZwg== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 14/24] mm/balloon_compaction: fold balloon_mapping_gfp_mask() into balloon_page_alloc() Date: Tue, 20 Jan 2026 00:01:22 +0100 Message-ID: <20260119230133.3551867-15-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's just remove balloon_mapping_gfp_mask(). Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- include/linux/balloon_compaction.h | 7 ------- mm/balloon_compaction.c | 12 ++++++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index e5451cf1f6589..d1d4739398978 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -106,13 +106,6 @@ static inline void balloon_page_insert(struct balloon_= dev_info *balloon, list_add(&page->lru, &balloon->pages); } =20 -static inline gfp_t balloon_mapping_gfp_mask(void) -{ - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) - return GFP_HIGHUSER_MOVABLE; - return GFP_HIGHUSER; -} - /* * balloon_page_finalize - prepare a balloon page that was removed from the * balloon list for release to the page allocator diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 5e1507a13a52f..1843e168db3ca 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -112,10 +112,14 @@ EXPORT_SYMBOL_GPL(balloon_page_list_dequeue); */ struct page *balloon_page_alloc(void) { - struct page *page =3D alloc_page(balloon_mapping_gfp_mask() | - __GFP_NOMEMALLOC | __GFP_NORETRY | - __GFP_NOWARN); - return page; + gfp_t gfp_flags =3D __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN; + + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) + gfp_flags |=3D GFP_HIGHUSER_MOVABLE; + else + gfp_flags |=3D GFP_HIGHUSER; + + return alloc_page(gfp_flags); } EXPORT_SYMBOL_GPL(balloon_page_alloc); =20 --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3B0C21CC64; Mon, 19 Jan 2026 23:03:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863807; cv=none; b=ikWudK3vQhiEt0wzyw8nFDgjMLTn3mYO29L/nCnbzYJ1AwMl9cZbcZJzmWOKn1BhotHWgz98geNPi5cYaYl7yR9Tn6Io0fYmEUR9U33z+FfPgP+0Bqk2uZx4wpO7xLDnyZp4MMdXJ3YPnh/6sCaZiim+t5av7QCVDOh8dJRk6gI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863807; c=relaxed/simple; bh=8Lw1LCv6YJ97mwCYs+lybDIcRNkq6gN9hctm9VzKy2M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YzmzLetNUNaoGoIAbtgPumd16CVnsSKkIvprcRKLeWhQ/mjwaWzLK63KD++IcdnuNcjvjbTyPp9OH2y7IciTFjbCMPPRSy6Ml4RLb9Jw23El6n4bZjugdwqTAOGz41HC0aPGQtM+5qg8LU8UvmhLsriRbinLgSVgOdq/wewJdFY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LmwfS+Wr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LmwfS+Wr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0196C116C6; Mon, 19 Jan 2026 23:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863806; bh=8Lw1LCv6YJ97mwCYs+lybDIcRNkq6gN9hctm9VzKy2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LmwfS+WrZI/buk9JY+CG7Jfxa+mafIdXePK6bEkhmIlnJ+IMvH2Y8ZDXMtul2RIKG tAXnPAcwQ9mY6U9oV3qSMJOaVmCHgcjGnYuCxhCRZSwYTb+lL4rS8Qo84Phz8UcPUl BUsP/xpxRW5qZyDTKZ+LFa3DIy30EW3PFsZhLLEH3SHgxaY+qs3OoEVegAzEK5T5sP jnGj7Y/mfg3jJktddW1FJTE3RLD+7OGYSiYz42eQRca+mn/v8/pvZfZzxvTsu0fk68 nYoO4CGE6uAe3mWMicqWpFMVwdFxMeFFJzqGzfQzmNrDHTgvy1uUUUQP/KG6HfGtmu P4cf1xckiw3vA== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 15/24] mm/balloon_compaction: move internal helpers to balloon_compaction.c Date: Tue, 20 Jan 2026 00:01:23 +0100 Message-ID: <20260119230133.3551867-16-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's move the helpers that are not required by drivers anymore. While at it, drop the doc of balloon_page_device() as it is trivial. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) Reported-by: kernel test robot --- include/linux/balloon_compaction.h | 44 ------------------------------ mm/balloon_compaction.c | 38 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 44 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index d1d4739398978..eec8994056a44 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -75,48 +75,4 @@ static inline void balloon_devinfo_init(struct balloon_d= ev_info *balloon) balloon->migratepage =3D NULL; balloon->adjust_managed_page_count =3D false; } - -#ifdef CONFIG_BALLOON_COMPACTION -/* - * balloon_page_device - get the b_dev_info descriptor for the balloon dev= ice - * that enqueues the given page. - */ -static inline struct balloon_dev_info *balloon_page_device(struct page *pa= ge) -{ - return (struct balloon_dev_info *)page_private(page); -} -#endif /* CONFIG_BALLOON_COMPACTION */ - -/* - * balloon_page_insert - insert a page into the balloon's page list and ma= ke - * the page->private assignment accordingly. - * @balloon : pointer to balloon device - * @page : page to be assigned as a 'balloon page' - * - * Caller must ensure the balloon_pages_lock is held. - */ -static inline void balloon_page_insert(struct balloon_dev_info *balloon, - struct page *page) -{ - __SetPageOffline(page); - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) { - SetPageMovableOps(page); - set_page_private(page, (unsigned long)balloon); - } - list_add(&page->lru, &balloon->pages); -} - -/* - * balloon_page_finalize - prepare a balloon page that was removed from the - * balloon list for release to the page allocator - * @page: page to be released to the page allocator - * - * Caller must ensure the balloon_pages_lock is held. - */ -static inline void balloon_page_finalize(struct page *page) -{ - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) - set_page_private(page, 0); - /* PageOffline is sticky until the page is freed to the buddy. */ -} #endif /* _LINUX_BALLOON_COMPACTION_H */ diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 1843e168db3ca..e0a4b481c3eda 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -17,6 +17,44 @@ */ static DEFINE_SPINLOCK(balloon_pages_lock); =20 +static struct balloon_dev_info *balloon_page_device(struct page *page) +{ + return (struct balloon_dev_info *)page_private(page); +} + +/* + * balloon_page_insert - insert a page into the balloon's page list and ma= ke + * the page->private assignment accordingly. + * @balloon : pointer to balloon device + * @page : page to be assigned as a 'balloon page' + * + * Caller must ensure the balloon_pages_lock is held. + */ +static void balloon_page_insert(struct balloon_dev_info *balloon, + struct page *page) +{ + __SetPageOffline(page); + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) { + SetPageMovableOps(page); + set_page_private(page, (unsigned long)balloon); + } + list_add(&page->lru, &balloon->pages); +} + +/* + * balloon_page_finalize - prepare a balloon page that was removed from the + * balloon list for release to the page allocator + * @page: page to be released to the page allocator + * + * Caller must ensure the balloon_pages_lock is held. + */ +static void balloon_page_finalize(struct page *page) +{ + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) + set_page_private(page, 0); + /* PageOffline is sticky until the page is freed to the buddy. */ +} + static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info, struct page *page) { --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C61176FC3; Mon, 19 Jan 2026 23:03:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863813; cv=none; b=dwzP5N6SL+rb4zneQOE1jM5Ss02HAfNvmoCs1dlETJGin4tVoMbDewW2NumVbkiDQaR9BlkROIbcsmT/chkEnfpz0oNrQpVOngmeifemXqDRjua8oyTsiQ6ME3vchYMm0ceAdWmTTZDT/IcvaKoxVLw/Y41sp4YE/QfYkY5m7x4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863813; c=relaxed/simple; bh=93bCC0t6vSff2vK8TVOF8nE3nZ/IKYJWWQ5I2pcLHSg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZxsQjN3bdI5ov6xzYAM64nT+iIrLyJsQhq6knKDEQ99n+4c7fAnyt+iTH5IglYl4z5Q0J7k8Dcmn+zskXv1M5K/SzR5Ak9/ot/DOxgBFTccODDuSigYVraZjMnDCW7BPU8ajGaQzJIVSarEh78AoNtqdSmo04ejrvNWzZbTosQY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JOFQQSl3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JOFQQSl3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AE3BC116C6; Mon, 19 Jan 2026 23:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863813; bh=93bCC0t6vSff2vK8TVOF8nE3nZ/IKYJWWQ5I2pcLHSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JOFQQSl3AQjJzyLdOYrRwc0dbiFxoJf/oza6XFRsomdnnGo9O/OX5gzccdwhSVAzd eUUGHNU9pBbhGaBYhz2UG4QleWsuFA3IfyZYp0y+Pogp9exSIRdeujhZTKkfU4uTQp wXYzgkMwBOWrX0vUSyhU35NIc97JkVBhLG+862uizkAT4HLinjE2jSbCewl/b5RZAT ZekWMFOYRgBb/iN0UioxgVJC8SV5NUVf7KktwPqhiTpLShfkv98cBCzBgcYFo3gFH1 5alKNgx5IzaY2+JIomSSnEU1ASOeg+eBrlVyrnfV0w/vnhLfhzhnh2LoTMpUr28Dcg RqL1z5c7xZa0w== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 16/24] mm/balloon_compaction: assert that the balloon_pages_lock is held Date: Tue, 20 Jan 2026 00:01:24 +0100 Message-ID: <20260119230133.3551867-17-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's add some sanity checks for holding the balloon_pages_lock when we're effectively inflating/deflating a page. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- mm/balloon_compaction.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index e0a4b481c3eda..bb2e5ec2cab36 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -33,6 +33,7 @@ static struct balloon_dev_info *balloon_page_device(struc= t page *page) static void balloon_page_insert(struct balloon_dev_info *balloon, struct page *page) { + lockdep_assert_held(&balloon_pages_lock); __SetPageOffline(page); if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) { SetPageMovableOps(page); @@ -50,6 +51,7 @@ static void balloon_page_insert(struct balloon_dev_info *= balloon, */ static void balloon_page_finalize(struct page *page) { + lockdep_assert_held(&balloon_pages_lock); if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) set_page_private(page, 0); /* PageOffline is sticky until the page is freed to the buddy. */ --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AADA21CC64; Mon, 19 Jan 2026 23:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863820; cv=none; b=JFHv76R5iWV3PBszBtSgyIsneMt/sVuaHt8yiezvwAI5GbtVl1Kv7FUOALkZf7WEg5kB8QCRFmt/5WvTzK4o0he/Fg+zWw6HFMz6iDY9r3OZibF91RpDvRoulfN5Rcnv0LJSH5aAZqfINhQDpLOXhS6VdKMykROl7DltYhPYhs8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863820; c=relaxed/simple; bh=U0Kl+wiD7v3bKS5MxUETuhXKt1l6XvM+u7VYx7CD0wU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=POfQ7JncuH//O+pe6JcKOtJDNQkczWu0yQW7w6JdzbEqj2mcyZ6n1XW/t+QvGipXBfWDHb+erMgHbywIfKvKBNa26/eTcdwge1ZUgZhEzl6IqDQ3fqvmYwe6R2z/zipFRPziLM2XzvRK/uM8i504sCrWBFZVTwcjyKcgADxJcgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CbR4/Q8M; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CbR4/Q8M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09188C116C6; Mon, 19 Jan 2026 23:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863820; bh=U0Kl+wiD7v3bKS5MxUETuhXKt1l6XvM+u7VYx7CD0wU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CbR4/Q8MGKn20B7dYkI0WERNBQpNiLPadHF0o6WRRYBGXVaXdkKG1IUYpLM7yKpns JP+Gs7INtEgWBX37ODz55WyATkn4jClfJ8stBh4Y9ShJGBnGTn/nPjL327uPgsExHP GqyvyFar2f8t7jcmtiuIMMHpf5k6jdG/rZ3vJ8DjwlquaT+nBx0+kbrD86o6MaPmFp dWU+tCcNAmu5BrfUdCmxyNRWZ1A7xCj9lZTV1WQwMDApWozkQVGBw8pvMAlsNeTFep GLoKngx/33AtVqUW/1pR9pcY5a8xX5eB9BiZPrjq1Vlic4cr+9WEjxqRCD+y8uMdVO 149k+T2c2kT9Q== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 17/24] mm/balloon_compaction: mark remaining functions for having proper kerneldoc Date: Tue, 20 Jan 2026 00:01:25 +0100 Message-ID: <20260119230133.3551867-18-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Looks like all we are missing for proper kerneldoc is another "*". Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- mm/balloon_compaction.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index bb2e5ec2cab36..bed30c6c1a487 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -22,7 +22,7 @@ static struct balloon_dev_info *balloon_page_device(struc= t page *page) return (struct balloon_dev_info *)page_private(page); } =20 -/* +/** * balloon_page_insert - insert a page into the balloon's page list and ma= ke * the page->private assignment accordingly. * @balloon : pointer to balloon device @@ -42,7 +42,7 @@ static void balloon_page_insert(struct balloon_dev_info *= balloon, list_add(&page->lru, &balloon->pages); } =20 -/* +/** * balloon_page_finalize - prepare a balloon page that was removed from the * balloon list for release to the page allocator * @page: page to be released to the page allocator @@ -140,7 +140,7 @@ size_t balloon_page_list_dequeue(struct balloon_dev_inf= o *b_dev_info, } EXPORT_SYMBOL_GPL(balloon_page_list_dequeue); =20 -/* +/** * balloon_page_alloc - allocates a new page for insertion into the balloon * page list. * @@ -163,7 +163,7 @@ struct page *balloon_page_alloc(void) } EXPORT_SYMBOL_GPL(balloon_page_alloc); =20 -/* +/** * balloon_page_enqueue - inserts a new page into the balloon page list. * * @b_dev_info: balloon device descriptor where we will insert a new page @@ -186,7 +186,7 @@ void balloon_page_enqueue(struct balloon_dev_info *b_de= v_info, } EXPORT_SYMBOL_GPL(balloon_page_enqueue); =20 -/* +/** * balloon_page_dequeue - removes a page from balloon's page list and retu= rns * its address to allow the driver to release the page. * @b_dev_info: balloon device descriptor where we will grab a page from. --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64F172C08AB; Mon, 19 Jan 2026 23:03:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863827; cv=none; b=jioO3fussbTx82dJbgU2o6ald81VNxVYfEnVxiJmhmAkOKheXgSqhGQLSRsNln3/Gcxpcqh+S6i60k3yY70DJiOkJ2QSKJM+ZRPDzys+001Kr4jK2InobZ7oAPlMNN1noq51WK7kIb4hzOmJT0urB7igSWD1+wiMf1HDYlprnPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863827; c=relaxed/simple; bh=KZzIizZvvXk5/lfOietMXSEPEGZqiuCDOnY5HWS5lB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KVmVuWUDX7uraKUu7CpKuvKgVQCkIfodt1LrI/eBpn8mMMqLxS/wVDw/DuI5W9FnIw2thFcn002XFs/Lkd5PQVw47qC+yocstXFdfDR/ugngJbbUiDIRP83wgHBy/95dlxbgt7xLLjnIJ9/Aaz1cfoVnV27fNgV6lQ/P40/GYSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f8J/4Vdc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f8J/4Vdc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19448C2BC87; Mon, 19 Jan 2026 23:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863827; bh=KZzIizZvvXk5/lfOietMXSEPEGZqiuCDOnY5HWS5lB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f8J/4Vdc+eCRJIAoxZbYJ40lQpJ5YxM1F/DqyvPfB4iJiREt/aP0cufXXYmkJTiIM rh0LWKL3Nl0Ig6I/DaxSbZKowewwb6MLwBm7BJJM7POJE6T/6Wb4590Bv4XgR6miZz uCagcFY0+R+8aQpuwm359CC04g5+OYUbM8mPxOLnyFL2g2jXX5Z2xE7rr+QfftChow 4Kfzlq3Guc+H5BI7frRkqQcFPbG757vyABP3hefzynK6Qxh39ZXxZ09NfWxMCn0UVR 1BRBgGimswwiqjm1cQ0jMqScckqGXfw5zyMHy1U0YopOuZK/DGiBJhdz2D+GLvFryi ae0irgoEhRC6g== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 18/24] mm/balloon_compaction: remove "extern" from functions Date: Tue, 20 Jan 2026 00:01:26 +0100 Message-ID: <20260119230133.3551867-19-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Adding "extern" to functions is frowned-upon. Let's just get rid of it for all functions here. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- include/linux/balloon_compaction.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index eec8994056a44..7757e0e314fdb 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -59,14 +59,14 @@ struct balloon_dev_info { bool adjust_managed_page_count; }; =20 -extern struct page *balloon_page_alloc(void); -extern void balloon_page_enqueue(struct balloon_dev_info *b_dev_info, - struct page *page); -extern struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_in= fo); -extern size_t balloon_page_list_enqueue(struct balloon_dev_info *b_dev_inf= o, - struct list_head *pages); -extern size_t balloon_page_list_dequeue(struct balloon_dev_info *b_dev_inf= o, - struct list_head *pages, size_t n_req_pages); +struct page *balloon_page_alloc(void); +void balloon_page_enqueue(struct balloon_dev_info *b_dev_info, + struct page *page); +struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info); +size_t balloon_page_list_enqueue(struct balloon_dev_info *b_dev_info, + struct list_head *pages); +size_t balloon_page_list_dequeue(struct balloon_dev_info *b_dev_info, + struct list_head *pages, size_t n_req_pages); =20 static inline void balloon_devinfo_init(struct balloon_dev_info *balloon) { --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2EEB1DC9B3; Mon, 19 Jan 2026 23:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863835; cv=none; b=GAwyJ+jGWcu7qJzPsDpOrGarOjsJlObVbA9ajCjaCe32hIrrl9s3KVr+MzdvlmixouATuqsNRRAQdRNzacv1giRo4YtF9yNKD9GJEMtTfpYpTYzfDnnSreMo7xYsGfnjlYicDbI2pHSaGPW/RMj/z5JYhKv3ecUYpaFo4IFDsbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863835; c=relaxed/simple; bh=kH1VyttzME5xFeeFdR/qAHeXrLO5pFzDG/LyJb7V0HA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eFTloM1Ag1xf8wE6M/8nLH+y3QKbEmNfCiXgygyCqNuPnla0mLLQMPAO3KwFUDsOYeJ45Hi+5//WV94pqpAiy7krkI8i0odn9OQGRFHUoNz/nav8s9paMiuW9lokRMO+TxToBerwPf45bDkSyw245WsyH5FCkZFyaOTUrfYSq4c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vIW4fuGu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vIW4fuGu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C09B1C19423; Mon, 19 Jan 2026 23:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863834; bh=kH1VyttzME5xFeeFdR/qAHeXrLO5pFzDG/LyJb7V0HA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vIW4fuGu6Fvm5fTOSiPeFfrt4FFXeyafRlE/6kmfcrtG7aEdsGaWbIX8IeNn0sRPI D1gHKWfPif0n1VW7nAJDk74228u1Cqx673N4Z9fsSSg05aYrMD2ZIUbz9hY/4oO7bM VL4FmwdTOM8cvcKd/7ean9yDQe6QSyh5qIrWAMD4tSL/fBAfsAXe2BxwiO8AyPSWlw Sd014FoSAVVq/hPIOFEXgyp+hyyWVjl/iMDU9M1xyvBBnP83HdnmLnVyHuaoHkldUy jj+CCjjMAKeHDv2/xjWGDVT/h7E+d6KiWNokqEor3Ae83lM+IA1yIRczDY3yZDzAwQ eP3Gi+2s8wxjg== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 19/24] mm/vmscan: drop inclusion of balloon_compaction.h Date: Tue, 20 Jan 2026 00:01:27 +0100 Message-ID: <20260119230133.3551867-20-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Before commit b1123ea6d3b3 ("mm: balloon: use general non-lru movable page feature"), the include was required because of isolated_balloon_page(). It's no longer required, so let's remove it. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- mm/vmscan.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index a0e3f51de749e..cd9f9a779e89b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -63,7 +63,6 @@ #include =20 #include -#include #include =20 #include "internal.h" --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 819B31EA7CB; Mon, 19 Jan 2026 23:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863841; cv=none; b=sBXEn5dvx+fnEZG7foSAOqpLNgubUaRI8GUXciRS3839m1qzkbtruiFxo5zfueuiaOrOhzQY3Ozbk9KVTQzYF5dM4dWUYN2kvsfcGzOHdCrpC6nCDws7VdjPHSSTwq1GVZ/xsLp5nlxL+00aqREzxbZ/sBjVWf2tAReWBPjcU0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863841; c=relaxed/simple; bh=GT7gMb9052k09b7feSno+zVM6CU/qsSXOXmaT6CsVkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AE7nxVMSlHf1+dYSRZW41cxHl9IIcZImCWtG5D1dcZfd9QiFHE5RVw79FkWV0SH+6R19Lw+zeSmQRLpWrHkslYKtlIlWAEU8l2W6JnsXeBA3j2M0O65jwuZ//zyi0Ll63tMO0S21ZVB6tFXFRTdOMcHuxjBxiCjk/pc+r1WRFCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Egk6IAbZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Egk6IAbZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2698C19424; Mon, 19 Jan 2026 23:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863841; bh=GT7gMb9052k09b7feSno+zVM6CU/qsSXOXmaT6CsVkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Egk6IAbZ0Z786ez2iuplNWTllT0uMarzPHhKBT5TZiJqtlB1NAfHjfRnXfav89zqN IZuNVh/TQyEZFMB+SEqEhvAMYHiWSlEI9hGbWlZPR9VmWQGCb1P8u2S3huLb1RrMZ7 /whZLTSUXsQLHaVJB19h/E3ALFef1pmo3tU0nkzaMJl5ylg6TCKtJ3taeyXF/E+rRr EgSufQo1nUeXpE5NmIYyHnHWrNT6/m+uPxYmKIPTi4EfE9Bwv273iA5QREtx6vPPv4 pJz5ClAL2L58t1rUTTBRoXIRMqQLNxU3RWRN6GUE6OcRKdRxaeWgTahjwjICqaOMkY YSdJgeMAuzWng== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 20/24] mm: rename balloon_compaction.(c|h) to balloon.(c|h) Date: Tue, 20 Jan 2026 00:01:28 +0100 Message-ID: <20260119230133.3551867-21-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Even without CONFIG_BALLOON_COMPACTION this infrastructure implements basic list and page management for a memory balloon. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- Documentation/core-api/mm-api.rst | 2 +- MAINTAINERS | 4 ++-- arch/powerpc/platforms/pseries/cmm.c | 2 +- drivers/misc/vmw_balloon.c | 2 +- drivers/virtio/virtio_balloon.c | 2 +- include/linux/{balloon_compaction.h =3D> balloon.h} | 11 +++++------ mm/Makefile | 2 +- mm/{balloon_compaction.c =3D> balloon.c} | 7 +++---- 8 files changed, 15 insertions(+), 17 deletions(-) rename include/linux/{balloon_compaction.h =3D> balloon.h} (92%) rename mm/{balloon_compaction.c =3D> balloon.c} (98%) diff --git a/Documentation/core-api/mm-api.rst b/Documentation/core-api/mm-= api.rst index 68193a4cfcf52..aabdd3cba58e8 100644 --- a/Documentation/core-api/mm-api.rst +++ b/Documentation/core-api/mm-api.rst @@ -130,5 +130,5 @@ More Memory Management Functions .. kernel-doc:: mm/vmscan.c .. kernel-doc:: mm/memory_hotplug.c .. kernel-doc:: mm/mmu_notifier.c -.. kernel-doc:: mm/balloon_compaction.c +.. kernel-doc:: mm/balloon.c .. kernel-doc:: mm/huge_memory.c diff --git a/MAINTAINERS b/MAINTAINERS index 0d044a58cbfe0..de8f89ca1149f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27536,9 +27536,9 @@ M: David Hildenbrand L: virtualization@lists.linux.dev S: Maintained F: drivers/virtio/virtio_balloon.c -F: include/linux/balloon_compaction.h +F: include/linux/balloon.h F: include/uapi/linux/virtio_balloon.h -F: mm/balloon_compaction.c +F: mm/balloon.c =20 VIRTIO BLOCK AND SCSI DRIVERS M: "Michael S. Tsirkin" diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/= pseries/cmm.c index 7fd8b3d7e7637..7a3c4922685ab 100644 --- a/arch/powerpc/platforms/pseries/cmm.c +++ b/arch/powerpc/platforms/pseries/cmm.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 53e9335b6718c..7fd3f709108c2 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloo= n.c index 6ae00de78b61b..de8041c3285a1 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon.h similarity index 92% rename from include/linux/balloon_compaction.h rename to include/linux/balloon.h index 7757e0e314fdb..82585542300d6 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * include/linux/balloon_compaction.h - * - * Common interface definitions for making balloon pages movable by compac= tion. + * Common interface for implementing a memory balloon, including support + * for migration of pages inflated in a memory balloon. * * Balloon page migration makes use of the general "movable_ops page migra= tion" * feature. @@ -35,8 +34,8 @@ * * Copyright (C) 2012, Red Hat, Inc. Rafael Aquini */ -#ifndef _LINUX_BALLOON_COMPACTION_H -#define _LINUX_BALLOON_COMPACTION_H +#ifndef _LINUX_BALLOON_H +#define _LINUX_BALLOON_H #include #include #include @@ -75,4 +74,4 @@ static inline void balloon_devinfo_init(struct balloon_de= v_info *balloon) balloon->migratepage =3D NULL; balloon->adjust_managed_page_count =3D false; } -#endif /* _LINUX_BALLOON_COMPACTION_H */ +#endif /* _LINUX_BALLOON_H */ diff --git a/mm/Makefile b/mm/Makefile index 9175f8cc65658..1e31e0a528dc1 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -122,7 +122,7 @@ obj-$(CONFIG_CMA) +=3D cma.o obj-$(CONFIG_NUMA) +=3D numa.o obj-$(CONFIG_NUMA_MEMBLKS) +=3D numa_memblks.o obj-$(CONFIG_NUMA_EMU) +=3D numa_emulation.o -obj-$(CONFIG_MEMORY_BALLOON) +=3D balloon_compaction.o +obj-$(CONFIG_MEMORY_BALLOON) +=3D balloon.o obj-$(CONFIG_PAGE_EXTENSION) +=3D page_ext.o obj-$(CONFIG_PAGE_TABLE_CHECK) +=3D page_table_check.o obj-$(CONFIG_CMA_DEBUGFS) +=3D cma_debug.o diff --git a/mm/balloon_compaction.c b/mm/balloon.c similarity index 98% rename from mm/balloon_compaction.c rename to mm/balloon.c index bed30c6c1a487..25e2a1e71eba9 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon.c @@ -1,15 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * mm/balloon_compaction.c - * - * Common interface for making balloon pages movable by compaction. + * Common interface for implementing a memory balloon, including support + * for migration of pages inflated in a memory balloon. * * Copyright (C) 2012, Red Hat, Inc. Rafael Aquini */ #include #include #include -#include +#include =20 /* * Lock protecting the balloon_dev_info of all devices. We don't really --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF70929BDAD; Mon, 19 Jan 2026 23:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863848; cv=none; b=VGTbXVKOEB5O+qQcaEMIXsoANbaOXWeadGcDy+4wSeZ0o4swbSjGbxIWHqDJtT3mqQrRUs/23i4bQqeTkXocVQmU6fdAoLIYjKosTdAa6FXKZg3WEdORL6VM+1kX3ZOucnpddfdDcPeGr98xAmFYgE3dvFE5Oj/D6XyZSmbDUIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863848; c=relaxed/simple; bh=8BBEwEPOV2feM9asWnviMEeN61fjbzDKcbDTnI9BSWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N5Qp+/TBS4VhfE4iyzwLWNwwrwUfz33ZHjNq/nhSLXUI9Nabz2H/YdFjf8jv+ViJHY7I6QRPlbB6flSqz07z3pmJFWUqCyP4kQ0HMy1cjd/QpUEIuI5XR+7XIinAni8UdG5WBMOGhTsLP7B7HUHSSvxmICPLma1kuq/zej+A+pA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ggts6Muq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ggts6Muq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F420BC19423; Mon, 19 Jan 2026 23:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863848; bh=8BBEwEPOV2feM9asWnviMEeN61fjbzDKcbDTnI9BSWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ggts6MuqPRmp6JPKI/imH0YjdupgG5Kahp6IN70J2t4YhljglpCtvsW2PUxClQiDt Wj6Hp7ccAdgQvsCFQZvMpmP7bB96YInjP5Q/zNtIg9AqiTpTECEQpc9kKMrGX4pN0t g3dDc1LkJMKSq4460pcW4IT+gsEI4J+CDyG2zu6z2gQPaSl6aVVYh302a8Gs1s7yrw nvBRzFeoUppU9xGXtblIuqvYXVTFyJq2E16Y+kqYPerTaWPq+GM6IU11YHnz8WpJbA Q1HICF/dmj34sRYrmkAOizVVXHXgufQSJQBq7HwJwOBBpkZ0vSBys3vymkNvqTa/0+ pMNsBWcnlnQXw== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 21/24] mm/kconfig: make BALLOON_COMPACTION depend on MIGRATION Date: Tue, 20 Jan 2026 00:01:29 +0100 Message-ID: <20260119230133.3551867-22-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Migration support for balloon memory depends on MIGRATION not COMPACTION. Compaction is simply another user of page migration. The last dependency on compaction.c was effectively removed with commit 3d388584d599 ("mm: convert "movable" flag in page->mapping to a page flag"). Ever since, everything for handling movable_ops page migration resides in core migration code. So let's change the dependency and adjust the description + help text. We'll rename BALLOON_COMPACTION separately next. Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- mm/Kconfig | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 24a3ff149a1b0..0d13c1b36e1c1 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -599,17 +599,14 @@ config MEMORY_BALLOON # # support for memory balloon compaction config BALLOON_COMPACTION - bool "Allow for balloon memory compaction/migration" + bool "Allow for balloon memory migration" default y - depends on COMPACTION && MEMORY_BALLOON - help - Memory fragmentation introduced by ballooning might reduce - significantly the number of 2MB contiguous memory blocks that can be - used within a guest, thus imposing performance penalties associated - with the reduced number of transparent huge pages that could be used - by the guest workload. Allowing the compaction & migration for memory - pages enlisted as being part of memory balloon devices avoids the - scenario aforementioned and helps improving memory defragmentation. + depends on MIGRATION && MEMORY_BALLOON + help + Allow for migration of pages inflated in a memory balloon such that + they can be allocated from memory areas only available for movable + allocations (e.g., ZONE_MOVABLE, CMA) and such that they can be + migrated for memory defragmentation purposes by memory compaction. =20 # # support for memory compaction --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45276296BC8; Mon, 19 Jan 2026 23:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863855; cv=none; b=DWDlAKuDsxbxL+CwhoVaJCTB/KE9sUvHK8SaumLA4Ra5tGitll9aas6cPTqfKtA1tCxym9eUF3KJt8+6TTuyuhyl6S3EVbQtvnkGWvsb1TPwUroPTNX9Fev0pakfVYRCPAxaMoGwi/6h7VjGCHEbGuK4gl4XRJAMBhsBOKlO9MI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863855; c=relaxed/simple; bh=rfLKWCy9vJo0cdwgW26hFt2Hmw6jpwEGhVTR8rbPNG0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AJVuKDZnDelPHHBB2VjIlACbsO7euTO3HKUNwg/38oTKIjPI5MyBQFX4HkcT3QKIJ7yetncj61mKChOkdqt3mR4xV2Ba1mvyvgdvU5V+cqHHhZfhmsvdwDpldvIcUsvZuymQNxVK6v8b9br8FYyIqTFHQig3cnwJUsh/lKQrZ0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oYhem+Ry; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oYhem+Ry" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D026BC116C6; Mon, 19 Jan 2026 23:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863854; bh=rfLKWCy9vJo0cdwgW26hFt2Hmw6jpwEGhVTR8rbPNG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oYhem+RyIfPYbRq/FfuQqbLgtWgy8BpIVjnZIFIo2pyBjNu0tkitvJixH2VAC5iwL 0udZb3Nwm9Nm9mnEfvtHLW9oTj17v3gePhwKqKsuwG2spWtGT7wrjMglu7Jk7xwwVL qgc0gO5oasN5SIWAvQ+fmSdW5X/8qWWN/6b89nNhT8qBhxDZLcl0dhrwWMDIQKhrbL 4k0sEibe6agRVrTRCbUTDZod92Sk3LXFSBCuK4MfajLCooB3qJFV8miYoiSDHNq1rg rRJf65xLWtvgrRdbaPTINUhuOO9OWGtADn303tSQQFRZaQP/O2FnwV9COpZS1oFNGo 4HRrRgQ99HmKA== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 22/24] mm: rename CONFIG_BALLOON_COMPACTION to CONFIG_BALLOON_MIGRATION Date: Tue, 20 Jan 2026 00:01:30 +0100 Message-ID: <20260119230133.3551867-23-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While compaction depends on migration, the other direction is not the case. So let's make it clearer that this is all about migration of balloon pages. Adjust all comments/docs in the core to talk about "migration" instead of "compaction". While at it add some "/* CONFIG_BALLOON_MIGRATION */". Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- Documentation/admin-guide/mm/memory-hotplug.rst | 8 ++++---- arch/powerpc/platforms/pseries/cmm.c | 8 ++++---- drivers/misc/vmw_balloon.c | 8 ++++---- drivers/virtio/virtio_balloon.c | 6 +++--- include/linux/balloon.h | 12 ++++++------ include/linux/vm_event_item.h | 4 ++-- mm/Kconfig | 4 ++-- mm/balloon.c | 10 +++++----- mm/memory_hotplug.c | 4 ++-- mm/migrate.c | 2 +- mm/vmstat.c | 4 ++-- 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentatio= n/admin-guide/mm/memory-hotplug.rst index 6581558fd0d7a..0207f87251421 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -603,11 +603,11 @@ ZONE_MOVABLE, especially when fine-tuning zone ratios: memory for metadata and page tables in the direct map; having a lot of o= ffline memory blocks is not a typical case, though. =20 -- Memory ballooning without balloon compaction is incompatible with - ZONE_MOVABLE. Only some implementations, such as virtio-balloon and - pseries CMM, fully support balloon compaction. +- Memory ballooning without support for balloon memory migration is incomp= atible + with ZONE_MOVABLE. Only some implementations, such as virtio-balloon and + pseries CMM, fully support balloon memory migration. =20 - Further, the CONFIG_BALLOON_COMPACTION kernel configuration option might= be + Further, the CONFIG_BALLOON_MIGRATION kernel configuration option might = be disabled. In that case, balloon inflation will only perform unmovable allocations and silently create a zone imbalance, usually triggered by inflation requests from the hypervisor. diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/= pseries/cmm.c index 7a3c4922685ab..8d83df12430f2 100644 --- a/arch/powerpc/platforms/pseries/cmm.c +++ b/arch/powerpc/platforms/pseries/cmm.c @@ -494,7 +494,7 @@ static struct notifier_block cmm_mem_nb =3D { .priority =3D CMM_MEM_HOTPLUG_PRI }; =20 -#ifdef CONFIG_BALLOON_COMPACTION +#ifdef CONFIG_BALLOON_MIGRATION static int cmm_migratepage(struct balloon_dev_info *b_dev_info, struct page *newpage, struct page *page, enum migrate_mode mode) @@ -520,10 +520,10 @@ static int cmm_migratepage(struct balloon_dev_info *b= _dev_info, plpar_page_set_active(page); return 0; } -#else /* CONFIG_BALLOON_COMPACTION */ +#else /* CONFIG_BALLOON_MIGRATION */ int cmm_migratepage(struct balloon_dev_info *b_dev_info, struct page *newp= age, struct page *page, enum migrate_mode mode); -#endif /* CONFIG_BALLOON_COMPACTION */ +#endif /* CONFIG_BALLOON_MIGRATION */ =20 /** * cmm_init - Module initialization @@ -540,7 +540,7 @@ static int cmm_init(void) =20 balloon_devinfo_init(&b_dev_info); b_dev_info.adjust_managed_page_count =3D true; - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) + if (IS_ENABLED(CONFIG_BALLOON_MIGRATION)) b_dev_info.migratepage =3D cmm_migratepage; =20 rc =3D register_oom_notifier(&cmm_oom_nb); diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 7fd3f709108c2..216a163959684 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1719,7 +1719,7 @@ static inline void vmballoon_debugfs_exit(struct vmba= lloon *b) #endif /* CONFIG_DEBUG_FS */ =20 =20 -#ifdef CONFIG_BALLOON_COMPACTION +#ifdef CONFIG_BALLOON_MIGRATION /** * vmballoon_migratepage() - migrates a balloon page. * @b_dev_info: balloon device information descriptor. @@ -1803,11 +1803,11 @@ static int vmballoon_migratepage(struct balloon_dev= _info *b_dev_info, up_read(&b->conf_sem); return ret; } -#else /* CONFIG_BALLOON_COMPACTION */ +#else /* CONFIG_BALLOON_MIGRATION */ int vmballoon_migratepage(struct balloon_dev_info *b_dev_info, struct page *newpage, struct page *page, enum migrate_mode mode); -#endif /* CONFIG_BALLOON_COMPACTION */ +#endif /* CONFIG_BALLOON_MIGRATION */ =20 static int __init vmballoon_init(void) { @@ -1827,7 +1827,7 @@ static int __init vmballoon_init(void) return error; =20 balloon_devinfo_init(&balloon.b_dev_info); - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) + if (IS_ENABLED(CONFIG_BALLOON_MIGRATION)) balloon.b_dev_info.migratepage =3D vmballoon_migratepage; =20 INIT_LIST_HEAD(&balloon.huge_pages); diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloo= n.c index de8041c3285a1..4e549abe59ff1 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -802,7 +802,7 @@ static void report_free_page_func(struct work_struct *w= ork) } } =20 -#ifdef CONFIG_BALLOON_COMPACTION +#ifdef CONFIG_BALLOON_MIGRATION /* * virtballoon_migratepage - perform the balloon page migration on behalf = of * a compaction thread. (called under page lock) @@ -851,7 +851,7 @@ static int virtballoon_migratepage(struct balloon_dev_i= nfo *vb_dev_info, mutex_unlock(&vb->balloon_lock); return 0; } -#endif /* CONFIG_BALLOON_COMPACTION */ +#endif /* CONFIG_BALLOON_MIGRATION */ =20 static unsigned long shrink_free_pages(struct virtio_balloon *vb, unsigned long pages_to_free) @@ -948,7 +948,7 @@ static int virtballoon_probe(struct virtio_device *vdev) =20 if (!virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) vb->vb_dev_info.adjust_managed_page_count =3D true; -#ifdef CONFIG_BALLOON_COMPACTION +#ifdef CONFIG_BALLOON_MIGRATION vb->vb_dev_info.migratepage =3D virtballoon_migratepage; #endif if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { diff --git a/include/linux/balloon.h b/include/linux/balloon.h index 82585542300d6..ca5b15150f425 100644 --- a/include/linux/balloon.h +++ b/include/linux/balloon.h @@ -22,9 +22,9 @@ * * As the page isolation scanning step a compaction thread does is a lockl= ess * procedure (from a page standpoint), it might bring some racy situations= while - * performing balloon page compaction. In order to sort out these racy sce= narios - * and safely perform balloon's page compaction and migration we must, alw= ays, - * ensure following these simple rules: + * performing balloon page migration. In order to sort out these racy scen= arios + * and safely perform balloon's page migration we must, always, ensure fol= lowing + * these simple rules: * * i. Inflation/deflation must set/clear page->private under the * balloon_pages_lock @@ -45,10 +45,10 @@ =20 /* * Balloon device information descriptor. - * This struct is used to allow the common balloon compaction interface + * This struct is used to allow the common balloon page migration interface * procedures to find the proper balloon device holding memory pages they'= ll - * have to cope for page compaction / migration, as well as it serves the - * balloon driver as a page book-keeper for its registered balloon devices. + * have to cope for page migration, as well as it serves the balloon drive= r as + * a page book-keeper for its registered balloon devices. */ struct balloon_dev_info { unsigned long isolated_pages; /* # of isolated pages for migration */ diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 92f80b4d69a6d..fca34d3473b6b 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -125,9 +125,9 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, #ifdef CONFIG_MEMORY_BALLOON BALLOON_INFLATE, BALLOON_DEFLATE, -#ifdef CONFIG_BALLOON_COMPACTION +#ifdef CONFIG_BALLOON_MIGRATION BALLOON_MIGRATE, -#endif +#endif /* CONFIG_BALLOON_MIGRATION */ #endif #ifdef CONFIG_DEBUG_TLBFLUSH NR_TLB_REMOTE_FLUSH, /* cpu tried to flush others' tlbs */ diff --git a/mm/Kconfig b/mm/Kconfig index 0d13c1b36e1c1..460a148d5b71a 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -597,8 +597,8 @@ config MEMORY_BALLOON bool =20 # -# support for memory balloon compaction -config BALLOON_COMPACTION +# support for memory balloon page migration +config BALLOON_MIGRATION bool "Allow for balloon memory migration" default y depends on MIGRATION && MEMORY_BALLOON diff --git a/mm/balloon.c b/mm/balloon.c index 25e2a1e71eba9..834f86c3c116d 100644 --- a/mm/balloon.c +++ b/mm/balloon.c @@ -34,7 +34,7 @@ static void balloon_page_insert(struct balloon_dev_info *= balloon, { lockdep_assert_held(&balloon_pages_lock); __SetPageOffline(page); - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) { + if (IS_ENABLED(CONFIG_BALLOON_MIGRATION)) { SetPageMovableOps(page); set_page_private(page, (unsigned long)balloon); } @@ -51,7 +51,7 @@ static void balloon_page_insert(struct balloon_dev_info *= balloon, static void balloon_page_finalize(struct page *page) { lockdep_assert_held(&balloon_pages_lock); - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) + if (IS_ENABLED(CONFIG_BALLOON_MIGRATION)) set_page_private(page, 0); /* PageOffline is sticky until the page is freed to the buddy. */ } @@ -153,7 +153,7 @@ struct page *balloon_page_alloc(void) { gfp_t gfp_flags =3D __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN; =20 - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) + if (IS_ENABLED(CONFIG_BALLOON_MIGRATION)) gfp_flags |=3D GFP_HIGHUSER_MOVABLE; else gfp_flags |=3D GFP_HIGHUSER; @@ -232,7 +232,7 @@ struct page *balloon_page_dequeue(struct balloon_dev_in= fo *b_dev_info) } EXPORT_SYMBOL_GPL(balloon_page_dequeue); =20 -#ifdef CONFIG_BALLOON_COMPACTION +#ifdef CONFIG_BALLOON_MIGRATION =20 static bool balloon_page_isolate(struct page *page, isolate_mode_t mode) =20 @@ -342,4 +342,4 @@ static int __init balloon_init(void) } core_initcall(balloon_init); =20 -#endif /* CONFIG_BALLOON_COMPACTION */ +#endif /* CONFIG_BALLOON_MIGRATION */ diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 389989a28abe0..bc805029da517 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -946,8 +946,8 @@ static struct zone *default_kernel_zone_for_pfn(int nid= , unsigned long start_pfn * We rely on "present pages" instead of "managed pages", as the latter is * highly unreliable and dynamic in virtualized environments, and does not * consider boot time allocations. For example, memory ballooning adjusts = the - * managed pages when inflating/deflating the balloon, and balloon compact= ion - * can even migrate inflated pages between zones. + * managed pages when inflating/deflating the balloon, and balloon page + * migration can even migrate inflated pages between zones. * * Using "present pages" is better but some things to keep in mind are: * diff --git a/mm/migrate.c b/mm/migrate.c index 4750a2ba15fef..1bf2cf8c44dd4 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -88,7 +88,7 @@ static const struct movable_operations *page_movable_ops(= struct page *page) * back to the buddy. */ if (PageOffline(page)) - /* Only balloon compaction sets PageOffline pages movable. */ + /* Only balloon page migration sets PageOffline pages movable. */ return offline_movable_ops; if (PageZsmalloc(page)) return zsmalloc_movable_ops; diff --git a/mm/vmstat.c b/mm/vmstat.c index 6ae8891c9693e..e96a344ab5974 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1422,9 +1422,9 @@ const char * const vmstat_text[] =3D { #ifdef CONFIG_MEMORY_BALLOON [I(BALLOON_INFLATE)] =3D "balloon_inflate", [I(BALLOON_DEFLATE)] =3D "balloon_deflate", -#ifdef CONFIG_BALLOON_COMPACTION +#ifdef CONFIG_BALLOON_MIGRATION [I(BALLOON_MIGRATE)] =3D "balloon_migrate", -#endif +#endif /* CONFIG_BALLOON_MIGRATION */ #endif /* CONFIG_MEMORY_BALLOON */ #ifdef CONFIG_DEBUG_TLBFLUSH [I(NR_TLB_REMOTE_FLUSH)] =3D "nr_tlb_remote_flush", --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B22223D7CE; Mon, 19 Jan 2026 23:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863862; cv=none; b=QhrCNGTa0MjF2lBY3IV/wvUstWm+L5nvG9lrN77hc2xp1v2zI0so9oLSYHIxatcv5WVdHyIkwLyWxRRBHEDwD3Cc1WFZyWS5n5iS/srSFvSxIwyXyFyFGTIaX9hShtQUohc3fmdMZ7TmWBDGLOWpRvFvxABINQFathYb4tE9WyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863862; c=relaxed/simple; bh=bBab6NBDRM1JzpiE2e7pM9KwdFDytuAM5t2vCrPDoaw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=olVIzjAxiTOJgel4W2sHDeAYQfJj4rAVTOJnbDPUjpH9sM4NYjlfS2KaQyiYRk4VrYJ9l18TdVyWmFmFpCTRLNy9OYem8rdsBUmwd48KRzWzOS+WTkERRk8WxWykIsODmeFH+1lg/nPI/gF/egWVJ/5dhzmbZ1djdfCi+3iq0no= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gur98Nh0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Gur98Nh0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C54FC116C6; Mon, 19 Jan 2026 23:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863861; bh=bBab6NBDRM1JzpiE2e7pM9KwdFDytuAM5t2vCrPDoaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gur98Nh0ZRVpYfJcb6gHUUpn6bxCBetvsDOZtfvPoVcwEo8KJ5clVB54eAiPH/Iai heYJBC6atNIA0y1z7PIzaecoSG2s3xEJzDZhMXVrPIqwRl9NKhfXGO5qyek6NOd4uG DUN0ewf2L0U6Rl3E9Nsx1uLhmL6eMgG5sNvexfLMmHYNMM8aV4XigKa1MpIyPfbGLI GlnWYx+NZnQXcxFVmFUqx5dXbO37NlrV5zRYL3FQ2HVuEwNv+jR5y1Dy3TcE7HF1vu MznI38e3Yz0CTVvnDhPa0UHMuVJr+pjhB8XC+kBMS2/qDZKl290mgjcKyNJCzh5URn RSFOLhHJE/ssw== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 23/24] mm: rename CONFIG_MEMORY_BALLOON -> CONFIG_BALLOON Date: Tue, 20 Jan 2026 00:01:31 +0100 Message-ID: <20260119230133.3551867-24-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's make it consistent with the naming of the files but also with the naming of CONFIG_BALLOON_MIGRATION. While at it, add a "/* CONFIG_BALLOON */". Reviewed-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand (Red Hat) --- arch/powerpc/platforms/pseries/Kconfig | 2 +- drivers/misc/Kconfig | 2 +- drivers/virtio/Kconfig | 2 +- include/linux/vm_event_item.h | 4 ++-- mm/Kconfig | 4 ++-- mm/Makefile | 2 +- mm/vmstat.c | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platform= s/pseries/Kconfig index 3e042218d6cd8..f7052b131a4c5 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig @@ -120,7 +120,7 @@ config PPC_SMLPAR config CMM tristate "Collaborative memory management" depends on PPC_SMLPAR - select MEMORY_BALLOON + select BALLOON default y help Select this option, if you want to enable the kernel interface diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index d7d41b054b982..5cc79d1517af5 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -410,7 +410,7 @@ config DS1682 config VMWARE_BALLOON tristate "VMware Balloon Driver" depends on VMWARE_VMCI && X86 && HYPERVISOR_GUEST - select MEMORY_BALLOON + select BALLOON help This is VMware physical memory management driver which acts like a "balloon" that can be inflated to reclaim physical pages diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig index 6db5235a7693d..ce5bc0d9ea287 100644 --- a/drivers/virtio/Kconfig +++ b/drivers/virtio/Kconfig @@ -112,7 +112,7 @@ config VIRTIO_PMEM config VIRTIO_BALLOON tristate "Virtio balloon driver" depends on VIRTIO - select MEMORY_BALLOON + select BALLOON select PAGE_REPORTING help This driver supports increasing and decreasing the amount diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index fca34d3473b6b..22a139f82d75f 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -122,13 +122,13 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, THP_SWPOUT, THP_SWPOUT_FALLBACK, #endif -#ifdef CONFIG_MEMORY_BALLOON +#ifdef CONFIG_BALLOON BALLOON_INFLATE, BALLOON_DEFLATE, #ifdef CONFIG_BALLOON_MIGRATION BALLOON_MIGRATE, #endif /* CONFIG_BALLOON_MIGRATION */ -#endif +#endif /* CONFIG_BALLOON */ #ifdef CONFIG_DEBUG_TLBFLUSH NR_TLB_REMOTE_FLUSH, /* cpu tried to flush others' tlbs */ NR_TLB_REMOTE_FLUSH_RECEIVED,/* cpu received ipi for flush */ diff --git a/mm/Kconfig b/mm/Kconfig index 460a148d5b71a..8e23af521605e 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -593,7 +593,7 @@ config SPLIT_PMD_PTLOCKS =20 # # support for memory balloon -config MEMORY_BALLOON +config BALLOON bool =20 # @@ -601,7 +601,7 @@ config MEMORY_BALLOON config BALLOON_MIGRATION bool "Allow for balloon memory migration" default y - depends on MIGRATION && MEMORY_BALLOON + depends on MIGRATION && BALLOON help Allow for migration of pages inflated in a memory balloon such that they can be allocated from memory areas only available for movable diff --git a/mm/Makefile b/mm/Makefile index 1e31e0a528dc1..0d85b10dbdde4 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -122,7 +122,7 @@ obj-$(CONFIG_CMA) +=3D cma.o obj-$(CONFIG_NUMA) +=3D numa.o obj-$(CONFIG_NUMA_MEMBLKS) +=3D numa_memblks.o obj-$(CONFIG_NUMA_EMU) +=3D numa_emulation.o -obj-$(CONFIG_MEMORY_BALLOON) +=3D balloon.o +obj-$(CONFIG_BALLOON) +=3D balloon.o obj-$(CONFIG_PAGE_EXTENSION) +=3D page_ext.o obj-$(CONFIG_PAGE_TABLE_CHECK) +=3D page_table_check.o obj-$(CONFIG_CMA_DEBUGFS) +=3D cma_debug.o diff --git a/mm/vmstat.c b/mm/vmstat.c index e96a344ab5974..0f64c898f79f8 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1419,13 +1419,13 @@ const char * const vmstat_text[] =3D { [I(THP_SWPOUT)] =3D "thp_swpout", [I(THP_SWPOUT_FALLBACK)] =3D "thp_swpout_fallback", #endif -#ifdef CONFIG_MEMORY_BALLOON +#ifdef CONFIG_BALLOON [I(BALLOON_INFLATE)] =3D "balloon_inflate", [I(BALLOON_DEFLATE)] =3D "balloon_deflate", #ifdef CONFIG_BALLOON_MIGRATION [I(BALLOON_MIGRATE)] =3D "balloon_migrate", #endif /* CONFIG_BALLOON_MIGRATION */ -#endif /* CONFIG_MEMORY_BALLOON */ +#endif /* CONFIG_BALLOON */ #ifdef CONFIG_DEBUG_TLBFLUSH [I(NR_TLB_REMOTE_FLUSH)] =3D "nr_tlb_remote_flush", [I(NR_TLB_REMOTE_FLUSH_RECEIVED)] =3D "nr_tlb_remote_flush_received", --=20 2.52.0 From nobody Sat Feb 7 20:39:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95AFF23D7CE; Mon, 19 Jan 2026 23:04:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863870; cv=none; b=mkX1YZxhNjtx4WMJ0beoA0wMpNsjhT1tMYhJFuh9m25ZQvuCigE0ebUnO/FCFXA+0C+KEKQJB7/QMm4eYria9FRLhGGvH6Dc/wupYu/BVa5ecNzyUUGZw/pJGUV7fgfdU+yYfxXt2xj1FEbvrWMDOnB6fsh29/5hVs/HMZkyM60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768863870; c=relaxed/simple; bh=S1lJXi3TslhD2DUEpYR7JuVS5MOqETlTcS4z0PNouhg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A47aj4oJj90oVWUQV97tSkEj4czaZ1spuH4SJjfMiaUo6H+o7/VMAdHCEZMmGJ+ssTqqPg7eOBeKSDQtu8IqzIiKBE80IIt8ovmbDGZ/3DJeIECXn5QFGHwdjfioBrv2EWiySyyEHqfk2zwiNQuE6c+j3/Aw9WjOBIGgExEXXBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JddkqrE6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JddkqrE6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A63EC116C6; Mon, 19 Jan 2026 23:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768863868; bh=S1lJXi3TslhD2DUEpYR7JuVS5MOqETlTcS4z0PNouhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JddkqrE6RvS1AkcsaP0vtdPHirYtI6v+ox8YHuFnXoHZ6NJfOnr3M+yynoay6gTTs 2CSXcn90icHiGYaNfQcjwZ5gBkXXRJdWMqLpgNOW25skxtZ0cVYbGJUW8kM68yJjsF xYxt39UFsY+/oOcthmFoy7p0q/3U5dWozuyWhB0B4IAEPbJwcOnI9Qv37JnTchNeIm zer4O9EWA4zNWmtWZucviW7z2hJBTJJSFMqW2pjllnEM9ZoJQDnaoN+5yVxeyv0iPU ley6W9IKnFUbeFASccnDtJvSJcW2dPCjakmFabdI4HFB4fknl1l42IDGOcMdpEVToz T00lzVZ1LJSCA== From: "David Hildenbrand (Red Hat)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Broadcom internal kernel review list , linux-doc@vger.kernel.org, virtualization@lists.linux.dev, "David Hildenbrand (Red Hat)" , Andrew Morton , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Arnd Bergmann , Greg Kroah-Hartman , Jerrin Shaji George , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Zi Yan Subject: [PATCH v3 24/24] MAINTAINERS: move memory balloon infrastructure to "MEMORY MANAGEMENT - BALLOON" Date: Tue, 20 Jan 2026 00:01:32 +0100 Message-ID: <20260119230133.3551867-25-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119230133.3551867-1-david@kernel.org> References: <20260119230133.3551867-1-david@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Nowadays, there is nothing virtio-balloon specific anymore about these files, the basic infrastructure is used by multiple memory balloon drivers. For now we'll route it through Andrew's tree, maybe in some future it makes sense to route this through a separate tree. Acked-by: Lorenzo Stoakes Acked-by: Vlastimil Babka Signed-off-by: David Hildenbrand (Red Hat) --- MAINTAINERS | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index de8f89ca1149f..11720728d92f2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16454,6 +16454,17 @@ T: quilt git://git.kernel.org/pub/scm/linux/kernel= /git/akpm/25-new F: mm/ F: tools/mm/ =20 +MEMORY MANAGEMENT - BALLOON +M: Andrew Morton +M: David Hildenbrand +L: linux-mm@kvack.org +L: virtualization@lists.linux.dev +S: Maintained +W: http://www.linux-mm.org +T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm +F: include/linux/balloon.h +F: mm/balloon.c + MEMORY MANAGEMENT - CORE M: Andrew Morton M: David Hildenbrand @@ -27536,9 +27547,7 @@ M: David Hildenbrand L: virtualization@lists.linux.dev S: Maintained F: drivers/virtio/virtio_balloon.c -F: include/linux/balloon.h F: include/uapi/linux/virtio_balloon.h -F: mm/balloon.c =20 VIRTIO BLOCK AND SCSI DRIVERS M: "Michael S. Tsirkin" --=20 2.52.0