Re: [PATCH v2 14/23] mm/balloon_compaction: move internal helpers to balloon_compaction.c

Lorenzo Stoakes
2026-01-15T12:32:57Z

On Thu, Jan 15, 2026 at 10:20:04AM +0100, David Hildenbrand (Red Hat) wrote:
> 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) <david@kernel.org>

LGTM, with some nits below so:

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

> ---
> 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_compaction.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_dev_info *balloon)
> balloon->migratepage = NULL;
> balloon->adjust_managed_page_count = false;
> }
> -
> -#ifdef CONFIG_BALLOON_COMPACTION
> -/*
> - * balloon_page_device - get the b_dev_info descriptor for the balloon device
> - * that enqueues the given page.
> - */
> -static inline struct balloon_dev_info *balloon_page_device(struct page *page)
> -{
> - 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 make
> - * 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);
>
> +static inline struct balloon_dev_info *balloon_page_device(struct page *page)

NIT: inline here isn't needed.

> +{
> + return (struct balloon_dev_info *)page_private(page);
> +}
> +
> +/*
> + * balloon_page_insert - insert a page into the balloon's page list and make
> + * 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)

NIT: same as above.

> +{
> + __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)

NIT: same as above.

> +{
> + 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)
> {
> --
> 2.52.0
>