Skip to contentSkip to conversation

mm page_fault: Reduce code complexity

PATCH In review hui yang 2 participants 2 messages May 27, 2020

Subsystems (2)
lore
Share & tools
lore

hui yang

author
#0 lore raw

PATCH 26/26 mm page_fault: Reduce code complexity

From: YangHui <[email protected]>

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.

---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -1
index f703fe8..b104879 100644
@@ -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() */
 	}
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines · hui yang

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.