Re: [PATCH v2 4/4] mm/memory: convert do_read_fault() to use folios

From: Matthew Wilcox
Date: Wed Jul 05 2023 - 16:19:09 EST


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@xxxxxxxxxx>

Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>

> @@ -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;