Skip to content

Commit 89a41a0

Browse files
davidhildenbrandakpm00
authored andcommitted
mm/hugetlb: use folio->lru int demote_free_hugetlb_folios()
We are demoting hugetlb folios to smaller hugetlb folios; let's avoid messing with pages where avoidable and handle it more similar to __split_huge_page_tail(). Link: https://lkml.kernel.org/r/20250113131611.2554758-7-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Muchun Song <muchun.song@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 3f982b9 commit 89a41a0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

mm/hugetlb.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3826,13 +3826,15 @@ static long demote_free_hugetlb_folios(struct hstate *src, struct hstate *dst,
38263826

38273827
for (i = 0; i < pages_per_huge_page(src); i += pages_per_huge_page(dst)) {
38283828
struct page *page = folio_page(folio, i);
3829+
/* Careful: see __split_huge_page_tail() */
3830+
struct folio *new_folio = (struct folio *)page;
38293831

3830-
page->mapping = NULL;
38313832
clear_compound_head(page);
38323833
prep_compound_page(page, dst->order);
38333834

3834-
init_new_hugetlb_folio(dst, page_folio(page));
3835-
list_add(&page->lru, &dst_list);
3835+
new_folio->mapping = NULL;
3836+
init_new_hugetlb_folio(dst, new_folio);
3837+
list_add(&new_folio->lru, &dst_list);
38363838
}
38373839
}
38383840

0 commit comments

Comments
 (0)