[PATCH 2/2] riscv: Drop mmap lock for page fault accounting

Pekka Enberg penberg at kernel.org
Sun Jun 28 10:30:13 EDT 2020


There's no need to hold on to the mmap lock while doing page fault
accounting in do_page_fault().

Signed-off-by: Pekka Enberg <penberg at kernel.org>
---
 arch/riscv/mm/fault.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 26f51cf99542..6256f25027af 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -133,6 +133,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
 		goto retry;
 	}
 
+	mmap_read_unlock(mm);
+
 	if (unlikely(fault & VM_FAULT_ERROR)) {
 		if (fault & VM_FAULT_OOM)
 			goto out_of_memory;
@@ -154,7 +156,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
 		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, addr);
 	}
 
-	mmap_read_unlock(mm);
 	return;
 
 	/*
@@ -190,14 +191,12 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
 	 * (which will retry the fault, or kill us if we got oom-killed).
 	 */
 out_of_memory:
-	mmap_read_unlock(mm);
 	if (!user_mode(regs))
 		goto no_context;
 	pagefault_out_of_memory();
 	return;
 
 do_sigbus:
-	mmap_read_unlock(mm);
 	/* Kernel mode? Handle exceptions or die */
 	if (!user_mode(regs))
 		goto no_context;
-- 
2.25.0




More information about the linux-riscv mailing list