mm/memory.c: skip spurious TLB flush for retried page fault
Subsystems (3)
PATCH v3 1/1 mm/memory.c: skip spurious TLB flush for retried page fault
Recently we found regression when running will_it_scale/page_fault3 test on ARM64. Over 70% down for the multi processes cases and over 20% down for the multi threads cases. It turns out the regression is caused by commit 89b15332af7c0312a41e50846819ca6613b58b4c ("mm: drop mmap_sem before calling balance_dirty_pages() in write fault").
The test mmaps a memory size file then write to the mapping, this would make all memory dirty and trigger dirty pages throttle, that upstream commit would release mmap_sem then retry the page fault. The retried page fault would see correct PTEs installed then just fall through to spurious TLB flush. The regression is caused by the excessive spurious TLB flush. It is fine on x86 since x86's spurious TLB flush is no-op.
We could just skip the spurious TLB flush to mitigate the regression.
---
v3: Incorporated Linus's suggestion
v2: Incorporated Will Deacon's suggestion
mm/memory.c | 3 +++ 1 file changed, 3 insertions(+)
mm/memory.c +3 -0
@@ -4247,6 +4247,9 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf) vmf->flags & FAULT_FLAG_WRITE)) { update_mmu_cache(vmf->vma, vmf->address, vmf->pte); } else { +/* Skip spurious TLB flush for retried page fault */ +if (vmf->flags &FAULT_FLAG_TRIED ) + goto unlock;/* * This is needed only for protection faults but the arch code * is not yet telling us if this is a protection fault or not.
Signature · 1 line
2.26.2
Quoted 2 lines · Yang Shi
We could just skip the spurious TLB flush to mitigate the regression.
Ok, this patch I will apply.
I still hope that arm64 fixes (maybe already fixed) their spurious TLB function, and I think we should rename it to make sure everybody understands it's local, but in the meantime this patch hides the regression and isn't wrong.
Thanks,
Linus
Quoted 5 lines · Linus Torvalds
Quoted 2 lines · Yang Shi
We could just skip the spurious TLB flush to mitigate the regression.
Ok, this patch I will apply.
Cheers.
Quoted 4 lines
I still hope that arm64 fixes (maybe already fixed) their spurious TLB function, and I think we should rename it to make sure everybody understands it's local, but in the meantime this patch hides the regression and isn't wrong.
I'll look at it for 5.10.
Will