From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Kefeng Wang <wangkefeng.wang@huawei.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, Xu Xin <xu.xin16@zte.com.cn>,
Chengming Zhou <chengming.zhou@linux.dev>
Subject: Re: [PATCH v2] mm: remove PageTransCompound()
Date: Thu, 18 Jun 2026 14:40:38 +0200 [thread overview]
Message-ID: <167eca2f-8338-4c95-93c7-b2d2a11bfef0@kernel.org> (raw)
In-Reply-To: <20260618113523.3913307-1-wangkefeng.wang@huawei.com>
On 6/18/26 13:35, Kefeng Wang wrote:
> Remove the last user of PageTransCompound() in ksm and
> get rid of PageTransCompound().
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> v2:
> - use more folio in cmp_and_merge_page(), suggested by David
>
> include/linux/page-flags.h | 14 --------------
> mm/ksm.c | 17 +++++++++--------
> 2 files changed, 9 insertions(+), 22 deletions(-)
>
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 7223f6f4e2b4..7a863572adce 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -879,20 +879,6 @@ FOLIO_FLAG_FALSE(partially_mapped)
>
> #define PG_head_mask ((1UL << PG_head))
>
> -#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> -/*
> - * PageTransCompound returns true for both transparent huge pages
> - * and hugetlbfs pages, so it should only be called when it's known
> - * that hugetlbfs pages aren't involved.
> - */
> -static inline int PageTransCompound(const struct page *page)
> -{
> - return PageCompound(page);
> -}
> -#else
> -TESTPAGEFLAG_FALSE(TransCompound, transcompound)
> -#endif
> -
> #if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE)
> /*
> * PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in the
> diff --git a/mm/ksm.c b/mm/ksm.c
> index 7d5b76478f0b..41ab25aa2a82 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -2327,23 +2327,24 @@ static void cmp_and_merge_page(struct page *page, struct ksm_rmap_item *rmap_ite
> tree_rmap_item =
> unstable_tree_search_insert(rmap_item, page, &tree_page);
> if (tree_rmap_item) {
> + struct folio *tree_folio;
> bool split;
>
> kfolio = try_to_merge_two_pages(rmap_item, page,
> tree_rmap_item, tree_page);
> + tree_folio = page_folio(tree_page);
> /*
> - * If both pages we tried to merge belong to the same compound
> - * page, then we actually ended up increasing the reference
> - * count of the same compound page twice, and split_huge_page
> - * failed.
> + * If both pages we tried to merge belong to the same (large)
> + * folio, then we actually ended up increasing the reference
> + * count of the same folio twice, and split_huge_page failed.
> + *
> * Here we set a flag if that happened, and we use it later to
> - * try split_huge_page again. Since we call put_page right
> + * try split_huge_page again. Since we call folio_put() right
> * afterwards, the reference count will be correct and
> * split_huge_page should succeed.
> */
> - split = PageTransCompound(page)
> - && compound_head(page) == compound_head(tree_page);
> - put_page(tree_page);
> + split = folio == tree_folio;
> + folio_put(tree_folio);
> if (kfolio) {
> /*
> * The pages were successfully merged: insert new
Thanks!
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
next prev parent reply other threads:[~2026-06-18 12:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 11:35 [PATCH v2] mm: remove PageTransCompound() Kefeng Wang
2026-06-18 12:40 ` David Hildenbrand (Arm) [this message]
2026-06-18 15:01 ` xu.xin16
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=167eca2f-8338-4c95-93c7-b2d2a11bfef0@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=linux-mm@kvack.org \
--cc=wangkefeng.wang@huawei.com \
--cc=xu.xin16@zte.com.cn \
/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