__remove_mapping() assumes that pages can only be either base pages or HPAGE_PMD_SIZE. Ask the page what size it is.
Unified · Split
| @@ -933,10 +933,7 @@ static int __remove_mapping(struct address_space *mapping, struct page *page, · 932 unmodified lines | ||
| 933 | 933 | * Note that if SetPageDirty is always performed via set_page_dirty, |
| 934 | 934 | * and thus under the i_pages lock, then this ordering is not required. |
| 935 | 935 | */ |
| 936 | − if (unlikely(PageTransHuge(page)) && PageSwapCache(page)) | |
| 937 | − refcount = 1 + HPAGE_PMD_NR; | |
| 938 | − else | |
| 939 | − refcount = 2; | |
| 936 | + refcount = 1 + compound_nr(page); | |
| 940 | 937 | if (!page_ref_freeze(page, refcount)) |
| 941 | 938 | goto cannot_free; |
| 942 | 939 | /* note: atomic_cmpxchg in page_ref_freeze provides the smp_rmb */ |