Skip to contentSkip to conversation

mm: hugetlb: fix __unmap_hugepage_range

RFC PATCH In review Hillf Danton 3 participants 3 messages Oct 31, 2014 – Nov 3, 2014

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

RFC PATCH 1/1 mm: hugetlb: fix __unmap_hugepage_range

First, after flushing TLB, we have no need to scan pte from start again. Second, before bail out loop, the address is forwarded one step.

---

mm/hugetlb.c +3 -1
@@ -2641,8 +2641,9 @@ void __unmap_hugepage_range(struct mmu_g
 
 	tlb_start_vma(tlb, vma);
 	mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
+	address = start;
 again:
-	for (address = start; address < end; address += sz) {
+	for (; address < end; address += sz) {
 		ptep = huge_pte_offset(mm, address);
 		if (!ptep)
 			continue;
@@ -2689,6 +2690,7 @@ again:
 		page_remove_rmap(page);
 		force_flush = !__tlb_remove_page(tlb, page);
 		if (force_flush) {
+			address += sz;
 			spin_unlock(ptl);
 			break;
 		}

--

--
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

[CCing people involved in 24669e58477e2]

Quoted 2 lines · Hillf Danton

First, after flushing TLB, we have no need to scan pte from start again. Second, before bail out loop, the address is forwarded one step.

I can imagine a more comprehensive wording here. It is not immediately clear whether this is just an optimization or a bug fix as well (especially the second part).

Anyway the optimization looks good to me.

Quoted 1 line
Quoted 26 lines

---

mm/hugetlb.c +3 -2
@@ -2641,8 +2641,9 @@ void __unmap_hugepage_range(struct mmu_g
 
 	tlb_start_vma(tlb, vma);
 	mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
+	address = start;
 again:
-	for (address = start; address < end; address += sz) {
+	for (; address < end; address += sz) {
 		ptep = huge_pte_offset(mm, address);
 		if (!ptep)
 			continue;
@@ -2689,6 +2690,7 @@ again:
 		page_remove_rmap(page);
 		force_flush = !__tlb_remove_page(tlb, page);
 		if (force_flush) {
+			address += sz;
 			spin_unlock(ptl);
 			break;
 		}
--
Signature · 8 lines
Michal Hocko
SUSE Labs

--
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>
Acked-by on v1 1/1
#2 lore raw
In reply to Hillf Danton
Quoted 4 lines · Hillf Danton

First, after flushing TLB, we have no need to scan pte from start again. Second, before bail out loop, the address is forwarded one step.

--
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>