diff mbox series

[26/26] mm page_fault: Reduce code complexity

Message ID 1590575610-4546-1-git-send-email-yanghui.def@gmail.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

hui yang May 27, 2020, 10:33 a.m. UTC
From: YangHui <yanghui.def@gmail.com>

if pte_alloc_one fail alloc a page, do_fault_around will return 0.
and in do_read_fault()->__do_fault(), it also pte_alloc_one a page.
if pte_alloc_one failed to alloc a page,it will return VM_FAULT_OOM.
To reduce code complexity,if alloc failed we return VM_FAULT_OOM.

Signed-off-by: YangHui <yanghui.def@gmail.com>
---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matthew Wilcox May 27, 2020, 5:13 p.m. UTC | #1
On Wed, May 27, 2020 at 06:33:30PM +0800, hui yang wrote:
> if pte_alloc_one fail alloc a page, do_fault_around will return 0.
> and in do_read_fault()->__do_fault(), it also pte_alloc_one a page.
> if pte_alloc_one failed to alloc a page,it will return VM_FAULT_OOM.
> To reduce code complexity,if alloc failed we return VM_FAULT_OOM.

This doesn't reduce code complexity at all.  You've made this error
different from every other error handled by this function because now
it returns directly instead of jumping to 'out:'.  I can't understand
your explanation, and at first glance I'm not even sure this patch is
correct.  Definitely not a simplification, so NAK with this justification.
The patch might be correct, but it'll need a lot better prose than this.
diff mbox series

Patch

diff --git a/mm/memory.c b/mm/memory.c
index f703fe8..b104879 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3800,7 +3800,7 @@  static vm_fault_t do_fault_around(struct vm_fault *vmf)
 	if (pmd_none(*vmf->pmd)) {
 		vmf->prealloc_pte = pte_alloc_one(vmf->vma->vm_mm);
 		if (!vmf->prealloc_pte)
-			goto out;
+			return VM_FAULT_OOM;
 		smp_wmb(); /* See comment in __pte_alloc() */
 	}