Message ID | 20230705194335.273790-4-sidhartha.kumar@oracle.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2,1/4] mm/memory: convert do_page_mkwrite() to use folios | expand |
On Wed, Jul 05, 2023 at 12:43:35PM -0700, Sidhartha Kumar wrote: > Saves one implicit call to compound_head() > > Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> > @@ -4543,10 +4544,12 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf) > if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) > return ret; > > + folio = page_folio(vmf->page); Why not move this down to after the call to finish_fault()? The compiler should be able to do a better job with that; it may have to spill it to the stack to preserve it over the function call. > ret |= finish_fault(vmf); > - unlock_page(vmf->page); > + folio_unlock(folio); > if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) > - put_page(vmf->page); > + folio_put(folio); > return ret;
On 7/5/23 1:19 PM, Matthew Wilcox wrote: > On Wed, Jul 05, 2023 at 12:43:35PM -0700, Sidhartha Kumar wrote: >> Saves one implicit call to compound_head() >> >> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> > > Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> > >> @@ -4543,10 +4544,12 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf) >> if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) >> return ret; >> >> + folio = page_folio(vmf->page); > > Why not move this down to after the call to finish_fault()? The > compiler should be able to do a better job with that; it may have to > spill it to the stack to preserve it over the function call. > I just noticed that the page inside the vmf was being used in finish_fault() so it would stable enough to do the folio conversion before. I can move it after for compiler reasons. >> ret |= finish_fault(vmf); >> - unlock_page(vmf->page); >> + folio_unlock(folio); >> if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) >> - put_page(vmf->page); >> + folio_put(folio); >> return ret; > >
diff --git a/mm/memory.c b/mm/memory.c index ce7826d3f6200..e40a03e488ca2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4527,6 +4527,7 @@ static inline bool should_fault_around(struct vm_fault *vmf) static vm_fault_t do_read_fault(struct vm_fault *vmf) { vm_fault_t ret = 0; + struct folio *folio; /* * Let's call ->map_pages() first and use ->fault() as fallback @@ -4543,10 +4544,12 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf) if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) return ret; + folio = page_folio(vmf->page); + ret |= finish_fault(vmf); - unlock_page(vmf->page); + folio_unlock(folio); if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) - put_page(vmf->page); + folio_put(folio); return ret; }
Saves one implicit call to compound_head() Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> --- v2 - move folio initialization after __do_fault() mm/memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)