Skip to content

Commit dbf85c2

Browse files
VMoolaakpm00
authored andcommitted
mm/khugepaged: convert is_refcount_suitable() to use folios
Both callers of is_refcount_suitable() have been converted to use folios, so convert it to take in a folio. Both callers only operate on head pages of folios so mapcount/refcount conversions here are trivial. Removes 3 calls to compound head, and removes 315 bytes of kernel text. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Vishal Moola (Oracle) <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Reviewed-by: Yang Shi <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5c07ebb commit dbf85c2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mm/khugepaged.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,15 @@ static void release_pte_pages(pte_t *pte, pte_t *_pte,
524524
}
525525
}
526526

527-
static bool is_refcount_suitable(struct page *page)
527+
static bool is_refcount_suitable(struct folio *folio)
528528
{
529529
int expected_refcount;
530530

531-
expected_refcount = total_mapcount(page);
532-
if (PageSwapCache(page))
533-
expected_refcount += compound_nr(page);
531+
expected_refcount = folio_mapcount(folio);
532+
if (folio_test_swapcache(folio))
533+
expected_refcount += folio_nr_pages(folio);
534534

535-
return page_count(page) == expected_refcount;
535+
return folio_ref_count(folio) == expected_refcount;
536536
}
537537

538538
static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
@@ -625,7 +625,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
625625
* but not from this process. The other process cannot write to
626626
* the page, only trigger CoW.
627627
*/
628-
if (!is_refcount_suitable(&folio->page)) {
628+
if (!is_refcount_suitable(folio)) {
629629
folio_unlock(folio);
630630
result = SCAN_PAGE_COUNT;
631631
goto out;
@@ -1371,7 +1371,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
13711371
* has excessive GUP pins (i.e. 512). Anyway the same check
13721372
* will be done again later the risk seems low.
13731373
*/
1374-
if (!is_refcount_suitable(&folio->page)) {
1374+
if (!is_refcount_suitable(folio)) {
13751375
result = SCAN_PAGE_COUNT;
13761376
goto out_unmap;
13771377
}

0 commit comments

Comments
 (0)