Commit dc6b4c72 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Liu Shixin
Browse files

mm: inline destroy_large_folio() into __folio_put_large()

mainline inclusion
from mainline-v6.10-rc1
commit 2542b1ac9a46ac58f9565de0048457956898d481
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9R3AY
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2542b1ac9a46ac58f9565de0048457956898d481

--------------------------------

destroy_large_folio() has only one caller, move its contents there.

Link: https://lkml.kernel.org/r/20240405153228.2563754-4-willy@infradead.org


Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarZi Yan <ziy@nvidia.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent 62b208c4
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1321,8 +1321,6 @@ void folio_copy(struct folio *dst, struct folio *src);

unsigned long nr_free_buffer_pages(void);

void destroy_large_folio(struct folio *folio);

/* Returns the number of bytes in this potentially compound page. */
static inline unsigned long page_size(struct page *page)
{
+0 −14
Original line number Diff line number Diff line
@@ -591,20 +591,6 @@ void prep_compound_page(struct page *page, unsigned int order)
	prep_compound_head(page, order);
}

void destroy_large_folio(struct folio *folio)
{
	if (folio_test_hugetlb(folio)) {
		free_huge_folio(folio);
		return;
	}

	if (folio_test_large_rmappable(folio))
		folio_undo_large_rmappable(folio);

	mem_cgroup_uncharge(folio);
	free_unref_page(&folio->page, folio_order(folio));
}

static inline void set_buddy_order(struct page *page, unsigned int order)
{
	set_page_private(page, order);
+10 −3
Original line number Diff line number Diff line
@@ -127,9 +127,16 @@ static void __folio_put_large(struct folio *folio)
	 * (it's never listed to any LRU lists) and no memcg routines should
	 * be called for hugetlb (it has a separate hugetlb_cgroup.)
	 */
	if (!folio_test_hugetlb(folio))
	if (folio_test_hugetlb(folio)) {
		free_huge_folio(folio);
		return;
	}

	page_cache_release(folio);
	destroy_large_folio(folio);
	if (folio_test_large_rmappable(folio))
		folio_undo_large_rmappable(folio);
	mem_cgroup_uncharge(folio);
	free_unref_page(&folio->page, folio_order(folio));
}

void __folio_put(struct folio *folio)