Skip to content

Commit 54fa49b

Browse files
sidkumar99akpm00
authored andcommitted
mm/hugetlb: convert dissolve_free_huge_pages() to folios
Allows us to rename dissolve_free_huge_pages() to dissolve_free_hugetlb_folio(). Convert one caller to pass in a folio directly and use page_folio() to convert the caller in mm/memory-failure. [[email protected]: remove unneeded `extern'] Link: https://lkml.kernel.org/r/[email protected] [[email protected]: v2] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Sidhartha Kumar <[email protected]> Reviewed-by: Oscar Salvador <[email protected]> Reviewed-by: Vishal Moola (Oracle) <[email protected]> Reviewed-by: Miaohe Lin <[email protected]> Cc: Jane Chu <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Muchun Song <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 452e862 commit 54fa49b

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

include/linux/hugetlb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ static inline int hstate_index(struct hstate *h)
861861
return h - hstates;
862862
}
863863

864-
extern int dissolve_free_huge_page(struct page *page);
864+
int dissolve_free_hugetlb_folio(struct folio *folio);
865865
extern int dissolve_free_huge_pages(unsigned long start_pfn,
866866
unsigned long end_pfn);
867867

@@ -1148,7 +1148,7 @@ static inline int hstate_index(struct hstate *h)
11481148
return 0;
11491149
}
11501150

1151-
static inline int dissolve_free_huge_page(struct page *page)
1151+
static inline int dissolve_free_hugetlb_folio(struct folio *folio)
11521152
{
11531153
return 0;
11541154
}

mm/hugetlb.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,8 +2377,8 @@ static struct folio *remove_pool_hugetlb_folio(struct hstate *h,
23772377
}
23782378

23792379
/*
2380-
* Dissolve a given free hugepage into free buddy pages. This function does
2381-
* nothing for in-use hugepages and non-hugepages.
2380+
* Dissolve a given free hugetlb folio into free buddy pages. This function
2381+
* does nothing for in-use hugetlb folios and non-hugetlb folios.
23822382
* This function returns values like below:
23832383
*
23842384
* -ENOMEM: failed to allocate vmemmap pages to free the freed hugepages
@@ -2390,10 +2390,9 @@ static struct folio *remove_pool_hugetlb_folio(struct hstate *h,
23902390
* 0: successfully dissolved free hugepages or the page is not a
23912391
* hugepage (considered as already dissolved)
23922392
*/
2393-
int dissolve_free_huge_page(struct page *page)
2393+
int dissolve_free_hugetlb_folio(struct folio *folio)
23942394
{
23952395
int rc = -EBUSY;
2396-
struct folio *folio = page_folio(page);
23972396

23982397
retry:
23992398
/* Not to disrupt normal path by vainly holding hugetlb_lock */
@@ -2470,13 +2469,13 @@ int dissolve_free_huge_page(struct page *page)
24702469
* make specified memory blocks removable from the system.
24712470
* Note that this will dissolve a free gigantic hugepage completely, if any
24722471
* part of it lies within the given range.
2473-
* Also note that if dissolve_free_huge_page() returns with an error, all
2474-
* free hugepages that were dissolved before that error are lost.
2472+
* Also note that if dissolve_free_hugetlb_folio() returns with an error, all
2473+
* free hugetlb folios that were dissolved before that error are lost.
24752474
*/
24762475
int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn)
24772476
{
24782477
unsigned long pfn;
2479-
struct page *page;
2478+
struct folio *folio;
24802479
int rc = 0;
24812480
unsigned int order;
24822481
struct hstate *h;
@@ -2489,8 +2488,8 @@ int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn)
24892488
order = min(order, huge_page_order(h));
24902489

24912490
for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << order) {
2492-
page = pfn_to_page(pfn);
2493-
rc = dissolve_free_huge_page(page);
2491+
folio = pfn_folio(pfn);
2492+
rc = dissolve_free_hugetlb_folio(folio);
24942493
if (rc)
24952494
break;
24962495
}

mm/memory-failure.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static int __page_handle_poison(struct page *page)
155155

156156
/*
157157
* zone_pcp_disable() can't be used here. It will
158-
* hold pcp_batch_high_lock and dissolve_free_huge_page() might hold
158+
* hold pcp_batch_high_lock and dissolve_free_hugetlb_folio() might hold
159159
* cpu_hotplug_lock via static_key_slow_dec() when hugetlb vmemmap
160160
* optimization is enabled. This will break current lock dependency
161161
* chain and leads to deadlock.
@@ -165,7 +165,7 @@ static int __page_handle_poison(struct page *page)
165165
* but nothing guarantees that those pages do not get back to a PCP
166166
* queue if we need to refill those.
167167
*/
168-
ret = dissolve_free_huge_page(page);
168+
ret = dissolve_free_hugetlb_folio(page_folio(page));
169169
if (!ret) {
170170
drain_all_pages(page_zone(page));
171171
ret = take_page_off_buddy(page);
@@ -178,8 +178,8 @@ static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, boo
178178
{
179179
if (hugepage_or_freepage) {
180180
/*
181-
* Doing this check for free pages is also fine since dissolve_free_huge_page
182-
* returns 0 for non-hugetlb pages as well.
181+
* Doing this check for free pages is also fine since
182+
* dissolve_free_hugetlb_folio() returns 0 for non-hugetlb folios as well.
183183
*/
184184
if (__page_handle_poison(page) <= 0)
185185
/*

0 commit comments

Comments
 (0)