linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm page_fault: Reduce code complexity
@ 2020-05-28 11:01 hui yang
  2020-05-28 11:45 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: hui yang @ 2020-05-28 11:01 UTC (permalink / raw)
  To: willy; +Cc: akpm, linux-mm, YangHui

From: YangHui <yanghui.def@gmail.com>

if pte_alloc_one failed alloc a page, do_fault_around will return 0.
and it will come into __do_fault(), it also pte_alloc_one a page.
in __do_fault and do_fault_around, pte_alloc_one did the same thing,
if do_fault_around alloc page filed,we just let it return. there is
no need to come into __do_fault to do repetitive pte_alloc_one.

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

diff --git a/mm/memory.c b/mm/memory.c
index f703fe8..a2d50a9 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3799,8 +3799,10 @@ 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)
+		if (!vmf->prealloc_pte) {
+			ret = VM_FAULT_OOM;
 			goto out;
+		}
 		smp_wmb(); /* See comment in __pte_alloc() */
 	}
 
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm page_fault: Reduce code complexity
  2020-05-28 11:01 [PATCH] mm page_fault: Reduce code complexity hui yang
@ 2020-05-28 11:45 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2020-05-28 11:45 UTC (permalink / raw)
  To: hui yang; +Cc: akpm, linux-mm

On Thu, May 28, 2020 at 07:01:39PM +0800, hui yang wrote:
> From: YangHui <yanghui.def@gmail.com>
> 
> if pte_alloc_one failed alloc a page, do_fault_around will return 0.
> and it will come into __do_fault(), it also pte_alloc_one a page.
> in __do_fault and do_fault_around, pte_alloc_one did the same thing,
> if do_fault_around alloc page filed,we just let it return. there is
> no need to come into __do_fault to do repetitive pte_alloc_one.

This really isn't "Reduce code complexity" though.  It's "Fail early
when memory allocation fails".  And, honestly, I don't see the point
of doing this.  You've optimised an incredibly rare failure path.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-28 11:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 11:01 [PATCH] mm page_fault: Reduce code complexity hui yang
2020-05-28 11:45 ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).