]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm: Use entire_mapcount in __page_dup_rmap()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 30 Dec 2022 20:16:03 +0000 (15:16 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 3 Jan 2023 04:00:55 +0000 (23:00 -0500)
Remove the use of the compound_mapcount_ptr() wrapper, and add an
assertion that we're not passing a tail page if we're duplicating a PMD.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/rmap.h

index aa682a2a93ce3b2f8d01a6cc125338fda833c496..a6bd1f0a183d91b2753fe08baf5b0f101c0dac78 100644 (file)
@@ -208,7 +208,14 @@ void hugepage_add_new_anon_rmap(struct page *, struct vm_area_struct *,
 
 static inline void __page_dup_rmap(struct page *page, bool compound)
 {
-       atomic_inc(compound ? compound_mapcount_ptr(page) : &page->_mapcount);
+       if (compound) {
+               struct folio *folio = (struct folio *)page;
+
+               VM_BUG_ON_PAGE(compound && !PageHead(page), page);
+               atomic_inc(&folio->_entire_mapcount);
+       } else {
+               atomic_inc(&page->_mapcount);
+       }
 }
 
 static inline void page_dup_file_rmap(struct page *page, bool compound)