mirror of
https://github.com/torvalds/linux.git
synced 2026-09-12 20:53:03 +02:00
mm: mincore: improve mincore_hugetlb()
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. [wangkefeng.wang@huawei.com: fixup improve mincore_hugetlb()] Link: https://lore.kernel.org/20260720124252.1483984-1-wangkefeng.wang@huawei.com Link: https://lore.kernel.org/20260717091347.1144789-6-wangkefeng.wang@huawei.com Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Reviewed-by: Pedro Falcato <pfalcato@suse.de> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Cc: Jann Horn <jannh@google.com> Cc: Liam R. Howlett <liam@infradead.org> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Vlastimil Babka <vbabka@kernel.org> Cc: Zi Yan <ziy@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
9218800076
commit
751a1f061a
28
mm/mincore.c
28
mm/mincore.c
|
|
@ -28,30 +28,16 @@ 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 char *vec = walk->private;
|
||||
const unsigned long nr = (end - addr) >> PAGE_SHIFT;
|
||||
unsigned char resident;
|
||||
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);
|
||||
resident = !huge_pte_none(ptep) && !pte_is_marker(ptep);
|
||||
memset(walk->private, resident, nr);
|
||||
walk->private += nr;
|
||||
spin_unlock(ptl);
|
||||
#else
|
||||
BUG();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user