Skip to contentSkip to conversation

mm/rmap: remove stale hugetlb check in try_to_unmap_one

PATCH Applied Dev Jain 5 participants 7 messages Aug 31 – Sep 7

Subsystems (2)
lore
Share & tools
lore

Dev Jain

author
#0 lore raw

PATCH 1/1 mm/rmap: remove stale hugetlb check in try_to_unmap_one

Post commit d4ec5572825a ("mm/rmap: add try_to_unmap_poisoned_hugetlb_one") try_to_unmap_one() cannot be called with a hugetlb folio. Therefore remove the folio_test_hugetlb() check.

---
Rebase soup - my huge_ptep_get() fixes landed after the refactoring.

This patch applies on Linux 7.3-rc1.

 mm/rmap.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/rmap.c +2 -5
index d1819fd699380..606c8ecf31302 100644
@@ -2299,11 +2299,8 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
 		VM_BUG_ON_FOLIO(!pvmw.pte, folio);
 
 		address = pvmw.address;
-		if (folio_test_hugetlb(folio)) {
-			pteval = huge_ptep_get(mm, address, pvmw.pte);
-		} else {
-			pteval = ptep_get(pvmw.pte);
-		}
+		pteval = ptep_get(pvmw.pte);
+
 		if (likely(pte_present(pteval))) {
 			pfn = pte_pfn(pteval);
 		} else {
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dev Jain

Post commit d4ec5572825a ("mm/rmap: add try_to_unmap_poisoned_hugetlb_one") try_to_unmap_one() cannot be called with a hugetlb folio. Therefore remove the folio_test_hugetlb() check.

LGTM so:

Quoted 27 lines

---
Rebase soup - my huge_ptep_get() fixes landed after the refactoring.

This patch applies on Linux 7.3-rc1.

 mm/rmap.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/rmap.c +2 -6
index d1819fd699380..606c8ecf31302 100644
@@ -2299,11 +2299,8 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
 		VM_BUG_ON_FOLIO(!pvmw.pte, folio);
 
 		address = pvmw.address;
-		if (folio_test_hugetlb(folio)) {
-			pteval = huge_ptep_get(mm, address, pvmw.pte);
-		} else {
-			pteval = ptep_get(pvmw.pte);
-		}
+		pteval = ptep_get(pvmw.pte);
+
 		if (likely(pte_present(pteval))) {
 			pfn = pte_pfn(pteval);
 		} else {
--
Quoted 2 lines

2.43.0

--
Cheers, Lorenzo

Reviewed-by on v1 1/1
#3 lore raw
In reply to Dev Jain
Quoted 3 lines · On Mon, 31 Aug 2026 08:28:47 +0000 Dev Jain <[email protected]> wrote:

Post commit d4ec5572825a ("mm/rmap: add try_to_unmap_poisoned_hugetlb_one") try_to_unmap_one() cannot be called with a hugetlb folio. Therefore remove the folio_test_hugetlb() check.

Yes, the d4ec5572825 change shows that try_to_unmap() dispatches hugetlb folios to try_to_unmap_poisoned_hugetlb_one(), so try_to_unmap_one() cannot be called with a hugetlb folio.

It would be better to add:

Fixes d4ec5572825 ("mm/rmap: add try_to_unmap_poisoned_hugetlb_one")

Thanks,
KunWu

Quoted 32 lines

---
Rebase soup - my huge_ptep_get() fixes landed after the refactoring.

This patch applies on Linux 7.3-rc1.

 mm/rmap.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/rmap.c +2 -5
index d1819fd699380..606c8ecf31302 100644
@@ -2299,11 +2299,8 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
 		VM_BUG_ON_FOLIO(!pvmw.pte, folio);
 
 		address = pvmw.address;
-		if (folio_test_hugetlb(folio)) {
-			pteval = huge_ptep_get(mm, address, pvmw.pte);
-		} else {
-			pteval = ptep_get(pvmw.pte);
-		}
+		pteval = ptep_get(pvmw.pte);
+
 		if (likely(pte_present(pteval))) {
 			pfn = pte_pfn(pteval);
 		} else {
Signature · 1 line
2.43.0
#4 lore raw
Quoted 6 lines · Kunwu Chan
Quoted 3 lines · On Mon, 31 Aug 2026 08:28:47 +0000 Dev Jain <[email protected]> wrote:

Post commit d4ec5572825a ("mm/rmap: add try_to_unmap_poisoned_hugetlb_one") try_to_unmap_one() cannot be called with a hugetlb folio. Therefore remove the folio_test_hugetlb() check.

Quoted 7 lines

Yes, the d4ec5572825 change shows that try_to_unmap() dispatches hugetlb folios to try_to_unmap_poisoned_hugetlb_one(), so try_to_unmap_one() cannot be called with a hugetlb folio.

It would be better to add:

Fixes d4ec5572825 ("mm/rmap: add try_to_unmap_poisoned_hugetlb_one")

Nope, let's not thanks.

This isn't a bug.

Quoted 23 lines

Thanks,
KunWu

Quoted 17 lines

---
Rebase soup - my huge_ptep_get() fixes landed after the refactoring.

This patch applies on Linux 7.3-rc1.

 mm/rmap.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/rmap.c +0 -0
index d1819fd699380..606c8ecf31302 100644
@@ -2299,11 +2299,8 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
 		VM_BUG_ON_FOLIO(!pvmw.pte, folio);
 
Quoted 16 lines
Quoted 12 lines
mm/rmap.c +2 -6
 		address = pvmw.address;
-		if (folio_test_hugetlb(folio)) {
-			pteval = huge_ptep_get(mm, address, pvmw.pte);
-		} else {
-			pteval = ptep_get(pvmw.pte);
-		}
+		pteval = ptep_get(pvmw.pte);
+
 		if (likely(pte_present(pteval))) {
 			pfn = pte_pfn(pteval);
 		} else {
--
Quoted 3 lines

2.43.0

--
Cheers, Lorenzo

#5 lore raw
Quoted 12 lines · On Mon, 31 Aug 2026 17:00:56 +0100 "Lorenzo Stoakes (ARM)" <[email protected]>…
Quoted 11 lines · Kunwu Chan
Quoted 3 lines · On Mon, 31 Aug 2026 08:28:47 +0000 Dev Jain <[email protected]> wrote:

Post commit d4ec5572825a ("mm/rmap: add try_to_unmap_poisoned_hugetlb_one") try_to_unmap_one() cannot be called with a hugetlb folio. Therefore remove the folio_test_hugetlb() check.

Yes, the d4ec5572825 change shows that try_to_unmap() dispatches hugetlb folios to try_to_unmap_poisoned_hugetlb_one(), so try_to_unmap_one() cannot be called with a hugetlb folio.

Quoted 7 lines
Quoted 2 lines

It would be better to add:

Fixes d4ec5572825 ("mm/rmap: add try_to_unmap_poisoned_hugetlb_one")

Nope, let's not thanks.

This isn't a bug.

Got it, thanks for pointing that out.
I mistakenly treated the stale code as a bug.

Thanks,
KunWu

Quoted 43 lines
Quoted 23 lines

Thanks,
KunWu

Quoted 17 lines

---
Rebase soup - my huge_ptep_get() fixes landed after the refactoring.

This patch applies on Linux 7.3-rc1.

 mm/rmap.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mm/rmap.c +0 -0
index d1819fd699380..606c8ecf31302 100644
@@ -2299,11 +2299,8 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
 		VM_BUG_ON_FOLIO(!pvmw.pte, folio);
 
Quoted 16 lines
Quoted 12 lines
mm/rmap.c +2 -6
 		address = pvmw.address;
-		if (folio_test_hugetlb(folio)) {
-			pteval = huge_ptep_get(mm, address, pvmw.pte);
-		} else {
-			pteval = ptep_get(pvmw.pte);
-		}
+		pteval = ptep_get(pvmw.pte);
+
 		if (likely(pte_present(pteval))) {
 			pfn = pte_pfn(pteval);
 		} else {
--
Quoted 3 lines

2.43.0

--
Cheers, Lorenzo

maintainer Acked-by on v1 1/1
#6 lore raw
In reply to Dev Jain
Quoted 9 lines · Dev Jain

Post commit d4ec5572825a ("mm/rmap: add try_to_unmap_poisoned_hugetlb_one") try_to_unmap_one() cannot be called with a hugetlb folio. Therefore remove the folio_test_hugetlb() check.

---
Rebase soup - my huge_ptep_get() fixes landed after the refactoring.

This patch applies on Linux 7.3-rc1.

Thanks!

Signature · 3 lines
Cheers,

David