Skip to content

Commit 6f609b7

Browse files
sidkumar99akpm00
authored andcommitted
mm/memory: convert do_shared_fault() to folios
Saves three implicit calls to compound_head(). Link: https://lkml.kernel.org/r/20230706163847.403202-3-sidhartha.kumar@oracle.com Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: ZhangPeng <zhangpeng362@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 5a97858 commit 6f609b7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

mm/memory.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4602,30 +4602,33 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf)
46024602
{
46034603
struct vm_area_struct *vma = vmf->vma;
46044604
vm_fault_t ret, tmp;
4605+
struct folio *folio;
46054606

46064607
ret = __do_fault(vmf);
46074608
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))
46084609
return ret;
46094610

4611+
folio = page_folio(vmf->page);
4612+
46104613
/*
46114614
* Check if the backing address space wants to know that the page is
46124615
* about to become writable
46134616
*/
46144617
if (vma->vm_ops->page_mkwrite) {
4615-
unlock_page(vmf->page);
4618+
folio_unlock(folio);
46164619
tmp = do_page_mkwrite(vmf);
46174620
if (unlikely(!tmp ||
46184621
(tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) {
4619-
put_page(vmf->page);
4622+
folio_put(folio);
46204623
return tmp;
46214624
}
46224625
}
46234626

46244627
ret |= finish_fault(vmf);
46254628
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE |
46264629
VM_FAULT_RETRY))) {
4627-
unlock_page(vmf->page);
4628-
put_page(vmf->page);
4630+
folio_unlock(folio);
4631+
folio_put(folio);
46294632
return ret;
46304633
}
46314634

0 commit comments

Comments
 (0)