Skip to content

Commit

Permalink
mm/memory: convert do_shared_fault() to folios
Browse files Browse the repository at this point in the history
Saves three implicit calls to compound_head().

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Sidhartha Kumar <[email protected]>
Reviewed-by: Matthew Wilcox (Oracle) <[email protected]>
Reviewed-by: ZhangPeng <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
sidkumar99 authored and akpm00 committed Aug 18, 2023
1 parent 5a97858 commit 6f609b7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -4602,30 +4602,33 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
vm_fault_t ret, tmp;
struct folio *folio;

ret = __do_fault(vmf);
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))
return ret;

folio = page_folio(vmf->page);

/*
* Check if the backing address space wants to know that the page is
* about to become writable
*/
if (vma->vm_ops->page_mkwrite) {
unlock_page(vmf->page);
folio_unlock(folio);
tmp = do_page_mkwrite(vmf);
if (unlikely(!tmp ||
(tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) {
put_page(vmf->page);
folio_put(folio);
return tmp;
}
}

ret |= finish_fault(vmf);
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE |
VM_FAULT_RETRY))) {
unlock_page(vmf->page);
put_page(vmf->page);
folio_unlock(folio);
folio_put(folio);
return ret;
}

Expand Down

0 comments on commit 6f609b7

Please sign in to comment.