Skip to contentSkip to conversation

mm, thp: fix leaking mapped pte in __collapse_huge_page_swapin()

PATCH Applied Ebru Akagunduz 3 participants 3 messages Sep 2, 2016 – Sep 7, 2016

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

PATCH 1/1 mm, thp: fix leaking mapped pte in __collapse_huge_page_swapin()

Currently, khugepaged does not let swapin, if there is no enough young pages in a THP. The problem is when a THP does not have enough young page, khugepaged leaks mapped ptes.

This patch prohibits leaking mapped ptes.

---
 mm/khugepaged.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
mm/khugepaged.c +5 -5
index 79c52d0..f401e9d 100644
@@ -881,6 +881,11 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
 		.pmd = pmd,
 	};
 
+	/* we only decide to swapin, if there is enough young ptes */
+	if (referenced < HPAGE_PMD_NR/2) {
+		trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0);
+		return false;
+	}
 	fe.pte = pte_offset_map(pmd, address);
 	for (; fe.address < address + HPAGE_PMD_NR*PAGE_SIZE;
 			fe.pte++, fe.address += PAGE_SIZE) {
@@ -888,11 +893,6 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
 		if (!is_swap_pte(pteval))
 			continue;
 		swapped_in++;
-		/* we only decide to swapin, if there is enough young ptes */
-		if (referenced < HPAGE_PMD_NR/2) {
-			trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0);
-			return false;
-		}
 		ret = do_swap_page(&fe, pteval);
 
 		/* do_swap_page returns VM_FAULT_RETRY with released mmap_sem */
Signature · 7 lines
1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ebru Akagunduz

Currently, khugepaged does not let swapin, if there is no enough young pages in a THP. The problem is when a THP does not have enough young page, khugepaged leaks mapped ptes.

This patch prohibits leaking mapped ptes.

Signature · 1 line
All Rights Reversed.
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ebru Akagunduz
Quoted 11 lines · Ebru Akagunduz

Currently, khugepaged does not let swapin, if there is no enough young pages in a THP. The problem is when a THP does not have enough young page, khugepaged leaks mapped ptes.

This patch prohibits leaking mapped ptes.

---
 mm/khugepaged.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)