From nobody Mon Feb 9 17:56:55 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 CB23433FE12; Thu, 15 Jan 2026 09:20:31 +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=1768468831; cv=none; b=NSuEbgnlSCpUw2b2Qb4NGwm/LZl1kjGjGBmAY5i36CIaASv0iXGXwXh5brQsi2NMDhhcwZfZjyiiPM7Got/dBbqVDGZJZxyKFyDbQ7tOk+5PqHcSShGbk1aT89yQj48fvL6zY7fzMTuxL63Sylpspve4o5bDF7JHO9GklM0T4Tw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468831; c=relaxed/simple; bh=Scv31UliB8apDlHu70nbhgpokthEcnnhLLec4iJu0Qg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X2FhSbPFDfE62E9kRVsrFNO+62UmAZh8cQV7w2irNLQVqQVoVpjQoiaSkI0y9pHb2jsYtLmY4dvXRjOALSoJAJA3yHovpzZ8GX7dPtvemEY9UsxdDtT0gKrpvwnnX/5F6K6uCz7vOXiD5WvZ+Hs9/ySV02VCFy2z3T5mFLc3F6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EYttf9RS; 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="EYttf9RS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04E4AC116D0; Thu, 15 Jan 2026 09:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468831; bh=Scv31UliB8apDlHu70nbhgpokthEcnnhLLec4iJu0Qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EYttf9RSd3DbdTaPTVk+zCGJKvc/Oez8ig0lU53ia9jJ6aGdraYIQwgrN8yJDx0Pr 5qlJKitoIajMNIWc7kDHGqVMM0UaKRvQAC7bbk7mgQkugqLRCBR8BUyRmOqRFH2N7Y EJ2au93bd/o+ApHVyv0ol6BDQCWpCFNv1hC3BOgoWcmnv7HvfTvufkfjUo08S6jWy3 5opLIIVpz8SqHZkxP47qBlAAYzOLBQ5lRLzyIQQhvTJHLC1jIMu6+wxgilo4nYr7cJ DeabCkk2c8fFv90mHyJ5RnYg2v4W7YzhuhYwVVVE1jXv557Xjjd9lvqckiUc5tazSb PsIdQFPAUZZCA== 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 v2 01/23] vmw_balloon: adjust BALLOON_DEFLATE when deflating while migrating Date: Thu, 15 Jan 2026 10:19:51 +0100 Message-ID: <20260115092015.3928975-2-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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 Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 5CB80194C96; Thu, 15 Jan 2026 09:20:39 +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=1768468839; cv=none; b=mTkRZYmTBNQpr8mtMTAU7k+P+l6v0ubvPb+XSL7rT+0+crAV9vZHkBPWJchaBUm9yVgfawQIPDQtUm3s1btM52XYSdoI4aoaVPw3e4y0LoeUa8n6mcX2RXbCw1cbZ33KUwFsaImx489K21iG0KUrheYrNkV6prfYTA9f7VGHdbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468839; c=relaxed/simple; bh=Cgrtz1QRoaELES+PU4SN1wm9f3oPVqbLP/yVshCylTQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uaNZF81fmDdBNQ4US3o40Z8p6kLiNSYqgRiX8pWJpLur7pRJymxZ9zDAfAgpbtBley1Yo3aSkb0ffuk4aELGxfmKJp5ThnXAdcDgYkQ8cOInKw1zH5TChzwBY6okFGveMEBIwmYqQxOO+0OloaUqz8bUge+ZvYfTLzQ3fc4DMGc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AsKfcaRm; 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="AsKfcaRm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14E52C116D0; Thu, 15 Jan 2026 09:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468838; bh=Cgrtz1QRoaELES+PU4SN1wm9f3oPVqbLP/yVshCylTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AsKfcaRmJZR6QBoU2B6nA9WMeBDA1v0qFPTd0qrx03mzDkR5Nrbczuc/sWxeXRHPh lq/FejhHEwMDemtiEzRaYK4TIBbMeGt4lXFbXhrUoYJsK8G6EEcTPcwzPMi+pFTb4h F5+Rbu6bfB7cE3xBuYoT7INyzSbIiUHSlgPZwn8SetNoCS3XFXiPppFn/TGtmh+Qw6 Z6Iqq4cTql/fEOx82g1l+T+EDPub/eL5mnJL7Xs8eIjUVNdfPIstSZHPehcNI4ppAo xcD8CZAfM7SEpMPAqxuRjP5ye4s3qDPmZ0Mzbyf955aFmneF9aDg0oTAVP0NWDlgVu 05tHWJAZpuPjw== 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 v2 02/23] vmw_balloon: remove vmballoon_compaction_init() Date: Thu, 15 Jan 2026 10:19:52 +0100 Message-ID: <20260115092015.3928975-3-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 2C79F2D6E70; Thu, 15 Jan 2026 09:20:45 +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=1768468846; cv=none; b=GJtMBOnorzyxhL5ByBz8l/WoD3K07wjnI/pg7zIU0AnfRSb3bte67ut/NqbutGmpsj+ip/cMfohrucdPa6NIWYvdA6jp0eg0pgVSUoYhkQcWwuATFYhq39yhCAM5hUzxTXWR0bDNKybVoY9svLW9DVrLXGH5wUVfe4Hl1eG/lKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468846; c=relaxed/simple; bh=9n8n+0cAzQ7vmJcEe9QB+II3uYJrH/Btd/75YDVJ8Ps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uq2I29takOgA3wmeKAWPexlAmcAHaPF+NMx6UmOh3LaIYkFHo35EtYmMWll5H3sE4Mz5OpmOI0q6tvILbr0xpoG3Vo+26YftYTVuhctaAR1TS+j9fzVCq15s1wrWkfbjUnJF4Nao3eeG7FrABxLC/cI2LNaALPGZYsJpGPOggXQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j/0/kout; 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="j/0/kout" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D5EFC19421; Thu, 15 Jan 2026 09:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468845; bh=9n8n+0cAzQ7vmJcEe9QB+II3uYJrH/Btd/75YDVJ8Ps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j/0/koutXAAcP4I/4wro7W2QSvhddotARmsvMnQOx/nzQIh10ziCaQHXsjHoEOaqy 9bStFDwBLQn+lyP7xAZl3tkeGlvdb/CfyfjgsPqyrFtIrPmMOjYEHCV/23vKdM3v2d KF9izQF9jAfa8ikcz+ZVZRrh9C7c/EFrXqAd6cLHHb5isfFKFyvkvam/DWsGPYByUh d0nFia07jUa+e8BhXn+l+bfo0gQ+g7UMpuOJuMajOPz0SU7EAuzCbp9zimxyEJBCZM ozDNgFuo4hwg9rU0B01n59OPHAlC1mgdXGgF//ZcI32EaaNtkCdbeEaFLywkokzOQ1 oC1dqiHkWvLzg== 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 v2 03/23] powerpc/pseries/cmm: remove cmm_balloon_compaction_init() Date: Thu, 15 Jan 2026 10:19:53 +0100 Message-ID: <20260115092015.3928975-4-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 CFC9C35B122; Thu, 15 Jan 2026 09:20:52 +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=1768468852; cv=none; b=sbd+VKm8mqC+lpn2tjhsd2pYUidNCqgVr+ta6R/r6EvU81T6cTZ+XI59xUlg27TzzLKnhOMNTDfISiDWQM6kraOsk1i4T5YcOw0cCHda+aV8EJUdas1ci2RcESpjxBF5t0XuZ9i9dd5j9eOhFr/RWulD4WsMKwI/ghqhKuFf5m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468852; c=relaxed/simple; bh=w4KcHLR+BH8XcJwxxcNytMND/0cbiSTTskBUX/GwE2M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VyroBkw6LSllfLaxrZeW5C0K7L3gm7GM/Epet/nverEjCLGKu5Jchpt57ysbLZGhJ20ZdfzyYAKvLIMSL1RkWTpgl+J18X/6bDIayBVBVwXk93MlPCvH4jl5jBn2hkCMBLy81SgUSxYNC9QdCbk46Ae1Js9ZpIC5bzX45c6pVQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mr92APs5; 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="mr92APs5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36A1CC116D0; Thu, 15 Jan 2026 09:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468852; bh=w4KcHLR+BH8XcJwxxcNytMND/0cbiSTTskBUX/GwE2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mr92APs5Utiee9xvMBLboUUTDgM0ap0b5FPXynhnef271Ip7h1Y0U7ViG/f/yERpz grC7h7iFLv7vSBxlDgzUvpHtw4xj/FB8+Q2m0ytRi9uVgqtrEtfCKxSnrLukHF9Gh8 LY7hCQRU+XGBRFqvQ7x4opgkMp+KEWTpBWnZx+xcsns1RavhWR5feNPh6OmKfNALn/ vhqH7OGIpuNY18FGFgnDnPHMAilbZSoxLfAvZ+stEdCBuXqIE4+mUF1ulfKBea8RBA hklYllWA2Hibwj7VZ7fctrerV/2Ula+CedMaEvanTiCpeXX1yf5iXU28VO4TRw+16w AEFeqZbVyZYvg== 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 v2 04/23] mm/balloon_compaction: centralize basic page migration handling Date: Thu, 15 Jan 2026 10:19:54 +0100 Message-ID: <20260115092015.3928975-5-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin --- arch/powerpc/platforms/pseries/cmm.c | 16 --------- drivers/misc/vmw_balloon.c | 49 +++++----------------------- drivers/virtio/virtio_balloon.c | 12 ------- mm/balloon_compaction.c | 37 ++++++++++++++++++--- 4 files changed, 41 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 03c5dbabb1565..5444c61bb9e76 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -232,20 +232,49 @@ 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); =20 /* Isolated balloon pages cannot get deflated. */ - 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); + switch (rc) { + case 0: + spin_lock_irqsave(&b_dev_info->pages_lock, flags); + + /* Insert the new page into the balloon list. */ + get_page(newpage); + + balloon_page_insert(b_dev_info, newpage); + __count_vm_event(BALLOON_MIGRATE); + break; + case -ENOENT: + spin_lock_irqsave(&b_dev_info->pages_lock, flags); + + /* Old page was deflated but new page not inflated. */ + __count_vm_event(BALLOON_DEFLATE); + break; + default: + return rc; + } + + 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 Mon Feb 9 17:56:55 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 988C033ADA4; Thu, 15 Jan 2026 09:20:59 +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=1768468859; cv=none; b=oQ8WcmO6u2Tf+IwgGe4bBLuwcEyw8UcY++h3l9cqDNj8JgSYJW1LS4J6BCFgpYpYRCbRlBBbOmUCefHaA6twwQ6gz0JfHAdH3jAXWOava7HELOd7W1jGTSbFHSHQpWPx0VdHBJAkq1mdFfaiX2kgplBDArJKBnF9WK9zUhop1kw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468859; c=relaxed/simple; bh=PdUVHGvcMA44CGxVHVjOza1O8qvsgkQWnlz3sIbCXJQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kP4cIEoHB82uIDrX0k9sJaaR8gmpH0MerKPrt42YFGLY2m4/aG6FRU12T5QIBfWiPlEQCIJaizjx4EIOgywFcl1onBI2MSkN6DfWITFs48dLE1lEIc1VXZdEf40rFxnd8zvDsec1eL11n7nGQuh3x5bKQZPiSVicAGs5rjfdLjk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I1aAQlLm; 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="I1aAQlLm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1D11C116D0; Thu, 15 Jan 2026 09:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468859; bh=PdUVHGvcMA44CGxVHVjOza1O8qvsgkQWnlz3sIbCXJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I1aAQlLmB/ddxTS02O6Gwqsds4e8W1dDtCAZnlVEjjhGUUq13GDM6gkcThI2QiTIe amYV85wji7q92wT3tPLWAVUEcSogqSP+TM4kqclevUbrl9JWbNJIOVXizaC3thUlK5 4PFst91uf4/dkWf5oCwkYsG1iV3uaVgTschseOzIggRXL323yssIpdgC6d6NDB4uhB LtXwa5ea+hjPPWx0OPiN7RisqrtDWY0bTLG+3l6NJgeYg3yc1hSiQ3T4bxOEMTOlwr F86Mwn/tnC4ZW6jTH4SeC9PGfkKhAmifRTlFsjzixJHg+WNlzKiY5CVzVlmClWSIRy zbKBzuwVjnYJA== 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 v2 05/23] mm/balloon_compaction: centralize adjust_managed_page_count() handling Date: Thu, 15 Jan 2026 10:19:55 +0100 Message-ID: <20260115092015.3928975-6-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Liam R. Howlett Acked-by: Michael S. Tsirkin --- 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 5444c61bb9e76..fd9ec47cf4670 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); @@ -256,12 +260,25 @@ static int balloon_page_migrate(struct page *newpage,= struct page *page, =20 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); + } break; case -ENOENT: spin_lock_irqsave(&b_dev_info->pages_lock, flags); =20 /* 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); break; default: return rc; --=20 2.52.0 From nobody Mon Feb 9 17:56:55 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 6F7EC333452; Thu, 15 Jan 2026 09:21:06 +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=1768468866; cv=none; b=foRWnEgS1F3M8RCc8kQqmOs89xJuuWvyTlErdfMoqVkOLXfQUCOhdfFzSoBeqypDF4rtZjJg3e0qkTsSNxm0TSIUlwbyeh9q7maVXDkQE1tcNsbyveKmAQ2DWuQAB/7KupSAPCUe6+Vtx7KpX6wpadko7d3QVO9+dTj/bgBubMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468866; c=relaxed/simple; bh=q+Q0Uz5/ogC154Dbd2goOOehqbQ7Ij08x/c47bAW3yk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W3kFcaUPrcrNmsaFNFNUg8tnqdkfr2H+VRXkyBQGljQ3pg0f90cZJJrsbT503vbHMxrUxsLR0piW87qIkXu6aLT88SpQviKR6NhSL+O8A35qG9wtrfiTHfxjGOB3mnt043XTwAnxF6x6o21Cptdwus1g7syhH0DmxLFlsEVYRMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YXLQM63O; 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="YXLQM63O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD927C116D0; Thu, 15 Jan 2026 09:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468866; bh=q+Q0Uz5/ogC154Dbd2goOOehqbQ7Ij08x/c47bAW3yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YXLQM63OvUIAXjYM+1gJ3tSen1quB36s7/mPz09KWLc8uyMyUjvkG+5++fUqmVxEC Ykn9RLJBfr+XLAQCzsxuqPR3iFk2NH5/VUlGWjrSQvbN6yRv6MdW+RPqgfBGTpbb7s yNUtgwNE0o8ISZJVBv0oWmfNnm2mXPLKwkfb9gfxKlvygbG7+Qgtuzt2sunaQRDlew /SjsLbp9llx3T5l3KcqqQxexGe+DtC/i7Rli1miNq1yQYMRLazApEy59dXNa41Y9aj sEY7jrlMhmyPaOGOgRBrG9ePy1z2tZsMKrJJKpCEre3nCdobOpHUefVnVn5mBk6HET ZAoNRBLwYG8TA== 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 v2 06/23] vmw_balloon: stop using the balloon_dev_info lock Date: Thu, 15 Jan 2026 10:19:56 +0100 Message-ID: <20260115092015.3928975-7-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. 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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 2BCD233FE12; Thu, 15 Jan 2026 09:21:12 +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=1768468873; cv=none; b=VhcL2tEY4KrtEv/U2AZcYzkCOJa7870E3EsjxDTeSS9QZLoDUOg9j5XNPy/8HGJd5YMgmeghCruosv37AxIpFLAhMmvtyjMw2dJE0PrWeKMXhvESt7VDr8Ps7+j0jEEMq5Y9zA0pUdGvv1IjvJ5N6F6ime4fKiGjgOQsDCO6iOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468873; c=relaxed/simple; bh=8ti3mJv0LiaEwwkTaTPC1cxyUqgx/Jz/5UzObtQLdtc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hasLld17Ih11Sd2u5mDfwwhBgQdOjP11dPNgwCNFI+wkNU9JuAIut6CxaqIwFFwqFbcCQkyJwoiP2mROlSHHlEwYYZL7lwTHGtGEDNN1BYx92jjTjh+R/OQABlWjabJcihF+BAA0VHgGfnASR2SMe3Z0o3sADeCesg7AUb0ReOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b74dktIU; 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="b74dktIU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9128BC19423; Thu, 15 Jan 2026 09:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468872; bh=8ti3mJv0LiaEwwkTaTPC1cxyUqgx/Jz/5UzObtQLdtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b74dktIU4BKKrC0Pn+Xqur68BVJP6BlafX0QNU8fZyTeKal5T7//ku1ZsvPcnRecR 6z1KsyRRJH42o2DkcOh5L5OZWNV1+pCFr8qq2LqFiaBLirtqHNnMarZiANcxgxldSv yiUMRTtzpnR8vXxomAGxYsAaxmOUkdT3Dd5bxyhJyoi+gnGclqyvlrg5/74DfoMcY+ +svVNN1YJpBTbggGX0OnEStoIXVPQS+pHiIIa6YNnPkhCJC/Dc64SCW8WC5QVRJgkR suL+zMFePEWvulaXtgcbZl6FZOClfVeoGduF0bnLMGCZiKOW68KSf/Y3TKq5c+nqa1 /72QY6YlMNeEA== 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 v2 07/23] mm/balloon_compaction: use a device-independent balloon (list) lock Date: Thu, 15 Jan 2026 10:19:57 +0100 Message-ID: <20260115092015.3928975-8-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin --- include/linux/balloon_compaction.h | 6 ++--- mm/balloon_compaction.c | 36 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 19 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 fd9ec47cf4670..97e838795354d 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; } @@ -230,10 +236,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, @@ -253,7 +259,7 @@ static int balloon_page_migrate(struct page *newpage, s= truct page *page, rc =3D b_dev_info->migratepage(b_dev_info, newpage, page, mode); switch (rc) { case 0: - spin_lock_irqsave(&b_dev_info->pages_lock, flags); + spin_lock_irqsave(&balloon_pages_lock, flags); =20 /* Insert the new page into the balloon list. */ get_page(newpage); @@ -272,7 +278,7 @@ static int balloon_page_migrate(struct page *newpage, s= truct page *page, } break; case -ENOENT: - spin_lock_irqsave(&b_dev_info->pages_lock, flags); + spin_lock_irqsave(&balloon_pages_lock, flags); =20 /* Old page was deflated but new page not inflated. */ __count_vm_event(BALLOON_DEFLATE); @@ -285,7 +291,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 Mon Feb 9 17:56:55 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 02B2D3358AD; Thu, 15 Jan 2026 09:21: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=1768468880; cv=none; b=mYRHhOrmH+B8j7+Dhi79PNeFUz8rW2kMtZjnmDsoGPPLaUGjw4meUoWbqOgKOLeQ6fivR97QgbpJMg5IAFa6FI0leIxO2XYCdcEkF202MNzOVGmmoPa70hUin2HnyqHiPTCF2egiaxgHn95HhNsaOa25f0D2YTfvzV8jbWx/beg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468880; c=relaxed/simple; bh=veUhuhby/6KA1wTGAfzOWG6HhKwBm4jTGxQAtB2JN04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q53jngnFIQHfzQkRTdtEVGFUS1ChhSQrZbVdfBF4kYK1flebJZtT93lyK8svfahtywJdAQCUjdhjAfXLmE7rBXDEmCwRIdZDyxP7cTdGVy0u7al9m4byt1l/emYbE5bAOXIhZE+I3JSDO4Kl+jSo8vsEhgNXY2fx7UPjvVYMnsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y80rnCdR; 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="Y80rnCdR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38841C19424; Thu, 15 Jan 2026 09:21:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468879; bh=veUhuhby/6KA1wTGAfzOWG6HhKwBm4jTGxQAtB2JN04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y80rnCdR8i6QTBR4X0ercdmfP5fWPB/ngV2MfzPjAt7B4m60e7IbTK3/Ma6HEAuq+ QUt/zdaQlg8x9WbmdCyE1sH3CDUE0uvYEcknpWrgTAZozhHGsoLJPDpb7oJPVDvNYm cTSTxYTkjE5k+V5e4y/uZBGp+CjbFhs2BoZrQGsyMt0JRiwN3JYXaAgGRy9AbkpsRO fvOg3qiwVop/b+rEqyMGRAQwYYQxQJ0C2j4H9vtBT0KX4WqgnY1Z3UUawCkbnIEm7d l6M4kuVPU6Qv2aD32llalJ8A6qICE4gMEFFcRL1cZWM2qAfD7F1hy9tMSg6ctz2fWC UFh+UyNyfdFkA== 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 v2 08/23] mm/balloon_compaction: remove dependency on page lock Date: Thu, 15 Jan 2026 10:19:58 +0100 Message-ID: <20260115092015.3928975-9-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin --- 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 97e838795354d..28ef0cb6b3bbc 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); @@ -249,9 +237,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); - /* Isolated balloon pages cannot get deflated. */ if (WARN_ON_ONCE(!b_dev_info)) return -EAGAIN; @@ -291,10 +276,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 Mon Feb 9 17:56:55 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 BD2C421771B; Thu, 15 Jan 2026 09:21: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=1768468888; cv=none; b=eRKj1CciGBQCE6CXrlsGsdKjBoWFl7Z8I+N8EI0+GNxNSlbiajzwcj6cq9ZQxIIUyhLzxBVnTEA+CHLojnZHTm09MM1EbEWgU3JHHWvj/pMxBQKwF5E6Qx+5uWfFiRNRhMH/yamjnWjre8jtO+qW44BL2XVB/SVDrt2ujbWr4Xg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468888; c=relaxed/simple; bh=41/pQYkps40P9BcPiu0aWSmWbv563rsgLU3lmcgFkvQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EQuX2CbyGHjRu4bGqQlA98XEZn9VBp6vAeGuZDqrfJK+kV42kqbnGiCli+/+vf2qZQo3eoiWw5EgkXSNutHYiLtjQIMOLzk8wNv5qFfjRHOzQBJjsR9X/w5bmSnTziZ5pJUjAzRdYnCc1ye1VtXXOF8JpVoeEBeJbBnDkaUILjI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rNcPPF+w; 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="rNcPPF+w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27829C116D0; Thu, 15 Jan 2026 09:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468886; bh=41/pQYkps40P9BcPiu0aWSmWbv563rsgLU3lmcgFkvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNcPPF+w00AAr53scL8jR18Q7fOodmmK2UlCZZsCOPQEG5dye1hFhrFWKaWMBcJsq HcvZireBCalmRO4S4nV/b3swFSKslwc+AyIpYszWZNzpBRDkKLrIM7Qe2hzywmeN9O Sswm7p6jhDQufIH2rpGOhnmmofd9rfW1tFqNoe9bTTmC+sA18UEjJXkGartnfR4SZU slgCMrFZ6F6p3/cLrbx6GaFoyd8wTmKak9rlPOTC5e8cYpYOALbBCDc2HP+SehECP7 EhSNzizFDkYAsy4RMNk/vLZyhmWm1w38i52nIJqG3Dm1ajv8iW2pK80Bt91m1Dc8It l+bdhGCDichyw== 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 v2 09/23] mm/balloon_compaction: make balloon_mops static Date: Thu, 15 Jan 2026 10:19:59 +0100 Message-ID: <20260115092015.3928975-10-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 28ef0cb6b3bbc..c44e0b62203cc 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -286,7 +286,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 Mon Feb 9 17:56:55 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 6387935BDCA; Thu, 15 Jan 2026 09:21: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=1768468893; cv=none; b=siFL9YbDiM5Cc306KYYNnRtZS7mV9M4wzolGJ9IlMDL86keyPE7pWEnbA6EnoQGliNeu3+i57MtckVXXpINXNOsD1z+gOB0ReJBeLkhxZx7GafYlKv4HXhv6EJYvWe39L1wT2fjC1bnvI9yA5UBfVBjNUZq3PwMw5Ouv78jI/pw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468893; c=relaxed/simple; bh=6msByTrRia9i6vND/vW1jweXAy1e72/r1CKD4n734CU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bNgA+eUb3PYn61a6qmgiyB3Thbps553EldA+btYzRVprf5KHc8BMXOYquwji+uxX2xry/BlaSks+oovzONvcYq1u4Zx9+8wVns9o6REv5NN1aiSZ/5G2Q9j6ua9DGvDN4sXbB5hF+S4WmKzlubyLoZFqcsmBj7CB7MEzqoFVRHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qu5cnsss; 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="qu5cnsss" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D840AC19421; Thu, 15 Jan 2026 09:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468893; bh=6msByTrRia9i6vND/vW1jweXAy1e72/r1CKD4n734CU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qu5cnsssHM0VOA2MGc8aTwkHs5DfKAxz8/KwFTSko1lI+ScylNG3t6KiXREGnGYG4 bbajnHy0fVOa5j3ek1JI70AVPeN+FZW+TEy1INoJw+F2pAFEGzIjvs7q8F0zIqdheB 5SIpjUgk5E9J67b6iBFVQmoZiYC+BeHVbM658tP0rwFlhllNOQDloLuGo7VYiWbeIk ORaDqAHDYEraa10Y7nrOVGW6wIKuRACCqbuew8ilXlfJ2fEj4fTQYD4OTtSs52Uagr 8ZwIkkfcpdPLwwkRUB5iFUqhulaWwTq3TRtoMlYOChCsWG1c1YUkGSDalb9T3rxaXa W4fHfh+JcLDbQ== 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 v2 10/23] mm/balloon_compaction: drop fs.h include from balloon_compaction.h Date: Thu, 15 Jan 2026 10:20:00 +0100 Message-ID: <20260115092015.3928975-11-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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". Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 776073358AD; Thu, 15 Jan 2026 09:21: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=1768468900; cv=none; b=IftVNkB13LhyIU46eicg9WfxSO0Si9SKJkafyUXDHyJixn9tky2PJDEgWzgjoxwydA6N7BjQCW4nHM34Ej3874IKq3B8ZoUUyRq0mZc9fJ7pMMx13GsosQYxlAYvzFVnGdIouC81uYdrsecOLL3900P6cRXiprCpzhFTOZKqlw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468900; c=relaxed/simple; bh=7Fok2QOLie23GL34zkS9ujQ08CnApW1sZfbHS9ad6qc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KqnumE11h2PWvL3A7Y+h+UFApqB4J+7ru3g7z52iKii2oX2ti11HrHoJAleSMaNhUWrD8X+SenYR15htW6hBk2N4YvNz0VZ4jGx811ePWMOR993nmMir825dC3WN1KcUw98j1aXaPKKmMGCZn+GUBb1DLAxJrnWSgdPuHsJ/y6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gjHo4SPq; 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="gjHo4SPq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84860C116D0; Thu, 15 Jan 2026 09:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468900; bh=7Fok2QOLie23GL34zkS9ujQ08CnApW1sZfbHS9ad6qc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gjHo4SPqXCwAV3VLQdXz/juLHBwZNkzTqrcYtbfYSxBaSvH+n5lb5GZqiD2ycVH9Q TO+0ZInpSdsqpUqW1vje/qktqMIJNqUZasZtMkmbImz/v+3qyrOUvBLbYel/59dZDx CHaY+HvEtsPTc6G7ult2MmEWMmgpWMOvgO+sq9j3mSWbmchbR6+3m1WPyJdO/H1dDr xyP5tNDrUHa5hiq/htOY6d+se+LFPUr2DuRQUibb7RzdR+pFQ8MEF7mIJgiyIz7du9 PJ3LVFh7wFYG3SEZEOBq/kYev6Zmqjg9nRgcroBBwNzHwezu+BBiIaey87TRFW5RDP ahbnv9gDliQ9A== 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 v2 11/23] drivers/virtio/virtio_balloon: stop using balloon_page_push/pop() Date: Thu, 15 Jan 2026 10:20:01 +0100 Message-ID: <20260115092015.3928975-12-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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(). Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 014342D6E70; Thu, 15 Jan 2026 09:21:46 +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=1768468907; cv=none; b=FB0WK3Qrs+HiBkHhYb4mPl/FP4Cehc2432mniOOG6VFmmflGRFv0n7p1V2anQpLQ/+qutJTasEPdW2z0gVeWYCkanCk21si5gj15FoTvxIiNnOF/Kbvzh4lP0B/93K4Vx7SbnkC4BC7bgWEKQoho2xmNU0uOvd3JuQLPAp2qyZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468907; c=relaxed/simple; bh=QfJODb3fLD5hI0yqpV8bPffFJbeeNR9z0J/ex3110GQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MEiYaL6wvPaTKvaCRogOJrbXPD8UW1n50pZ0bqfbBhmxGYkiHCLYENUCJ2qTnFnKtd5uofjKw40dD1HVIiefKnwgCkDRNtfUSHBbmsa05jUbPsqhLsIiAQjfUsFxj2C1cpqjkk5Xu1zOmyMp3uaNrZvR42SSl2RWOYcPhIg6l0s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OFYSnzrR; 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="OFYSnzrR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A3F7C116D0; Thu, 15 Jan 2026 09:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468906; bh=QfJODb3fLD5hI0yqpV8bPffFJbeeNR9z0J/ex3110GQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OFYSnzrRIk8CUweoFvnALc8UkccAxZt/i3iCriyBA+I/zJLMeME8Mp2WVUoiICN3b CBVMgtFX/1kPf6qCUSX8OuUmfeDlgSrLnIZMdi1GXhai8maIA8s0xRP63jmbrO9BkO 2arju4rT7IQiibRnpqgIe+UbVDQRnOx3QuBgrDXkDgnbUIey/MD/gCgq1h9VbyOCmg BMg15H/nhYtfsbk8SCZQSruMTcFGWI/6EcjjsDuezMPHOdQ9Mv/NfXCh0wJGwx2Cmn MsAxSB0BlH4irDhYEedCtspCpCYR72b65QBxumJxnErOBx0dBYbhsHJdwr4/+xuw1e TFQdfFS4JjoLQ== 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 v2 12/23] mm/balloon_compaction: remove balloon_page_push/pop() Date: Thu, 15 Jan 2026 10:20:02 +0100 Message-ID: <20260115092015.3928975-13-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 c44e0b62203cc..90b2d61a593b7 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 Mon Feb 9 17:56:55 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 9C51B3358CA; Thu, 15 Jan 2026 09:21:53 +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=1768468913; cv=none; b=l407bT4HKIHvRfaPZihXur53A3h6F9z3vbuT2ZuQvjrPWKOa+t1DvkcRtuJPvlVIxwF8qQOrKGDL47lWDbS97j31snIshvE3DiysxGwuITpJ1POp94BJ7PP9W4MEAxEORSMTQ/W8ZUULKY7bLuXoTe5jnQxYVOkRwVWui1eoLSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468913; c=relaxed/simple; bh=plBsJJDsOVKU21GBNZQ0Y8RZZjUVLRU39NQAtNsDJJk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PFsct9xzgxB2HYPQ8wB5wgV69dyZvjWO0ktIWs9NeNM4yoB2SYm/u1RocPIOUYSV8TXLpLBdiPhrnyl3z4B70WEKb1Qn+GaLnso+mLd2C3/Za3Tc5QP/jrd98JzxmTNjzQu2GI0HRGJfHE+PPBxifa9Wix620X2KbPyiGyYtFvY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hRoEkz+a; 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="hRoEkz+a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4188CC116D0; Thu, 15 Jan 2026 09:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468913; bh=plBsJJDsOVKU21GBNZQ0Y8RZZjUVLRU39NQAtNsDJJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hRoEkz+axwnx4uvOCDJzNCaEEpypD+Or2qirVm812qm0RODJPsAre4QcDoHRFY5vA VvzJNNVDMVeOZ6M0jX2zENDqjSJgKmq3oifv1Lk3etoFnUduMtCuUDCWdad/m0rnth UnuLcfh3utfedo46BP5h6OyQngyqEhhAbE2Klhz/a95rbb9AT3GYON8iv7QnS6qRu4 G+T4YFdkhIO2gvjUSbyHvhwkF4qJtcMlxNTDtkxSYXkZAcUrkfDBJFnNlGgn4/p/ar 9SlBNZXOdFDnUFDs+pp4AAM2r7MeE4fv/JvsPM8gm+cbiSWlt4pF5pLkt0vvE04HUX IuUAF6cCw2KaQ== 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 v2 13/23] mm/balloon_compaction: fold balloon_mapping_gfp_mask() into balloon_page_alloc() Date: Thu, 15 Jan 2026 10:20:03 +0100 Message-ID: <20260115092015.3928975-14-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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(). Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 90b2d61a593b7..709c57c00b481 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 Mon Feb 9 17:56:55 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 9F67A33E36B; Thu, 15 Jan 2026 09:22:00 +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=1768468920; cv=none; b=QgsSYxV8/foLEhS3oICqzSz8lUoOJBROS85xQx4Zjp0uZxNJcbagt9yOp9QbOzOyzB+k12mvuz6Vj7R2XqnaqVs7lQA0xmWU4/bro5yg16LDTz+uAWCfxwdDes+K1j/EycKngqxJR5BXTdVTj3bHvxS4NcJVeeLxkQhn6s33EC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468920; c=relaxed/simple; bh=qmPDA1ZKr0A977KNkEekwqrp6nf+Yo9xCkHHCXnhQZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fwz2WH55tz//6YLQBZXxsExqK4eKomR+YN8rbe+MBNAAgABA4VCpU23KT2xzHhBRyTLeYXZ8NOnZjvjlxYLd+OToYh68aw3OYMQO715xxjl4eRljSJgKTHgmhA3lmeGQJ/gBqANe4LVEPfzaQ7a9oFL0aSQuD/2jbCwEK7ZvTz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mKaVkpLY; 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="mKaVkpLY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B265C19421; Thu, 15 Jan 2026 09:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468920; bh=qmPDA1ZKr0A977KNkEekwqrp6nf+Yo9xCkHHCXnhQZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mKaVkpLYZ1a3BYGxfunPbIaVDY5pndtciPfSgAB/BhePVlAEfUrr6CiA5UIpqjHcr kmNI7JUUl2rx4o9yjBHv4f8JAFQL27syiZ8kWqFd6rmmPgWA3RbIWxDfgOo+IkiD5o pK1OJDf4An6gvFYEhr+GGr813wDfvbUy5FT0lfYcuKh4VDnOReppbSlvfiyuDOCYGp L3NMhWKaw4b8FOM7iH/zTWS3t09K1rrQEXi5LG3OaQz8/P9lLQezpgeneCARWf88bl EhtgSv7g7Io1ggc38r4OVzZboge+AOmiBCrMZnFqTM3LPlv3OsAsivXiZkI1xnUGte pfrHvuy9E6z5g== 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 v2 14/23] mm/balloon_compaction: move internal helpers to balloon_compaction.c Date: Thu, 15 Jan 2026 10:20:04 +0100 Message-ID: <20260115092015.3928975-15-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 709c57c00b481..717bc43732d09 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -17,6 +17,44 @@ */ static DEFINE_SPINLOCK(balloon_pages_lock); =20 +static inline struct balloon_dev_info *balloon_page_device(struct page *pa= ge) +{ + 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 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. */ +} + static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info, struct page *page) { --=20 2.52.0 From nobody Mon Feb 9 17:56:55 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 0FB5E35B14C; Thu, 15 Jan 2026 09:22:07 +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=1768468930; cv=none; b=r3LKcPNAMdhpH05visk8NNJyiYvwUVejTT1Vj+KBPtU58+7hmjuYnWvTMWE3dQKWvUN2xxbNbKvQhxWXMrE2TCDqx1dcsgNkplFDnSxRbEy4H7wFndU28Vcw9mlpFAa3Cs62+BOiv1FITq6UFMWQ6m2MBg0XPJNaErlSnWOP1k4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468930; c=relaxed/simple; bh=9RrxLDqhOcILNhAHJt+XRLUWGRQWJudLU4Xe8hhYhVQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qTemB8VddJEawuYtkkiXighsidiycZUdE/kLoqfHbqfCtSfeaNvbkCbXqvTa2QqOXwgqEiQ8FJf/eu+Znd2YNJrLMLJyvS3r5hnoq2SMxRNGymBMC6gDFQsCprFL4CX9hFLWV8qtp0C8L+5gIJ6PlLCyGyfhKex9NTBQoBNqQH0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kZdLhXG4; 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="kZdLhXG4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB4A1C116D0; Thu, 15 Jan 2026 09:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468927; bh=9RrxLDqhOcILNhAHJt+XRLUWGRQWJudLU4Xe8hhYhVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kZdLhXG4JXKgdqJL7DBaf/x0yhRcWA9OMea3z22FVMpb45e1AaUr5hCLnS7f6YE70 De84oIOk6cku3p9sQhGMVZskL3VdEGt9Ewx80abTgrJKY4swAbL7miB0ZBVaEtBNRs LL+KhZAmuO0EV3W4N4F4/bifWzXyoSFMibubLSjNT4Lvbq01o9PD5M0/KuzxxGAlRc pLcCk39qQsCsTevuPxOywxBWafY5Koq0CnZqDsn1KfM3FV/RAEoo8IJbgMX6/XoKOY ukV9b8vgh4FO+UTIvYaYV/n4HqHOJpoe86jRjAMqgxRCcnPJTKAtCShqEKaeucUCQU rU9hb8FynZuxw== 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 v2 15/23] mm/balloon_compaction: assert that the balloon_pages_lock is held Date: Thu, 15 Jan 2026 10:20:05 +0100 Message-ID: <20260115092015.3928975-16-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- mm/balloon_compaction.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 717bc43732d09..f6e0582bd7ffe 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -33,6 +33,7 @@ static inline struct balloon_dev_info *balloon_page_devic= e(struct page *page) static inline 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 inline void balloon_page_insert(struct balloon_dev= _info *balloon, */ static inline 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 Mon Feb 9 17:56:55 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 64D8E35BDA3; Thu, 15 Jan 2026 09:22:14 +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=1768468934; cv=none; b=KTMfK1upG2Z79vFYHrczaBR/6P9BW+UZlysRdlZop57yUrq/qENYZIYVFjXlw4j+xkUCyR4lS7VBe1RcfCuuKnR2lusTTEmFFqSYqxhfNebL1wvCQD0jiM9SWj/03a2ffCZU23gjTyZR1uzBt3bVUbntQ3uCQOHXGDeCX3z3AR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468934; c=relaxed/simple; bh=6zKbuQ678tGVdnAZlvqQEolgSvUqQzw5yEAzbIvNTX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I275WT13UApNsHquBfFglY/pWxAKt+Sqmd6P5KP+0fZ9CaIIwUCiHVIVIXs3d56/TjIm3Bp6vCckFRJaM1W9B82iGqbcXPRfNTyS1Bs1V42VixGcPsFNPmlihQXiYmvfSEUjPfa/oUcGPC/xAEDUzjXPOcVeXrfQhlQqfuZPtfg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s9KraK3N; 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="s9KraK3N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAD2EC19423; Thu, 15 Jan 2026 09:22:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468934; bh=6zKbuQ678tGVdnAZlvqQEolgSvUqQzw5yEAzbIvNTX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s9KraK3NK478rMPNcGB2SPMKVpBD/lrCvQmN/00cJRhyaI0JynINGaMLGTCknHvx8 XuFSz3psTaFCfLftFZKK0z0+cggwozZicZL/vr8A/xdwbkfqZjPUoAfzvvZJHXEo/A 7+hEs6g8C0kTDbb4y08ZqIpJ/DarC74xjvTOAOgU9+ykYoFIQ1GUOaFZkPNDz5dX7S E29MMow6YjyylwhXf6kVkAFxlPTd435UVg7ZHECFwj4mGjktBpkD9SP9SB8OIE9UFE goeg92CZcbZh7uXzeWr1/uvCGGxwxM3BAdUib/iqDBUoeHdWb1StMML1t3XCtjKQpm p85cX8ZTk1kJw== 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 v2 16/23] mm/balloon_compaction: mark remaining functions for having proper kerneldoc Date: Thu, 15 Jan 2026 10:20:06 +0100 Message-ID: <20260115092015.3928975-17-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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 "*". Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 f6e0582bd7ffe..f41e4a179a431 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -22,7 +22,7 @@ static inline struct balloon_dev_info *balloon_page_devic= e(struct 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 inline 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 Mon Feb 9 17:56:55 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 DC50E32E744; Thu, 15 Jan 2026 09:22: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=1768468941; cv=none; b=ZEYR5GyP59UPGt2BE/CPV621/MQIgZY4ZNwy5Be5CwfslwDIXUqdJC4Q8PAP1AckEc2hjwgCb+u/4oDZGmhoQSWs0feAgYEpjBJxYSXWeKlKgxGDGhpg3fAhVTvdSW8LgJcVCThdFp9VQm9iYHqunyKLpMpOLE+wvuKT1/k0wOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468941; c=relaxed/simple; bh=Oj+us+E2nZAjD82c0L65S4QjEivMkfGsOYR3vhKdMVI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hHe/73W8hPAnMPxH5BSVISYikcaZ30cis0DWbCWIlS2N3RM168mfmQPuiNZz/tIOtwyRz7dGYuUhSIEe0yWFm5giUJagUP3rfC1PgVNoeY+AEg03IHG6ubyuvXFtKPdGk2ppovURpkCDXaWVsoFWDnPtr37LfhZO4+r6i0T4u1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bGUQs23U; 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="bGUQs23U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC667C116D0; Thu, 15 Jan 2026 09:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468941; bh=Oj+us+E2nZAjD82c0L65S4QjEivMkfGsOYR3vhKdMVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bGUQs23UuL0MUIaVZt7HjPch43nLsyQr8N/KNriEAjCx1ksgLfhW3wh48gTZaa+qY 96tnj/UUzP0PIXCipF3pzqx5dBpKsv8RRkmQpvassgvOnDD1yC83WGpuc9Tn802iSC a9cN1fN0mpI9pDPh/+61Faxwx0B8M6IYupNqigL7L/7o/aZQnf8fmy2eka+e+iRqad d2DobqERbxqyaFK6XuxZf8/k65wudAWKWSX8Qqu6w1yrr1CNUzKqkUMrU0y1SwVQSg XF7DROKXMmmj9QotQznh5z9X3AmNma7WE8e2XDgJ4amiXBfaEc6aoY4Q3j2AMyI5mw rQEuDPtwxRwvQ== 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 v2 17/23] mm/balloon_compaction: remove "extern" from functions Date: Thu, 15 Jan 2026 10:20:07 +0100 Message-ID: <20260115092015.3928975-18-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 5BF5435A958; Thu, 15 Jan 2026 09:22: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=1768468948; cv=none; b=rzRYQiLO8NSoAfT3uI1XVVVSwPg365GbiGoB7Pm8mNVtN9f+CeDYahPQFrGEaT6/URG4HeYWR5OUKg3YTG352Y98/Jg/YrDuCRA/LA3x+acmAlExDHLtJcrrnQcGGVHzzJxRt9JXE16zWbVFvXm8UkSxerwvGlfwGGvXALwPKo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468948; c=relaxed/simple; bh=xIjT/yGPbzWdy9CPPKodSOcwDaIkDPisOU81OKu1Nkw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gs/EWgu8vNp9IpvpYdgVNHCk5Hu58KFv3xOT9t9F3DA7Dy4r1XrUdq+rzYZtoXqbb1viD8pdyzfIJ3a86WIAmKe6kUJldyw83tplwb6LxwBAhihla04uMnux+oMLcxdCD4lXsw+VibAJpsITFl6Ba0OeT+yd/ror88Efqf129tU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BYTnHiFW; 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="BYTnHiFW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3FE0C19421; Thu, 15 Jan 2026 09:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468948; bh=xIjT/yGPbzWdy9CPPKodSOcwDaIkDPisOU81OKu1Nkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BYTnHiFW7YPOe2J6Fze71iGPPpPxEwmxWfzUTk14RKrKFn43bosoW++6osAwhU5wA q1rDiNffO1rJz6FGY3F2Ky5wp0qW7xYClI601zpW0HycKpBc/SJkGGvDucxJk25GoG wMpJF3z8qZQC1e6zOMpasbtacWBOTpKXfutSC2ewiyGEUStYFrt1GnXGT8w57OD0K1 wmPV95kTvJ3GGM4fs7FU7MYFZ5+73R5SCqaFY8Mkp6QpcLMpKFy2KrC5v3U4UJ8L8B ScLVUp/VAdCHnagkQF7bLWsOzfl8QWFhD94a+zVmyPP33NRDslhtn6lO/g0hK+i2Up VO8uFwXwKrqgA== 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 v2 18/23] mm/vmscan: drop inclusion of balloon_compaction.h Date: Thu, 15 Jan 2026 10:20:08 +0100 Message-ID: <20260115092015.3928975-19-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 7EA4833ADA4; Thu, 15 Jan 2026 09:22:35 +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=1768468955; cv=none; b=JxN4BhRhJNWH72P/ivXErV2XchRdhe1L65VTSG5UTmD39+Kh8GVTnSN43KTyjQFdrOi6qW+FhCiHfRe0GqBgRwI1gzoo9PE/9FGcI7p0A4QH4MpCtkDSFh4dVWRkKwmTUoOO7mTqn07Ftya2W2MLGmH9JnCFrB/2xdhC7zERflc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468955; c=relaxed/simple; bh=orOF2wsFt94hkjmk1N2Zd+ddx/S2GWQX029b6WMD7uQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HbeqFNkcmtn4PmalQH86aGpA1etoKNmHIkog5CpylTzRMuYc2ugho4yx7MgK1Jxjbe/5yAjNy0+xQt6foXO8YFG3w+G4ihQoHYLPcJfX15z88TR/iCOf0N96i7UU+pUbOPubTKxq7jBrs7ys2KC0TLiHwLq4L1J580+sKeidqj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LRbgYqDO; 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="LRbgYqDO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFDB7C19421; Thu, 15 Jan 2026 09:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468955; bh=orOF2wsFt94hkjmk1N2Zd+ddx/S2GWQX029b6WMD7uQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LRbgYqDO+Qlb0LQafvw3c7vh6olSFHEWpoVPHnglqGVWBWAvL6mio/t/6X16ULSXK FSOblh+jDXnKh4C21qvqKUxPVOFHkhrB804ixHZYBEzqqUCCKLU63box7Drii9Un6t jovNzGAFhwi3NhW7Bqk4cxUabQQtqppyf5fuzet0HoMCxuknRd5nLZ5jZ6TbVXXiIi F3EELF8IAdsQvaP/N6b0fH1YwhSMNWwkqztLygRrxQc5vqpkuybT1skrhq8qIocapn 56+HuY0+BBbYByKJinvqL6U5mfk1Vmrjy2M+8qE3msi6/8SePi9VT1tL6En/qA+NOz jVAzQzpa5cGGA== 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 v2 19/23] mm: rename balloon_compaction.(c|h) to balloon.(c|h) Date: Thu, 15 Jan 2026 10:20:09 +0100 Message-ID: <20260115092015.3928975-20-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 f41e4a179a431..5734dae81e318 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 Mon Feb 9 17:56:55 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 27348194C96; Thu, 15 Jan 2026 09:22:41 +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=1768468962; cv=none; b=S6o2LDvhxxFrJDgCRArHVHqak71zIOescqVjFMulj1hw/tn/9mAEe5KgMk1TsTcroTYleTUhzLLOHmMr3HnXYLpALRlAuFtBBYCJBRky1xsyldUReMTCniFVfXV09wgecblBN83VaehYWiVZ8KVOZxof62w6LNUKiFA977+o56U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468962; c=relaxed/simple; bh=nMSbJ130FsUcdSsvFUeUBR1YMlPlSjm9XeIRM/kAkzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MNbqjVPVap29dGngtLr0ZqArl67Osai61UDdWPe5S7ExHOvG10M0Xxxecqh0bJY9EJEx/d9szuAAl7AXdNEVzxsPbtFbJ5baQFchFf/dCaufuWkYsF2u8UWHXceY6gZeydyXZ8EelZbWsVGuOLQIfsHv9aPXA4S+nj+2FUAhjWw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O8jYzSQQ; 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="O8jYzSQQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 948EDC116D0; Thu, 15 Jan 2026 09:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468961; bh=nMSbJ130FsUcdSsvFUeUBR1YMlPlSjm9XeIRM/kAkzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O8jYzSQQhivp9+oi3e+25bY5iCyiGPyPZY4Q5d6BT6vIFTT2h6LTECelzgIQUwBam xm93YDpR/+tfwHTtSoZFn4io0EPnm7MXDaUCFJBiGSmOzZEsonSTnTAxHsKjgTmePs H1WVZ6Ru1nLs8fYp2MEhnZtBPHrn7pIJQJ4NUvjSZQzddO+dTHGoMvFy05u0Yzgkpg 9S7YHWca/kqlFCmPhigeFIAT6icw+tMlOJZGExUL4+q8ikAyOvua74wdBt7xThNHPm pwqoKl6EwJ/Zyx8ks0VFdx3aSfDNXWYRAOTML42Re/Qkt3iA/jsQXyOkuLXfvG+dA4 H6XnATH7JX0Lg== 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 v2 20/23] mm/kconfig: make BALLOON_COMPACTION depend on MIGRATION Date: Thu, 15 Jan 2026 10:20:10 +0100 Message-ID: <20260115092015.3928975-21-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 EF00633FE12; Thu, 15 Jan 2026 09:22:48 +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=1768468969; cv=none; b=qt30R3Xa9gC/z0WH3WUp7PdGYfcSAdVv+0Z5SG4L4snawdEnaUMkQItykbtrFImW4VUChCdgGGwsu2ZyBKlin0uTfnXD0sVvNyzdQo6RY3wgWb6j6giTda7Zrm+3Ufb3rvsR81PR+sxoDzA3ppTGJJxKpurX0Syt3x1ieNp+G7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468969; c=relaxed/simple; bh=w6otr8dOiGGPKOOaZg+aLicu0NmKupE2fxQfP1fFeDo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YuqRiucsCo5SA32IF8MmyZ136Xgt5HHMvZ5EV3N3BmNFUJlPWnzdy/bS2gl95qFQSqI5zXMdx0gLVwNPH6iR85LvIRLmfMwtnfFX134y3BnNhtOybzb9AHyqrZJmG1t7dBOPsqiUrTxI21QBgUMiDy6XVRE4unpC6wVw+xkh9xc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pBZ858MS; 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="pBZ858MS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52FDCC116D0; Thu, 15 Jan 2026 09:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468968; bh=w6otr8dOiGGPKOOaZg+aLicu0NmKupE2fxQfP1fFeDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBZ858MSONQyV80MXql5DSlvJYlnHpdlMDQeGhtBPpjJsJmUO/N6130v2d2D11+xy Tz/eg6yWwWCEXrMOJ7BNewbnzGXWH9eI2hKw7e4JUS4asznZPjof+bQzAWiiwdmJxJ kRvw9iBlNo66utvjTOjJ/tebXRYgvkqhnRWoobLVthZYEdxZdM62wTQgFjnAGLOx31 sZtM+SXx9admPYYvNyR6vPgt1O8JjdJuTYgZLhrAjWwR88+PScCcgHbsTMDEniVgwF 2/o0j07aKa5JBw79dOI7utgp8mSbIUrkx0YAwf2dYnOPNCSBhIkKyK+Px4tz+pskFU UuGX0Zdk3gt1Q== 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 v2 21/23] mm: rename CONFIG_BALLOON_COMPACTION to CONFIG_BALLOON_MIGRATION Date: Thu, 15 Jan 2026 10:20:11 +0100 Message-ID: <20260115092015.3928975-22-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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 */". Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 | 2 +- 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, 30 insertions(+), 30 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..e8da95ca4ad48 100644 --- a/include/linux/balloon.h +++ b/include/linux/balloon.h @@ -45,7 +45,7 @@ =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. 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 5734dae81e318..8a21c6b9a7f0a 100644 --- a/mm/balloon.c +++ b/mm/balloon.c @@ -34,7 +34,7 @@ static inline 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 inline void balloon_page_insert(struct balloon_dev= _info *balloon, static inline 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 @@ -340,4 +340,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 Mon Feb 9 17:56:55 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 ACECD33FE12; Thu, 15 Jan 2026 09:22:55 +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=1768468975; cv=none; b=SNHgL0ZvclpsIDHxjxlT3x1HMlVLa3Ok0zH35tBSwV34bH2tXmN/5Xh3kHDW+OTXEwXZhACOVNmyHeoKVeNqfT/FQIZ8+bZBnJL3YwumVTNzfAysh8G6+LYE6A2Bo5sgtdaFuCePycuOz7h5aw+r7+rRajarrmcnOIJrRaNkW/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468975; c=relaxed/simple; bh=p88E23dCTiy64PagmGaBE80XA04TjGF75KHH64+hMzk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WaFQaJ12KE4X6EB0S7R+vBCkbG8oKeSnIFkbEQsu1hWZPo7ya/kme9ZzxNPluWMtI4TpcrIjhbS0GuxXkoaRaI+DzMvll603Saksa9S27mD9jZHjjd7hUlX9GVWyhTXiOu2SYWg3IRIwLl3DQbndn9DtVZyt5PKEUL8S9ButHMc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YGSJm4R7; 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="YGSJm4R7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 511E3C19423; Thu, 15 Jan 2026 09:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468975; bh=p88E23dCTiy64PagmGaBE80XA04TjGF75KHH64+hMzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YGSJm4R7U/R58XrtXpfth8OYhuw9HdCkCtpWyccTsIRiLwmNpmCuzFOQjJE8hn4RB uz1otUzKMl+JqDw/m0o2g+c0JgWmf6LIEDWnjW3WcP6Gvgi+5AVgLTM1Tkg8i23lo0 HscxoHnTt49CQRkbwTVeYEz4Qz+ebECUrYwNMCKBX0+CxNj01SL7fE/3p/Er6/91Bq qsTSS2JteQnFmUfiPFBKiInhJ4zHkCfhIxyV5hE4LzhJeFBY5JnDrPkZwPA036j2Zq pNR1R1afCa7a88Y+63spvI0c0ua4He1TcQa/OUzSv+MHhmqmsjSw5mliwnFBp0jb96 0PDz3KSlgkcGA== 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 v2 22/23] mm: rename CONFIG_MEMORY_BALLOON -> CONFIG_BALLOON Date: Thu, 15 Jan 2026 10:20:12 +0100 Message-ID: <20260115092015.3928975-23-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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 */". Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Michael S. Tsirkin Reviewed-by: Lorenzo Stoakes --- 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 Mon Feb 9 17:56:55 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 4E3B5261B78; Thu, 15 Jan 2026 09:23:02 +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=1768468982; cv=none; b=cUtYp/ahTvzVInrEPl7iCPSoO8EyCnQ2Txn5NPufscIw+YEtlzM/XF/hDeOTxQ3uUCuibyFG8sfKLrxcFNb0cWWEOOJG15CInT6Zmq2unZd+UD5nEOVKGKk+4tuxUcpgQGloy5k6WyfsoUYqBpJENSG3iK0nA6BY1QIsXYEnnzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768468982; c=relaxed/simple; bh=7bbMIQHe4/weqHbDvWGJ/Jw7lMXhnWUDxpL265aHTuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kqcj06DwOwKcUdBteIO70o5ozqm57ZJDEaAqpQYPhOUln2WN5rn3bYJWiAkvp9WkFWs9jky6YJrigskfWO1nwvqKMQBH3Tp+lG5YHZK4Jo96bSlq3gfQiPwDYFBW8F3xvErLS6Mqfz4bsYCyuiraHMc5rye/jJrMlpDP7HDOK3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AAEkmlmh; 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="AAEkmlmh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11E0EC116D0; Thu, 15 Jan 2026 09:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768468982; bh=7bbMIQHe4/weqHbDvWGJ/Jw7lMXhnWUDxpL265aHTuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AAEkmlmhOTceSZ1CTH7c6V1r4hbYnHKCzeML4q4ap22b0eiu4voauLSYHnNcbJ82N VLuftsgMRoUyx0cMRJjfaaWJ6BiT8gRsgO+9Q5aY0E+33tpnidcAehdKF26sx0Twyc lSHIO4sFT4VXKuEckOYXFbcwO2lHkZw6isdac90GlKa7IY+CT1/zmbixS05MAgrjSs Z7apK7S7toMIAwBpwp/8ipTr2iGV5xeHGgBeyIIdb3peRCRXYh0JEuQ2LJWKHD9JLB XaIoAfBmxPPtpSqNRqqIm2BJ+5OlceBGoU7EDpzHi+ijxE9wxxjXP8/U4A5zoNmLHw 5WaX+2zvRSF4w== 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 v2 23/23] MAINTAINERS: move memory balloon infrastructure to "MEMORY MANAGEMENT - BALLOON" Date: Thu, 15 Jan 2026 10:20:13 +0100 Message-ID: <20260115092015.3928975-24-david@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115092015.3928975-1-david@kernel.org> References: <20260115092015.3928975-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. Signed-off-by: David Hildenbrand (Red Hat) Acked-by: Lorenzo Stoakes Acked-by: Michael S. Tsirkin Acked-by: Vlastimil Babka --- MAINTAINERS | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index de8f89ca1149f..b974f8c1c2225 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16454,6 +16454,16 @@ 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 +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 +27546,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