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, "Liam R . Howlett" <liam@infradead.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Vlastimil Babka <vbabka@kernel.org>, Jann Horn <jannh@google.com>,
Pedro Falcato <pfalcato@suse.de>, Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb()
Date: Fri, 10 Jul 2026 14:17:43 +0200 [thread overview]
Message-ID: <8992ac30-340d-42c7-8799-2d797b92b59c@kernel.org> (raw)
In-Reply-To: <20260710120052.103886-5-wangkefeng.wang@huawei.com>
On 7/10/26 14:00, Kefeng Wang wrote:
> The walk_hugetlb_range() always passes a non-NULL pte, so remove the
> dead NULL check. Replace the per-page iteration loop with memset()
> for better performance.
>
> Reviewed-by: Pedro Falcato <pfalcato@suse.de>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> mm/mincore.c | 27 +++++++--------------------
> 1 file changed, 7 insertions(+), 20 deletions(-)
>
> diff --git a/mm/mincore.c b/mm/mincore.c
> index 8b5e6afefb91..9952bc3edf76 100644
> --- a/mm/mincore.c
> +++ b/mm/mincore.c
> @@ -28,30 +28,17 @@ static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr,
> unsigned long end, struct mm_walk *walk)
> {
> #ifdef CONFIG_HUGETLB_PAGE
> - unsigned char present;
> + unsigned long nr = (end - addr) >> PAGE_SHIFT;
> unsigned char *vec = walk->private;
> + unsigned char present;
> spinlock_t *ptl;
> + pte_t ptep;
>
> ptl = huge_pte_lock(hstate_vma(walk->vma), walk->mm, pte);
> -
> - /*
> - * Hugepages under user process are always in RAM and never
> - * swapped out, but theoretically it needs to be checked.
> - */
> - if (!pte) {
> - present = 0;
> - } else {
> - const pte_t ptep = huge_ptep_get(walk->mm, addr, pte);
> -
> - if (huge_pte_none(ptep) || pte_is_marker(ptep))
> - present = 0;
> - else
> - present = 1;
> - }
> -
> - for (; addr != end; vec++, addr += PAGE_SIZE)
> - *vec = present;
> - walk->private = vec;
> + ptep = huge_ptep_get(walk->mm, addr, pte);
> + present = !(huge_pte_none(ptep) || pte_is_marker(ptep));
Easier to read as
present = !huge_pte_none(ptep) && !pte_is_marker(ptep);
But now I wonder "why not pte_present()".
Calling this "present" is misleading. It's maybe "resident"?
I guess we want to indicate migration entries and hwpoison entries as "1".
--
Cheers,
David
next prev parent reply other threads:[~2026-07-10 12:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 12:00 [PATCH v2 0/5] mm: mincore: misc cleanups Kefeng Wang
2026-07-10 12:00 ` [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP Kefeng Wang
2026-07-10 12:07 ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc() Kefeng Wang
2026-07-10 12:09 ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 3/5] mm: mincore: remove xa_is_value() in mincore_swap() Kefeng Wang
2026-07-10 12:09 ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb() Kefeng Wang
2026-07-10 12:17 ` David Hildenbrand (Arm) [this message]
2026-07-10 12:00 ` [PATCH v2 5/5] mm: mincore: refactor mincore_page() Kefeng Wang
2026-07-10 12:19 ` David Hildenbrand (Arm)
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=8992ac30-340d-42c7-8799-2d797b92b59c@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=pfalcato@suse.de \
--cc=vbabka@kernel.org \
--cc=wangkefeng.wang@huawei.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