Skip to content

Commit

Permalink
mm/hugetlb: convert putback_active_hugepage to take in a folio
Browse files Browse the repository at this point in the history
Convert putback_active_hugepage() to folio_putback_active_hugetlb(), this
removes one user of the Huge Page macros which take in a page.  The
callers in migrate.c are also cleaned up by being able to directly use the
src and dst folio variables.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Sidhartha Kumar <[email protected]>
Reviewed-by: Mike Kravetz <[email protected]>
Cc: Gerald Schaefer <[email protected]>
Cc: John Hubbard <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Muchun Song <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
sidkumar99 authored and akpm00 committed Feb 13, 2023
1 parent 91a2fb9 commit ea8e72f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/linux/hugetlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int isolate_hugetlb(struct folio *folio, struct list_head *list);
int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison);
int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
bool *migratable_cleared);
void putback_active_hugepage(struct page *page);
void folio_putback_active_hugetlb(struct folio *folio);
void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason);
void free_huge_page(struct page *page);
void hugetlb_fix_reserve_counts(struct inode *inode);
Expand Down Expand Up @@ -429,7 +429,7 @@ static inline int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
return 0;
}

static inline void putback_active_hugepage(struct page *page)
static inline void folio_putback_active_hugetlb(struct folio *folio)
{
}

Expand Down
8 changes: 4 additions & 4 deletions mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -7300,13 +7300,13 @@ int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
return ret;
}

void putback_active_hugepage(struct page *page)
void folio_putback_active_hugetlb(struct folio *folio)
{
spin_lock_irq(&hugetlb_lock);
SetHPageMigratable(page);
list_move_tail(&page->lru, &(page_hstate(page))->hugepage_activelist);
folio_set_hugetlb_migratable(folio);
list_move_tail(&folio->lru, &(folio_hstate(folio))->hugepage_activelist);
spin_unlock_irq(&hugetlb_lock);
put_page(page);
folio_put(folio);
}

void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason)
Expand Down
8 changes: 4 additions & 4 deletions mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void putback_movable_pages(struct list_head *l)

list_for_each_entry_safe(page, page2, l, lru) {
if (unlikely(PageHuge(page))) {
putback_active_hugepage(page);
folio_putback_active_hugetlb(page_folio(page));
continue;
}
list_del(&page->lru);
Expand Down Expand Up @@ -1298,7 +1298,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,

if (folio_ref_count(src) == 1) {
/* page was freed from under us. So we are done. */
putback_active_hugepage(hpage);
folio_putback_active_hugetlb(src);
return MIGRATEPAGE_SUCCESS;
}

Expand Down Expand Up @@ -1383,7 +1383,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
folio_unlock(src);
out:
if (rc == MIGRATEPAGE_SUCCESS)
putback_active_hugepage(hpage);
folio_putback_active_hugetlb(src);
else if (rc != -EAGAIN)
list_move_tail(&src->lru, ret);

Expand All @@ -1395,7 +1395,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
if (put_new_page)
put_new_page(new_hpage, private);
else
putback_active_hugepage(new_hpage);
folio_putback_active_hugetlb(dst);

return rc;
}
Expand Down

0 comments on commit ea8e72f

Please sign in to comment.