From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: David Hildenbrand <david@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org,
"Andrew Morton" <akpm@linux-foundation.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Madhavan Srinivasan" <maddy@linux.ibm.com>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"Jerrin Shaji George" <jerrin.shaji-george@broadcom.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Jan Kara" <jack@suse.cz>, "Zi Yan" <ziy@nvidia.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Joshua Hahn" <joshua.hahnjy@gmail.com>,
"Rakie Kim" <rakie.kim@sk.com>,
"Byungchul Park" <byungchul@sk.com>,
"Gregory Price" <gourry@gourry.net>,
"Ying Huang" <ying.huang@linux.alibaba.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
"Vlastimil Babka" <vbabka@suse.cz>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Minchan Kim" <minchan@kernel.org>,
"Sergey Senozhatsky" <senozhatsky@chromium.org>,
"Brendan Jackman" <jackmanb@google.com>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"John Hubbard" <jhubbard@nvidia.com>,
"Peter Xu" <peterx@redhat.com>, "Xu Xin" <xu.xin16@zte.com.cn>,
"Chengming Zhou" <chengming.zhou@linux.dev>,
"Miaohe Lin" <linmiaohe@huawei.com>,
"Naoya Horiguchi" <nao.horiguchi@gmail.com>,
"Oscar Salvador" <osalvador@suse.de>,
"Rik van Riel" <riel@surriel.com>,
"Harry Yoo" <harry.yoo@oracle.com>,
"Qi Zheng" <zhengqi.arch@bytedance.com>,
"Shakeel Butt" <shakeel.butt@linux.dev>
Subject: Re: [PATCH v1 02/29] mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize()
Date: Mon, 30 Jun 2025 16:15:28 +0100 [thread overview]
Message-ID: <f9cb1865-aa9d-409f-bce5-7051480c1a71@lucifer.local> (raw)
In-Reply-To: <20250630130011.330477-3-david@redhat.com>
On Mon, Jun 30, 2025 at 02:59:43PM +0200, David Hildenbrand wrote:
> Let's move the removal of the page from the balloon list into the single
> caller, to remove the dependency on the PG_isolated flag and clarify
> locking requirements.
>
> We'll shuffle the operations a bit such that they logically make more sense
> (e.g., remove from the list before clearing flags).
>
> In balloon migration functions we can now move the balloon_page_finalize()
> out of the balloon lock and perform the finalization just before dropping
> the balloon reference.
>
> Document that the page lock is currently required when modifying the
> movability aspects of a page; hopefully we can soon decouple this from the
> page lock.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> arch/powerpc/platforms/pseries/cmm.c | 2 +-
> drivers/misc/vmw_balloon.c | 3 +-
> drivers/virtio/virtio_balloon.c | 4 +--
> include/linux/balloon_compaction.h | 43 +++++++++++-----------------
> mm/balloon_compaction.c | 3 +-
> 5 files changed, 21 insertions(+), 34 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/pseries/cmm.c
> index 5f4037c1d7fe8..5e0a718d1be7b 100644
> --- a/arch/powerpc/platforms/pseries/cmm.c
> +++ b/arch/powerpc/platforms/pseries/cmm.c
> @@ -532,7 +532,6 @@ static int cmm_migratepage(struct balloon_dev_info *b_dev_info,
>
> spin_lock_irqsave(&b_dev_info->pages_lock, flags);
> balloon_page_insert(b_dev_info, newpage);
> - balloon_page_delete(page);
We seem to just be removing this and not replacing with finalize, is this right?
> b_dev_info->isolated_pages--;
> spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
>
> @@ -542,6 +541,7 @@ static int cmm_migratepage(struct balloon_dev_info *b_dev_info,
> */
> plpar_page_set_active(page);
>
> + balloon_page_finalize(page);
> /* balloon page list reference */
> put_page(page);
>
> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> index c817d8c216413..6653fc53c951c 100644
> --- a/drivers/misc/vmw_balloon.c
> +++ b/drivers/misc/vmw_balloon.c
> @@ -1778,8 +1778,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
> * @pages_lock . We keep holding @comm_lock since we will need it in a
> * second.
> */
> - balloon_page_delete(page);
> -
> + balloon_page_finalize(page);
> put_page(page);
>
> /* Inflate */
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 89da052f4f687..e299e18346a30 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -866,15 +866,13 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
> tell_host(vb, vb->inflate_vq);
>
> /* balloon's page migration 2nd step -- deflate "page" */
> - spin_lock_irqsave(&vb_dev_info->pages_lock, flags);
> - balloon_page_delete(page);
> - spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags);
> vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
> set_page_pfns(vb, vb->pfns, page);
> tell_host(vb, vb->deflate_vq);
>
> mutex_unlock(&vb->balloon_lock);
>
> + balloon_page_finalize(page);
> put_page(page); /* balloon reference */
>
> return MIGRATEPAGE_SUCCESS;
> diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h
> index 5ca2d56996201..b9f19da37b089 100644
> --- a/include/linux/balloon_compaction.h
> +++ b/include/linux/balloon_compaction.h
> @@ -97,27 +97,6 @@ static inline void balloon_page_insert(struct balloon_dev_info *balloon,
> list_add(&page->lru, &balloon->pages);
> }
>
> -/*
> - * balloon_page_delete - delete a page from balloon's page list and clear
> - * the page->private assignement accordingly.
> - * @page : page to be released from balloon's page list
> - *
> - * Caller must ensure the page is locked and the spin_lock protecting balloon
> - * pages list is held before deleting a page from the balloon device.
> - */
> -static inline void balloon_page_delete(struct page *page)
> -{
> - __ClearPageOffline(page);
> - __ClearPageMovable(page);
> - set_page_private(page, 0);
> - /*
> - * No touch page.lru field once @page has been isolated
> - * because VM is using the field.
> - */
> - if (!PageIsolated(page))
> - list_del(&page->lru);
I don't see this check elsewhere, is it because, as per the 1/xx of this series,
because by the time we do the finalize
> -}
> -
> /*
> * balloon_page_device - get the b_dev_info descriptor for the balloon device
> * that enqueues the given page.
> @@ -141,12 +120,6 @@ static inline void balloon_page_insert(struct balloon_dev_info *balloon,
> list_add(&page->lru, &balloon->pages);
> }
>
> -static inline void balloon_page_delete(struct page *page)
> -{
> - __ClearPageOffline(page);
> - list_del(&page->lru);
> -}
> -
> static inline gfp_t balloon_mapping_gfp_mask(void)
> {
> return GFP_HIGHUSER;
> @@ -154,6 +127,22 @@ static inline gfp_t balloon_mapping_gfp_mask(void)
>
> #endif /* CONFIG_BALLOON_COMPACTION */
>
> +/*
> + * 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 that the page is locked.
Can we assert this? Maybe mention that the balloon lock should not be held?
> + */
> +static inline void balloon_page_finalize(struct page *page)
> +{
> + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) {
> + __ClearPageMovable(page);
> + set_page_private(page, 0);
> + }
Why do we check this? Is this function called from anywhere where that config won't be set?
> + __ClearPageOffline(page);
> +}
> +
> /*
> * balloon_page_push - insert a page into a page list.
> * @head : pointer to list
> diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
> index fcb60233aa35d..ec176bdb8a78b 100644
> --- a/mm/balloon_compaction.c
> +++ b/mm/balloon_compaction.c
> @@ -94,7 +94,8 @@ size_t balloon_page_list_dequeue(struct balloon_dev_info *b_dev_info,
> if (!trylock_page(page))
> continue;
>
> - balloon_page_delete(page);
> + list_del(&page->lru);
> + balloon_page_finalize(page);
> __count_vm_event(BALLOON_DEFLATE);
> list_add(&page->lru, pages);
> unlock_page(page);
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-06-30 15:16 UTC|newest]
Thread overview: 138+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 12:59 [PATCH v1 00/29] mm/migration: rework movable_ops page migration (part 1) David Hildenbrand
2025-06-30 12:59 ` [PATCH v1 01/29] mm/balloon_compaction: we cannot have isolated pages in the balloon list David Hildenbrand
2025-06-30 14:45 ` Lorenzo Stoakes
2025-06-30 12:59 ` [PATCH v1 02/29] mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize() David Hildenbrand
2025-06-30 15:15 ` Lorenzo Stoakes [this message]
2025-07-01 7:58 ` David Hildenbrand
2025-07-01 9:01 ` Lorenzo Stoakes
2025-07-01 9:59 ` David Hildenbrand
2025-06-30 12:59 ` [PATCH v1 03/29] mm/zsmalloc: drop PageIsolated() related VM_BUG_ONs David Hildenbrand
2025-06-30 15:17 ` Lorenzo Stoakes
2025-07-01 8:03 ` David Hildenbrand
2025-07-01 8:57 ` Lorenzo Stoakes
2025-06-30 12:59 ` [PATCH v1 04/29] mm/page_alloc: let page freeing clear any set page type David Hildenbrand
2025-06-30 15:27 ` Lorenzo Stoakes
2025-07-01 8:17 ` David Hildenbrand
2025-07-01 8:27 ` Lorenzo Stoakes
2025-07-01 8:34 ` David Hildenbrand
2025-07-01 8:37 ` Lorenzo Stoakes
2025-07-01 10:02 ` David Hildenbrand
2025-06-30 12:59 ` [PATCH v1 05/29] mm/balloon_compaction: make PageOffline sticky until the page is freed David Hildenbrand
2025-06-30 16:01 ` Lorenzo Stoakes
2025-06-30 16:14 ` Zi Yan
2025-06-30 16:17 ` Lorenzo Stoakes
2025-07-01 6:13 ` Harry Yoo
2025-07-01 8:11 ` David Hildenbrand
2025-07-01 8:12 ` David Hildenbrand
2025-07-01 8:21 ` David Hildenbrand
2025-06-30 12:59 ` [PATCH v1 06/29] mm/zsmalloc: make PageZsmalloc() " David Hildenbrand
2025-06-30 16:03 ` Lorenzo Stoakes
2025-07-01 8:27 ` David Hildenbrand
2025-06-30 12:59 ` [PATCH v1 07/29] mm/migrate: rename isolate_movable_page() to isolate_movable_ops_page() David Hildenbrand
2025-06-30 16:24 ` Lorenzo Stoakes
2025-07-01 8:29 ` David Hildenbrand
2025-07-01 9:11 ` Lorenzo Stoakes
2025-06-30 12:59 ` [PATCH v1 08/29] mm/migrate: rename putback_movable_folio() to putback_movable_ops_page() David Hildenbrand
2025-06-30 16:29 ` Lorenzo Stoakes
2025-07-01 6:04 ` Harry Yoo
2025-07-01 14:42 ` Zi Yan
2025-06-30 12:59 ` [PATCH v1 09/29] mm/migrate: factor out movable_ops page handling into migrate_movable_ops_page() David Hildenbrand
2025-06-30 17:05 ` Lorenzo Stoakes
2025-07-01 9:24 ` David Hildenbrand
2025-07-01 10:10 ` David Hildenbrand
2025-07-01 7:05 ` Harry Yoo
2025-06-30 12:59 ` [PATCH v1 10/29] mm/migrate: remove folio_test_movable() and folio_movable_ops() David Hildenbrand
2025-06-30 17:07 ` Lorenzo Stoakes
2025-07-01 10:15 ` David Hildenbrand
2025-07-01 10:25 ` Lorenzo Stoakes
2025-07-01 6:31 ` Harry Yoo
2025-06-30 12:59 ` [PATCH v1 11/29] mm/migrate: move movable_ops page handling out of move_to_new_folio() David Hildenbrand
2025-07-01 7:14 ` Harry Yoo
2025-07-01 9:37 ` Lorenzo Stoakes
2025-06-30 12:59 ` [PATCH v1 12/29] mm/zsmalloc: stop using __ClearPageMovable() David Hildenbrand
2025-07-01 8:20 ` Harry Yoo
2025-07-01 9:40 ` Lorenzo Stoakes
2025-07-02 8:11 ` Sergey Senozhatsky
2025-07-02 8:25 ` David Hildenbrand
2025-07-02 10:10 ` Sergey Senozhatsky
2025-07-02 10:55 ` David Hildenbrand
2025-07-03 2:28 ` Sergey Senozhatsky
2025-07-03 3:22 ` Sergey Senozhatsky
2025-07-03 7:45 ` David Hildenbrand
2025-07-03 7:49 ` Sergey Senozhatsky
2025-06-30 12:59 ` [PATCH v1 13/29] mm/balloon_compaction: " David Hildenbrand
2025-07-01 10:03 ` Lorenzo Stoakes
2025-07-01 10:19 ` David Hildenbrand
2025-07-01 10:40 ` Lorenzo Stoakes
2025-07-01 12:24 ` David Hildenbrand
2025-06-30 12:59 ` [PATCH v1 14/29] mm/migrate: remove __ClearPageMovable() David Hildenbrand
2025-07-01 8:36 ` Harry Yoo
2025-07-01 10:43 ` Lorenzo Stoakes
2025-07-01 12:25 ` David Hildenbrand
2025-06-30 12:59 ` [PATCH v1 15/29] mm/migration: remove PageMovable() David Hildenbrand
2025-07-01 10:50 ` Lorenzo Stoakes
2025-07-01 12:27 ` David Hildenbrand
2025-07-02 9:20 ` Harry Yoo
2025-06-30 12:59 ` [PATCH v1 16/29] mm: rename __PageMovable() to page_has_movable_ops() David Hildenbrand
2025-07-01 10:59 ` Lorenzo Stoakes
2025-07-01 12:29 ` David Hildenbrand
2025-07-02 9:29 ` Harry Yoo
2025-06-30 12:59 ` [PATCH v1 17/29] mm/page_isolation: drop __folio_test_movable() check for large folios David Hildenbrand
2025-07-01 11:03 ` Lorenzo Stoakes
2025-07-01 12:32 ` David Hildenbrand
2025-07-02 9:54 ` Harry Yoo
2025-07-02 9:48 ` Harry Yoo
2025-06-30 12:59 ` [PATCH v1 18/29] mm: remove __folio_test_movable() David Hildenbrand
2025-07-01 11:30 ` Lorenzo Stoakes
2025-07-01 12:36 ` David Hildenbrand
2025-07-02 10:20 ` Harry Yoo
2025-06-30 13:00 ` [PATCH v1 19/29] mm: stop storing migration_ops in page->mapping David Hildenbrand
2025-07-01 12:12 ` Lorenzo Stoakes
2025-07-01 12:41 ` David Hildenbrand
2025-07-02 10:34 ` Harry Yoo
2025-07-02 11:04 ` David Hildenbrand
2025-07-02 11:43 ` Harry Yoo
2025-07-02 11:51 ` David Hildenbrand
2025-07-02 11:57 ` Harry Yoo
2025-06-30 13:00 ` [PATCH v1 20/29] mm: convert "movable" flag in page->mapping to a page flag David Hildenbrand
2025-07-01 12:44 ` Lorenzo Stoakes
2025-07-01 12:49 ` David Hildenbrand
2025-07-02 11:54 ` Harry Yoo
2025-07-02 12:01 ` David Hildenbrand
2025-07-02 13:01 ` Harry Yoo
2025-07-02 15:25 ` David Hildenbrand
2025-06-30 13:00 ` [PATCH v1 21/29] mm: rename PG_isolated to PG_movable_ops_isolated David Hildenbrand
2025-07-01 12:51 ` Lorenzo Stoakes
2025-07-01 16:19 ` David Hildenbrand
2025-07-02 13:04 ` Harry Yoo
2025-06-30 13:00 ` [PATCH v1 22/29] mm/page-flags: rename PAGE_MAPPING_MOVABLE to PAGE_MAPPING_ANON_KSM David Hildenbrand
2025-07-01 12:54 ` Lorenzo Stoakes
2025-07-01 19:31 ` David Hildenbrand
2025-07-02 9:06 ` Lorenzo Stoakes
2025-07-02 13:11 ` Harry Yoo
2025-06-30 13:00 ` [PATCH v1 23/29] mm/page-alloc: remove PageMappingFlags() David Hildenbrand
2025-07-01 13:02 ` Lorenzo Stoakes
2025-07-01 19:34 ` David Hildenbrand
2025-07-02 8:49 ` Lorenzo Stoakes
2025-07-02 9:02 ` David Hildenbrand
2025-07-02 9:09 ` Lorenzo Stoakes
2025-07-02 9:16 ` David Hildenbrand
2025-07-02 13:20 ` Harry Yoo
2025-06-30 13:00 ` [PATCH v1 24/29] mm/page-flags: remove folio_mapping_flags() David Hildenbrand
2025-07-01 13:03 ` Lorenzo Stoakes
2025-07-02 13:23 ` Harry Yoo
2025-06-30 13:00 ` [PATCH v1 25/29] mm: simplify folio_expected_ref_count() David Hildenbrand
2025-07-01 13:15 ` Lorenzo Stoakes
2025-07-02 13:40 ` Harry Yoo
2025-06-30 13:00 ` [PATCH v1 26/29] mm: rename PAGE_MAPPING_* to FOLIO_MAPPING_* David Hildenbrand
2025-07-01 13:17 ` Lorenzo Stoakes
2025-07-02 14:10 ` Harry Yoo
2025-06-30 13:00 ` [PATCH v1 27/29] docs/mm: convert from "Non-LRU page migration" to "movable_ops page migration" David Hildenbrand
2025-07-01 13:19 ` Lorenzo Stoakes
2025-07-02 14:23 ` Harry Yoo
2025-07-02 14:52 ` David Hildenbrand
2025-06-30 13:00 ` [PATCH v1 28/29] mm/balloon_compaction: "movable_ops" doc updates David Hildenbrand
2025-07-01 13:20 ` Lorenzo Stoakes
2025-06-30 13:00 ` [PATCH v1 29/29] mm/balloon_compaction: provide single balloon_page_insert() and balloon_mapping_gfp_mask() David Hildenbrand
2025-07-01 13:22 ` Lorenzo Stoakes
2025-07-01 19:38 ` [PATCH v1 00/29] mm/migration: rework movable_ops page migration (part 1) David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f9cb1865-aa9d-409f-bce5-7051480c1a71@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=byungchul@sk.com \
--cc=chengming.zhou@linux.dev \
--cc=christophe.leroy@csgroup.eu \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=eperezma@redhat.com \
--cc=gourry@gourry.net \
--cc=gregkh@linuxfoundation.org \
--cc=hannes@cmpxchg.org \
--cc=harry.yoo@oracle.com \
--cc=jack@suse.cz \
--cc=jackmanb@google.com \
--cc=jasowang@redhat.com \
--cc=jerrin.shaji-george@broadcom.com \
--cc=jgg@ziepe.ca \
--cc=jhubbard@nvidia.com \
--cc=joshua.hahnjy@gmail.com \
--cc=linmiaohe@huawei.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=matthew.brost@intel.com \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=mst@redhat.com \
--cc=nao.horiguchi@gmail.com \
--cc=npiggin@gmail.com \
--cc=osalvador@suse.de \
--cc=peterx@redhat.com \
--cc=rakie.kim@sk.com \
--cc=riel@surriel.com \
--cc=rppt@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=viro@zeniv.linux.org.uk \
--cc=virtualization@lists.linux.dev \
--cc=willy@infradead.org \
--cc=xu.xin16@zte.com.cn \
--cc=xuanzhuo@linux.alibaba.com \
--cc=ying.huang@linux.alibaba.com \
--cc=zhengqi.arch@bytedance.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox