Commit 96c772c2 authored by David Hildenbrand's avatar David Hildenbrand Committed by Andrew Morton

mm/huge_memory: page_try_dup_anon_rmap() -> folio_try_dup_anon_rmap_pmd()

Let's convert copy_huge_pmd() and fixup the comment in copy_huge_pud(). 
While at it, perform more folio conversion in copy_huge_pmd().

Link: https://lkml.kernel.org/r/20231220224504.646757-36-david@redhat.comSigned-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Yin Fengwei <fengwei.yin@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 61d90309
...@@ -1275,6 +1275,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, ...@@ -1275,6 +1275,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
{ {
spinlock_t *dst_ptl, *src_ptl; spinlock_t *dst_ptl, *src_ptl;
struct page *src_page; struct page *src_page;
struct folio *src_folio;
pmd_t pmd; pmd_t pmd;
pgtable_t pgtable = NULL; pgtable_t pgtable = NULL;
int ret = -ENOMEM; int ret = -ENOMEM;
...@@ -1341,11 +1342,12 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, ...@@ -1341,11 +1342,12 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
src_page = pmd_page(pmd); src_page = pmd_page(pmd);
VM_BUG_ON_PAGE(!PageHead(src_page), src_page); VM_BUG_ON_PAGE(!PageHead(src_page), src_page);
src_folio = page_folio(src_page);
get_page(src_page); folio_get(src_folio);
if (unlikely(page_try_dup_anon_rmap(src_page, true, src_vma))) { if (unlikely(folio_try_dup_anon_rmap_pmd(src_folio, src_page, src_vma))) {
/* Page maybe pinned: split and retry the fault on PTEs. */ /* Page maybe pinned: split and retry the fault on PTEs. */
put_page(src_page); folio_put(src_folio);
pte_free(dst_mm, pgtable); pte_free(dst_mm, pgtable);
spin_unlock(src_ptl); spin_unlock(src_ptl);
spin_unlock(dst_ptl); spin_unlock(dst_ptl);
...@@ -1454,8 +1456,8 @@ int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm, ...@@ -1454,8 +1456,8 @@ int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm,
} }
/* /*
* TODO: once we support anonymous pages, use page_try_dup_anon_rmap() * TODO: once we support anonymous pages, use
* and split if duplicating fails. * folio_try_dup_anon_rmap_*() and split if duplicating fails.
*/ */
pudp_set_wrprotect(src_mm, addr, src_pud); pudp_set_wrprotect(src_mm, addr, src_pud);
pud = pud_mkold(pud_wrprotect(pud)); pud = pud_mkold(pud_wrprotect(pud));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment