Skip to contentSkip to conversation

riscv/mm: Simplify retry logic in do_page_fault()

PATCH In review Pekka Enberg 2 participants 4 messages Aug 19, 2020 – Aug 21, 2020 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv/mm: Simplify retry logic in do_page_fault()

From: Pekka Enberg <[email protected]>

Let's combine the two retry logic if statements in do_page_fault() to simplify the code.

---
 arch/riscv/mm/fault.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
arch/riscv/mm/fault.c +9 -11
index 716d64e36f83..f5c2e4a249eb 100644
@@ -127,17 +127,15 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
 		BUG();
 	}
 
-	if (flags & FAULT_FLAG_ALLOW_RETRY) {
-		if (fault & VM_FAULT_RETRY) {
-			flags |= FAULT_FLAG_TRIED;
-
-			/*
-			 * No need to mmap_read_unlock(mm) as we would
-			 * have already released it in __lock_page_or_retry
-			 * in mm/filemap.c.
-			 */
-			goto retry;
-		}
+	if (unlikely((fault & VM_FAULT_RETRY) && (flags & FAULT_FLAG_ALLOW_RETRY))) {
+		flags |= FAULT_FLAG_TRIED;
+
+		/*
+		 * No need to mmap_read_unlock(mm) as we would
+		 * have already released it in __lock_page_or_retry
+		 * in mm/filemap.c.
+		 */
+		goto retry;
 	}
 
 	mmap_read_unlock(mm);
Signature · 7 lines
2.26.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · On Wed, 19 Aug 2020 07:10:11 PDT (-0700), [email protected] wrote:

From: Pekka Enberg <[email protected]>

Let's combine the two retry logic if statements in do_page_fault() to simplify the code.

---
 arch/riscv/mm/fault.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
arch/riscv/mm/fault.c +2 -11
index 716d64e36f83..f5c2e4a249eb 100644
@@ -127,17 +127,15 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
 		BUG();
 	}
 
-	if (flags & FAULT_FLAG_ALLOW_RETRY) {
-		if (fault & VM_FAULT_RETRY) {
-			flags |= FAULT_FLAG_TRIED;
-
-			/*
-			 * No need to mmap_read_unlock(mm) as we would
-			 * have already released it in __lock_page_or_retry
-			 * in mm/filemap.c.
-			 */
-			goto retry;
-		}
+	if (unlikely((fault & VM_FAULT_RETRY) && (flags & FAULT_FLAG_ALLOW_RETRY))) {
+		flags |= FAULT_FLAG_TRIED;

arch/riscv/mm/fault.c asmlinkage void do_page_fault(struct pt_regs *regs) · line 141

Quoted 10 lines
arch/riscv/mm/fault.c +7 -0
+
+		/*
+		 * No need to mmap_read_unlock(mm) as we would
+		 * have already released it in __lock_page_or_retry
+		 * in mm/filemap.c.
+		 */
+		goto retry;
 	}
 
 	mmap_read_unlock(mm);

This is missing your Signed-off-by, and while it's a bit pedantic I can't add it myself. Otherwise

Thanks!

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#2 lore raw
Quoted 40 lines · Palmer Dabbelt
Quoted 38 lines · On Wed, 19 Aug 2020 07:10:11 PDT (-0700), [email protected] wrote:

From: Pekka Enberg <[email protected]>

Let's combine the two retry logic if statements in do_page_fault() to simplify the code.

---
 arch/riscv/mm/fault.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
arch/riscv/mm/fault.c +9 -11
index 716d64e36f83..f5c2e4a249eb 100644
@@ -127,17 +127,15 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
              BUG();
      }
 
-     if (flags & FAULT_FLAG_ALLOW_RETRY) {
-             if (fault & VM_FAULT_RETRY) {
-                     flags |= FAULT_FLAG_TRIED;
-
-                     /*
-                      * No need to mmap_read_unlock(mm) as we would
-                      * have already released it in __lock_page_or_retry
-                      * in mm/filemap.c.
-                      */
-                     goto retry;
-             }
+     if (unlikely((fault & VM_FAULT_RETRY) && (flags & FAULT_FLAG_ALLOW_RETRY))) {
+             flags |= FAULT_FLAG_TRIED;
+
+             /*
+              * No need to mmap_read_unlock(mm) as we would
+              * have already released it in __lock_page_or_retry
+              * in mm/filemap.c.
+              */
+             goto retry;
      }
 
Quoted 8 lines

arch/riscv/mm/fault.c asmlinkage void do_page_fault(struct pt_regs *regs) · line 141

Quoted 1 line
arch/riscv/mm/fault.c +0 -0
      mmap_read_unlock(mm);

This is missing your Signed-off-by, and while it's a bit pedantic I can't add it myself. Otherwise

Thanks!

Oh, sorry about that. Here you go:

I can also resend the patch with a SOB if you so prefer.

- Pekka

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#3 lore raw
Quoted 48 lines · On Thu, 20 Aug 2020 21:06:34 PDT (-0700), [email protected] wrote:
Quoted 47 lines · Palmer Dabbelt
Quoted 29 lines · On Wed, 19 Aug 2020 07:10:11 PDT (-0700), [email protected] wrote:

From: Pekka Enberg <[email protected]>

Let's combine the two retry logic if statements in do_page_fault() to simplify the code.

---
 arch/riscv/mm/fault.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
arch/riscv/mm/fault.c +2 -11
index 716d64e36f83..f5c2e4a249eb 100644
@@ -127,17 +127,15 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
              BUG();
      }
 
-     if (flags & FAULT_FLAG_ALLOW_RETRY) {
-             if (fault & VM_FAULT_RETRY) {
-                     flags |= FAULT_FLAG_TRIED;
-
-                     /*
-                      * No need to mmap_read_unlock(mm) as we would
-                      * have already released it in __lock_page_or_retry
-                      * in mm/filemap.c.
-                      */
-                     goto retry;
-             }
+     if (unlikely((fault & VM_FAULT_RETRY) && (flags & FAULT_FLAG_ALLOW_RETRY))) {
+             flags |= FAULT_FLAG_TRIED;

arch/riscv/mm/fault.c asmlinkage void do_page_fault(struct pt_regs *regs) · line 141

Quoted 10 lines
arch/riscv/mm/fault.c +7 -0
+
+             /*
+              * No need to mmap_read_unlock(mm) as we would
+              * have already released it in __lock_page_or_retry
+              * in mm/filemap.c.
+              */
+             goto retry;
      }
 
      mmap_read_unlock(mm);

This is missing your Signed-off-by, and while it's a bit pedantic I can't add it myself. Otherwise

Quoted 7 lines
Quoted 1 line

Thanks!

Oh, sorry about that. Here you go:

I can also resend the patch with a SOB if you so prefer.

This is fine. It's on fixes, but unless something comes up I won't send it out until next week.

Thanks!

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv