can_split_folio() is just a refcount comparison, making sure only the split caller holds an extra pin. Open code it with folio_expected_ref_count() != folio_ref_count() - 1. For the extra_pins used by folio_ref_freeze(), add folio_cache_ref_count() to calculate it. Also replace folio_expected_ref_count() with folio_cache_ref_count() used by folio_ref_unfreeze(), since they are returning the same values when a folio is frozen and folio_cache_ref_count() does not have unnecessary folio_mapcount() in its implementation.
Showing the changes to include/linux (1 of 3 files). Show all
Unified · Split
| @@ -369,7 +369,6 @@ enum split_type { · 368 unmodified lines | |||
| 369 | SPLIT_TYPE_NON_UNIFORM, | 369 | SPLIT_TYPE_NON_UNIFORM, |
| 370 | }; | 370 | }; |
| 371 | 371 | ||
| 372 | bool can_split_folio(struct folio *folio, int caller_pins, int *pextra_pins); | ||
| 373 | int __split_huge_page_to_list_to_order(struct page *page, struct list_head *list, | 372 | int __split_huge_page_to_list_to_order(struct page *page, struct list_head *list, |
| 374 | unsigned int new_order); | 373 | unsigned int new_order); |
| 375 | int folio_split_unmapped(struct folio *folio, unsigned int new_order); | 374 | int folio_split_unmapped(struct folio *folio, unsigned int new_order); |