From: Nico Pache <npache@redhat.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: akpm@linux-foundation.org, david@kernel.org,
lorenzo.stoakes@oracle.com, ziy@nvidia.com,
baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com,
ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
lance.yang@linux.dev, rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, linux-mm@kvack.org
Subject: Re: [Patch v2 3/3] mm/khugepaged: unify SCAN_PMD_NONE and SCAN_PMD_NULL into SCAN_NO_PTE_TABLE
Date: Mon, 17 Nov 2025 10:25:10 -0700 [thread overview]
Message-ID: <CAA1CXcATqLCv8k0OEoEcYy-=e1NevsjoebnefFbV1=yB-gyygA@mail.gmail.com> (raw)
In-Reply-To: <20251114030028.7035-4-richard.weiyang@gmail.com>
On Thu, Nov 13, 2025 at 8:00 PM Wei Yang <richard.weiyang@gmail.com> wrote:
>
> The current hugepage collapse scan results include two separate values,
> SCAN_PMD_NONE and SCAN_PMD_NULL, which are handled identically by
> the consuming code.
>
> To reduce confusion and improve long-term maintenance, this commit
> merges these two functionally equivalent states into a single, clearer
> identifier: SCAN_NO_PTE_TABLE
Nice cleanup!
Reviewed-by: Nico Pache <npache@redhat.com>
>
> Suggested-by: "David Hildenbrand (Red Hat)" <david@kernel.org>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
> include/trace/events/huge_memory.h | 3 +--
> mm/khugepaged.c | 23 ++++++++++-------------
> 2 files changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/include/trace/events/huge_memory.h b/include/trace/events/huge_memory.h
> index dd94d14a2427..4cde53b45a85 100644
> --- a/include/trace/events/huge_memory.h
> +++ b/include/trace/events/huge_memory.h
> @@ -10,8 +10,7 @@
> #define SCAN_STATUS \
> EM( SCAN_FAIL, "failed") \
> EM( SCAN_SUCCEED, "succeeded") \
> - EM( SCAN_PMD_NULL, "pmd_null") \
> - EM( SCAN_PMD_NONE, "pmd_none") \
> + EM( SCAN_NO_PTE_TABLE, "no_pte_table") \
> EM( SCAN_PMD_MAPPED, "page_pmd_mapped") \
> EM( SCAN_EXCEED_NONE_PTE, "exceed_none_pte") \
> EM( SCAN_EXCEED_SWAP_PTE, "exceed_swap_pte") \
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 2ee5048b764e..40f9d5939aa5 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -30,8 +30,7 @@
> enum scan_result {
> SCAN_FAIL,
> SCAN_SUCCEED,
> - SCAN_PMD_NULL,
> - SCAN_PMD_NONE,
> + SCAN_NO_PTE_TABLE,
> SCAN_PMD_MAPPED,
> SCAN_EXCEED_NONE_PTE,
> SCAN_EXCEED_SWAP_PTE,
> @@ -934,7 +933,7 @@ static inline int check_pmd_state(pmd_t *pmd)
> pmd_t pmde = pmdp_get_lockless(pmd);
>
> if (pmd_none(pmde))
> - return SCAN_PMD_NONE;
> + return SCAN_NO_PTE_TABLE;
>
> /*
> * The folio may be under migration when khugepaged is trying to
> @@ -944,11 +943,11 @@ static inline int check_pmd_state(pmd_t *pmd)
> if (pmd_is_migration_entry(pmde))
> return SCAN_PMD_MAPPED;
> if (!pmd_present(pmde))
> - return SCAN_PMD_NULL;
> + return SCAN_NO_PTE_TABLE;
> if (pmd_trans_huge(pmde))
> return SCAN_PMD_MAPPED;
> if (pmd_bad(pmde))
> - return SCAN_PMD_NULL;
> + return SCAN_NO_PTE_TABLE;
> return SCAN_SUCCEED;
> }
>
> @@ -958,7 +957,7 @@ static int find_pmd_or_thp_or_none(struct mm_struct *mm,
> {
> *pmd = mm_find_pmd(mm, address);
> if (!*pmd)
> - return SCAN_PMD_NULL;
> + return SCAN_NO_PTE_TABLE;
>
> return check_pmd_state(*pmd);
> }
> @@ -1013,7 +1012,7 @@ static int __collapse_huge_page_swapin(struct mm_struct *mm,
> pte = pte_offset_map_ro_nolock(mm, pmd, addr, &ptl);
> if (!pte) {
> mmap_read_unlock(mm);
> - result = SCAN_PMD_NULL;
> + result = SCAN_NO_PTE_TABLE;
> goto out;
> }
> }
> @@ -1187,7 +1186,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,
> &compound_pagelist);
> spin_unlock(pte_ptl);
> } else {
> - result = SCAN_PMD_NULL;
> + result = SCAN_NO_PTE_TABLE;
> }
>
> if (unlikely(result != SCAN_SUCCEED)) {
> @@ -1270,7 +1269,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
> nodes_clear(cc->alloc_nmask);
> pte = pte_offset_map_lock(mm, pmd, start_addr, &ptl);
> if (!pte) {
> - result = SCAN_PMD_NULL;
> + result = SCAN_NO_PTE_TABLE;
> goto out;
> }
>
> @@ -1544,8 +1543,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr,
> switch (result) {
> case SCAN_SUCCEED:
> break;
> - case SCAN_PMD_NULL:
> - case SCAN_PMD_NONE:
> + case SCAN_NO_PTE_TABLE:
> /*
> * All pte entries have been removed and pmd cleared.
> * Skip all the pte checks and just update the pmd mapping.
> @@ -2832,8 +2830,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
> mmap_read_unlock(mm);
> goto handle_result;
> /* Whitelisted set of results where continuing OK */
> - case SCAN_PMD_NULL:
> - case SCAN_PMD_NONE:
> + case SCAN_NO_PTE_TABLE:
> case SCAN_PTE_NON_PRESENT:
> case SCAN_PTE_UFFD_WP:
> case SCAN_LACK_REFERENCED_PAGE:
> --
> 2.34.1
>
prev parent reply other threads:[~2025-11-17 17:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 3:00 [Patch v2 0/3] unify PMD scan results and remove redundant cleanup Wei Yang
2025-11-14 3:00 ` [Patch v2 1/3] mm/khugepaged: remove redundant clearing of struct collapse_control Wei Yang
2025-11-14 4:37 ` Dev Jain
2025-11-14 8:53 ` David Hildenbrand (Red Hat)
2025-11-17 8:04 ` Baolin Wang
2025-11-17 17:23 ` Nico Pache
2025-11-14 3:00 ` [Patch v2 2/3] mm/khugepaged: continue to collapse on SCAN_PMD_NONE Wei Yang
2025-11-14 8:54 ` David Hildenbrand (Red Hat)
2025-11-14 3:00 ` [Patch v2 3/3] mm/khugepaged: unify SCAN_PMD_NONE and SCAN_PMD_NULL into SCAN_NO_PTE_TABLE Wei Yang
2025-11-14 5:06 ` Dev Jain
2025-11-14 8:55 ` David Hildenbrand (Red Hat)
2025-11-17 8:11 ` Baolin Wang
2025-11-17 17:25 ` Nico Pache [this message]
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='CAA1CXcATqLCv8k0OEoEcYy-=e1NevsjoebnefFbV1=yB-gyygA@mail.gmail.com' \
--to=npache@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=lance.yang@linux.dev \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=richard.weiyang@gmail.com \
--cc=rostedt@goodmis.org \
--cc=ryan.roberts@arm.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