Skip to content

Commit d4b4084

Browse files
author
Matthew Wilcox (Oracle)
committed
mm: Turn can_split_huge_page() into can_split_folio()
This function already required a head page to be passed, so this just adds type-safety and removes a few implicit calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
1 parent e0cd5e7 commit d4b4084

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

include/linux/huge_mm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void prep_transhuge_page(struct page *page);
185185
void free_transhuge_page(struct page *page);
186186
bool is_transparent_hugepage(struct page *page);
187187

188-
bool can_split_huge_page(struct page *page, int *pextra_pins);
188+
bool can_split_folio(struct folio *folio, int *pextra_pins);
189189
int split_huge_page_to_list(struct page *page, struct list_head *list);
190190
static inline int split_huge_page(struct page *page)
191191
{
@@ -387,7 +387,7 @@ static inline bool is_transparent_hugepage(struct page *page)
387387
#define thp_get_unmapped_area NULL
388388

389389
static inline bool
390-
can_split_huge_page(struct page *page, int *pextra_pins)
390+
can_split_folio(struct folio *folio, int *pextra_pins)
391391
{
392392
BUILD_BUG();
393393
return false;

mm/huge_memory.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,18 +2516,19 @@ int page_trans_huge_mapcount(struct page *page)
25162516
}
25172517

25182518
/* Racy check whether the huge page can be split */
2519-
bool can_split_huge_page(struct page *page, int *pextra_pins)
2519+
bool can_split_folio(struct folio *folio, int *pextra_pins)
25202520
{
25212521
int extra_pins;
25222522

25232523
/* Additional pins from page cache */
2524-
if (PageAnon(page))
2525-
extra_pins = PageSwapCache(page) ? thp_nr_pages(page) : 0;
2524+
if (folio_test_anon(folio))
2525+
extra_pins = folio_test_swapcache(folio) ?
2526+
folio_nr_pages(folio) : 0;
25262527
else
2527-
extra_pins = thp_nr_pages(page);
2528+
extra_pins = folio_nr_pages(folio);
25282529
if (pextra_pins)
25292530
*pextra_pins = extra_pins;
2530-
return total_mapcount(page) == page_count(page) - extra_pins - 1;
2531+
return folio_mapcount(folio) == folio_ref_count(folio) - extra_pins - 1;
25312532
}
25322533

25332534
/*
@@ -2619,7 +2620,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)
26192620
* Racy check if we can split the page, before unmap_page() will
26202621
* split PMDs
26212622
*/
2622-
if (!can_split_huge_page(head, &extra_pins)) {
2623+
if (!can_split_folio(folio, &extra_pins)) {
26232624
ret = -EBUSY;
26242625
goto out_unlock;
26252626
}
@@ -2928,7 +2929,7 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
29282929
goto next;
29292930

29302931
total++;
2931-
if (!can_split_huge_page(compound_head(page), NULL))
2932+
if (!can_split_folio(page_folio(page), NULL))
29322933
goto next;
29332934

29342935
if (!trylock_page(page))

mm/vmscan.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,18 +1703,18 @@ static unsigned int shrink_page_list(struct list_head *page_list,
17031703
if (!PageSwapCache(page)) {
17041704
if (!(sc->gfp_mask & __GFP_IO))
17051705
goto keep_locked;
1706-
if (page_maybe_dma_pinned(page))
1706+
if (folio_maybe_dma_pinned(folio))
17071707
goto keep_locked;
17081708
if (PageTransHuge(page)) {
17091709
/* cannot split THP, skip it */
1710-
if (!can_split_huge_page(page, NULL))
1710+
if (!can_split_folio(folio, NULL))
17111711
goto activate_locked;
17121712
/*
17131713
* Split pages without a PMD map right
17141714
* away. Chances are some or all of the
17151715
* tail pages can be freed without IO.
17161716
*/
1717-
if (!compound_mapcount(page) &&
1717+
if (!folio_entire_mapcount(folio) &&
17181718
split_folio_to_list(folio,
17191719
page_list))
17201720
goto activate_locked;

0 commit comments

Comments
 (0)