Skip to content

Commit 4c640f1

Browse files
davidhildenbrandakpm00
authored andcommitted
mm/hugetlb: rename isolate_hugetlb() to folio_isolate_hugetlb()
Let's make the function name match "folio_isolate_lru()", and add some kernel doc. Link: https://lkml.kernel.org/r/20250113131611.2554758-3-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Muchun Song <muchun.song@linux.dev> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 8d91fed commit 4c640f1

5 files changed

Lines changed: 27 additions & 10 deletions

File tree

include/linux/hugetlb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to,
153153
vm_flags_t vm_flags);
154154
long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
155155
long freed);
156-
bool isolate_hugetlb(struct folio *folio, struct list_head *list);
156+
bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list);
157157
int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison);
158158
int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
159159
bool *migratable_cleared);
@@ -414,7 +414,7 @@ static inline pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr,
414414
return NULL;
415415
}
416416

417-
static inline bool isolate_hugetlb(struct folio *folio, struct list_head *list)
417+
static inline bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list)
418418
{
419419
return false;
420420
}

mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2344,7 +2344,7 @@ static unsigned long collect_longterm_unpinnable_folios(
23442344
continue;
23452345

23462346
if (folio_test_hugetlb(folio)) {
2347-
isolate_hugetlb(folio, movable_folio_list);
2347+
folio_isolate_hugetlb(folio, movable_folio_list);
23482348
continue;
23492349
}
23502350

mm/hugetlb.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,7 +2812,7 @@ static int alloc_and_dissolve_hugetlb_folio(struct hstate *h,
28122812
* Fail with -EBUSY if not possible.
28132813
*/
28142814
spin_unlock_irq(&hugetlb_lock);
2815-
isolated = isolate_hugetlb(old_folio, list);
2815+
isolated = folio_isolate_hugetlb(old_folio, list);
28162816
ret = isolated ? 0 : -EBUSY;
28172817
spin_lock_irq(&hugetlb_lock);
28182818
goto free_new;
@@ -2897,7 +2897,7 @@ int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list)
28972897
if (hstate_is_gigantic(h))
28982898
return -ENOMEM;
28992899

2900-
if (folio_ref_count(folio) && isolate_hugetlb(folio, list))
2900+
if (folio_ref_count(folio) && folio_isolate_hugetlb(folio, list))
29012901
ret = 0;
29022902
else if (!folio_ref_count(folio))
29032903
ret = alloc_and_dissolve_hugetlb_folio(h, folio, list);
@@ -7421,7 +7421,24 @@ __weak unsigned long hugetlb_mask_last_page(struct hstate *h)
74217421

74227422
#endif /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */
74237423

7424-
bool isolate_hugetlb(struct folio *folio, struct list_head *list)
7424+
/**
7425+
* folio_isolate_hugetlb - try to isolate an allocated hugetlb folio
7426+
* @folio: the folio to isolate
7427+
* @list: the list to add the folio to on success
7428+
*
7429+
* Isolate an allocated (refcount > 0) hugetlb folio, marking it as
7430+
* isolated/non-migratable, and moving it from the active list to the
7431+
* given list.
7432+
*
7433+
* Isolation will fail if @folio is not an allocated hugetlb folio, or if
7434+
* it is already isolated/non-migratable.
7435+
*
7436+
* On success, an additional folio reference is taken that must be dropped
7437+
* using folio_putback_active_hugetlb() to undo the isolation.
7438+
*
7439+
* Return: True if isolation worked, otherwise False.
7440+
*/
7441+
bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list)
74257442
{
74267443
bool ret = true;
74277444

mm/mempolicy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static int queue_folios_hugetlb(pte_t *pte, unsigned long hmask,
647647
*/
648648
if ((flags & MPOL_MF_MOVE_ALL) ||
649649
(!folio_likely_mapped_shared(folio) && !hugetlb_pmd_shared(pte)))
650-
if (!isolate_hugetlb(folio, qp->pagelist))
650+
if (!folio_isolate_hugetlb(folio, qp->pagelist))
651651
qp->nr_failed++;
652652
unlock:
653653
spin_unlock(ptl);

mm/migrate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static void putback_movable_folio(struct folio *folio)
128128
*
129129
* This function shall be used whenever the isolated pageset has been
130130
* built from lru, balloon, hugetlbfs page. See isolate_migratepages_range()
131-
* and isolate_hugetlb().
131+
* and folio_isolate_hugetlb().
132132
*/
133133
void putback_movable_pages(struct list_head *l)
134134
{
@@ -169,7 +169,7 @@ bool isolate_folio_to_list(struct folio *folio, struct list_head *list)
169169
bool isolated, lru;
170170

171171
if (folio_test_hugetlb(folio))
172-
return isolate_hugetlb(folio, list);
172+
return folio_isolate_hugetlb(folio, list);
173173

174174
lru = !__folio_test_movable(folio);
175175
if (lru)
@@ -2200,7 +2200,7 @@ static int __add_folio_for_migration(struct folio *folio, int node,
22002200
return -EACCES;
22012201

22022202
if (folio_test_hugetlb(folio)) {
2203-
if (isolate_hugetlb(folio, pagelist))
2203+
if (folio_isolate_hugetlb(folio, pagelist))
22042204
return 1;
22052205
} else if (folio_isolate_lru(folio)) {
22062206
list_add_tail(&folio->lru, pagelist);

0 commit comments

Comments
 (0)