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 hugetlb_fault()

We can replace seven implicit calls to compound_head() with one by using
folio.

[akpm@linux-foundation.org: update comment, per Sidhartha]
Link: https://lkml.kernel.org/r/20230606062013.2947002-4-zhangpeng362@huawei.com
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Reviewed-by Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
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
061e62e8 959a78b6

+10 -10
+10 -10
mm/hugetlb.c
··· 6062 6062 vm_fault_t ret; 6063 6063 u32 hash; 6064 6064 pgoff_t idx; 6065 - struct page *page = NULL; 6065 + struct folio *folio = NULL; 6066 6066 struct folio *pagecache_folio = NULL; 6067 6067 struct hstate *h = hstate_vma(vma); 6068 6068 struct address_space *mapping; ··· 6179 6179 /* 6180 6180 * hugetlb_wp() requires page locks of pte_page(entry) and 6181 6181 * pagecache_folio, so here we need take the former one 6182 - * when page != pagecache_folio or !pagecache_folio. 6182 + * when folio != pagecache_folio or !pagecache_folio. 6183 6183 */ 6184 - page = pte_page(entry); 6185 - if (page_folio(page) != pagecache_folio) 6186 - if (!trylock_page(page)) { 6184 + folio = page_folio(pte_page(entry)); 6185 + if (folio != pagecache_folio) 6186 + if (!folio_trylock(folio)) { 6187 6187 need_wait_lock = 1; 6188 6188 goto out_ptl; 6189 6189 } 6190 6190 6191 - get_page(page); 6191 + folio_get(folio); 6192 6192 6193 6193 if (flags & (FAULT_FLAG_WRITE|FAULT_FLAG_UNSHARE)) { 6194 6194 if (!huge_pte_write(entry)) { ··· 6204 6204 flags & FAULT_FLAG_WRITE)) 6205 6205 update_mmu_cache(vma, haddr, ptep); 6206 6206 out_put_page: 6207 - if (page_folio(page) != pagecache_folio) 6208 - unlock_page(page); 6209 - put_page(page); 6207 + if (folio != pagecache_folio) 6208 + folio_unlock(folio); 6209 + folio_put(folio); 6210 6210 out_ptl: 6211 6211 spin_unlock(ptl); 6212 6212 ··· 6225 6225 * here without taking refcount. 6226 6226 */ 6227 6227 if (need_wait_lock) 6228 - wait_on_page_locked(page); 6228 + folio_wait_locked(folio); 6229 6229 return ret; 6230 6230 } 6231 6231