Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/hugetlb: use a folio in copy_hugetlb_page_range()

Patch series "Convert several functions in hugetlb.c to use a folio", v2.

This patch series converts three functions in hugetlb.c to use a folio,
which can remove several implicit calls to compound_head().


This patch (of 3):

We can replace five implict calls to compound_head() with one by using
pte_folio. The page we get back is always a head page, so we just convert
ptepage to pte_folio.

Link: https://lkml.kernel.org/r/20230606062013.2947002-1-zhangpeng362@huawei.com
Link: https://lkml.kernel.org/r/20230606062013.2947002-2-zhangpeng362@huawei.com
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Nanyong Sun <sunnanyong@huawei.com>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

ZhangPeng and committed by
Andrew Morton
ad27ce20 9fc96c7c

+11 -11
+11 -11
mm/hugetlb.c
··· 5016 5016 struct vm_area_struct *src_vma) 5017 5017 { 5018 5018 pte_t *src_pte, *dst_pte, entry; 5019 - struct page *ptepage; 5019 + struct folio *pte_folio; 5020 5020 unsigned long addr; 5021 5021 bool cow = is_cow_mapping(src_vma->vm_flags); 5022 5022 struct hstate *h = hstate_vma(src_vma); ··· 5115 5115 set_huge_pte_at(dst, addr, dst_pte, entry); 5116 5116 } else { 5117 5117 entry = huge_ptep_get(src_pte); 5118 - ptepage = pte_page(entry); 5119 - get_page(ptepage); 5118 + pte_folio = page_folio(pte_page(entry)); 5119 + folio_get(pte_folio); 5120 5120 5121 5121 /* 5122 5122 * Failing to duplicate the anon rmap is a rare case ··· 5128 5128 * need to be without the pgtable locks since we could 5129 5129 * sleep during the process. 5130 5130 */ 5131 - if (!PageAnon(ptepage)) { 5132 - page_dup_file_rmap(ptepage, true); 5133 - } else if (page_try_dup_anon_rmap(ptepage, true, 5134 - src_vma)) { 5131 + if (!folio_test_anon(pte_folio)) { 5132 + page_dup_file_rmap(&pte_folio->page, true); 5133 + } else if (page_try_dup_anon_rmap(&pte_folio->page, 5134 + true, src_vma)) { 5135 5135 pte_t src_pte_old = entry; 5136 5136 struct folio *new_folio; 5137 5137 ··· 5140 5140 /* Do not use reserve as it's private owned */ 5141 5141 new_folio = alloc_hugetlb_folio(dst_vma, addr, 1); 5142 5142 if (IS_ERR(new_folio)) { 5143 - put_page(ptepage); 5143 + folio_put(pte_folio); 5144 5144 ret = PTR_ERR(new_folio); 5145 5145 break; 5146 5146 } 5147 5147 ret = copy_user_large_folio(new_folio, 5148 - page_folio(ptepage), 5149 - addr, dst_vma); 5150 - put_page(ptepage); 5148 + pte_folio, 5149 + addr, dst_vma); 5150 + folio_put(pte_folio); 5151 5151 if (ret) { 5152 5152 folio_put(new_folio); 5153 5153 break;