Skip to contentSkip to conversation

mm: teach mincore_hugetlb about pte markers

PATCH Applied James Houghton 4 participants 4 messages Mar 2, 2023 – Mar 3, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: teach mincore_hugetlb about pte markers

By checking huge_pte_none(), we incorrectly classify PTE markers as "present". Instead, check huge_pte_none_mostly(), classifying PTE markers the same as if the PTE were completely blank.

PTE markers, unlike other kinds of swap entries, don't reference any physical page and don't indicate that a physical page was mapped previously. As such, treat them as non-present for the sake of mincore().

Fixes 5c041f5d1f23 ("mm: teach core mm about pte markers")
---
 mm/mincore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mincore.c +1 -1
index cd69b9db0081..d359650b0f75 100644
@@ -33,7 +33,7 @@ static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr,
 	 * Hugepages under user process are always in RAM and never
 	 * swapped out, but theoretically it needs to be checked.
 	 */
-	present = pte && !huge_pte_none(huge_ptep_get(pte));
+	present = pte && !huge_pte_none_mostly(huge_ptep_get(pte));
 	for (; addr != end; vec++, addr += PAGE_SIZE)
 		*vec = present;
 	walk->private = vec;
Signature · 1 line
2.40.0.rc0.216.gc4246ad0f0-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · James Houghton

By checking huge_pte_none(), we incorrectly classify PTE markers as "present". Instead, check huge_pte_none_mostly(), classifying PTE markers the same as if the PTE were completely blank.

PTE markers, unlike other kinds of swap entries, don't reference any physical page and don't indicate that a physical page was mapped previously. As such, treat them as non-present for the sake of mincore().

Fixes 5c041f5d1f23 ("mm: teach core mm about pte markers")

Thanks, James.

Signature · 1 line
Peter Xu
maintainer
#2 lore raw
Quoted 10 lines · On Thu, 2 Mar 2023 17:32:48 -0500 Peter Xu <[email protected]> wrote:
Quoted 9 lines · James Houghton

By checking huge_pte_none(), we incorrectly classify PTE markers as "present". Instead, check huge_pte_none_mostly(), classifying PTE markers the same as if the PTE were completely blank.

PTE markers, unlike other kinds of swap entries, don't reference any physical page and don't indicate that a physical page was mapped previously. As such, treat them as non-present for the sake of mincore().

Quoted 5 lines
Quoted 2 lines
Fixes 5c041f5d1f23 ("mm: teach core mm about pte markers")

I think I'll add cc:stable to this.

Acked-by on v1 1/1
#3 lore raw
In reply to James Houghton
Quoted 20 lines · James Houghton

By checking huge_pte_none(), we incorrectly classify PTE markers as "present". Instead, check huge_pte_none_mostly(), classifying PTE markers the same as if the PTE were completely blank.

PTE markers, unlike other kinds of swap entries, don't reference any physical page and don't indicate that a physical page was mapped previously. As such, treat them as non-present for the sake of mincore().

Fixes 5c041f5d1f23 ("mm: teach core mm about pte markers")
---
  mm/mincore.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/mincore.c +0 -0
index cd69b9db0081..d359650b0f75 100644

mm/mincore.c static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr, · line 39

Quoted 8 lines
mm/mincore.c +1 -1
@@ -33,7 +33,7 @@ static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr,
  	 * Hugepages under user process are always in RAM and never
  	 * swapped out, but theoretically it needs to be checked.
  	 */
-	present = pte && !huge_pte_none(huge_ptep_get(pte));
+	present = pte && !huge_pte_none_mostly(huge_ptep_get(pte));
  	for (; addr != end; vec++, addr += PAGE_SIZE)
  		*vec = present;
  	walk->private = vec;
Signature · 3 lines
Thanks,

David / dhildenb