summaryrefslogtreecommitdiffstats
path: root/mm/hugetlb.c
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2025-01-13 14:16:11 +0100
committerAndrew Morton <akpm@linux-foundation.org>2025-01-26 05:22:42 +0100
commit89a41a0263293856678189981e5407375261c4ff (patch)
tree222e5da4746be52302a61b93746643af7734bf6f /mm/hugetlb.c
parentmm/hugetlb-cgroup: convert hugetlb_cgroup_css_offline() to work on folios (diff)
downloadlinux-89a41a0263293856678189981e5407375261c4ff.tar.xz
linux-89a41a0263293856678189981e5407375261c4ff.zip
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>
Diffstat (limited to '')
-rw-r--r--mm/hugetlb.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 308b0e3876b5..87761b042ed0 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3826,13 +3826,15 @@ static long demote_free_hugetlb_folios(struct hstate *src, struct hstate *dst,
for (i = 0; i < pages_per_huge_page(src); i += pages_per_huge_page(dst)) {
struct page *page = folio_page(folio, i);
+ /* Careful: see __split_huge_page_tail() */
+ struct folio *new_folio = (struct folio *)page;
- page->mapping = NULL;
clear_compound_head(page);
prep_compound_page(page, dst->order);
- init_new_hugetlb_folio(dst, page_folio(page));
- list_add(&page->lru, &dst_list);
+ new_folio->mapping = NULL;
+ init_new_hugetlb_folio(dst, new_folio);
+ list_add(&new_folio->lru, &dst_list);
}
}