[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aURXd7d1on5vxnnT@cmpxchg.org>
Date: Thu, 18 Dec 2025 14:35:19 -0500
From: Johannes Weiner <hannes@...xchg.org>
To: Gregory Price <gourry@...rry.net>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org, kernel-team@...a.com,
akpm@...ux-foundation.org, vbabka@...e.cz, surenb@...gle.com,
mhocko@...e.com, jackmanb@...gle.com, ziy@...dia.com,
richard.weiyang@...il.com, osalvador@...e.de, rientjes@...gle.com,
david@...hat.com, joshua.hahnjy@...il.com, fvdl@...gle.com
Subject: Re: [PATCH v5] page_alloc: allow migration of smaller hugepages
during contig_alloc
On Thu, Dec 18, 2025 at 02:08:31PM -0500, Gregory Price wrote:
> @@ -7099,8 +7099,30 @@ static bool pfn_range_valid_contig(struct zone *z, unsigned long start_pfn,
> if (PageReserved(page))
> return false;
>
> - if (PageHuge(page))
> - return false;
> + /*
> + * Only consider ranges containing hugepages if those pages are
> + * smaller than the requested contiguous region. e.g.:
> + * Move 2MB pages to free up a 1GB range.
> + * Don't move 1GB pages to free up a 2MB range.
> + *
> + * This makes contiguous allocation more reliable if multiple
> + * hugepage sizes are used without causing needless movement.
> + */
> + if (PageHuge(page)) {
> + unsigned int order;
> +
> + if (!IS_ENABLED(CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION))
> + return false;
> +
> + if (!search_hugetlb)
> + return false;
> +
> + page = compound_head(page);
> + order = compound_order(page);
> + if ((order >= MAX_FOLIO_ORDER) ||
> + (nr_pages <= (1 << order)))
> + return false;
If you keep searching past it, you can step over the whole page to
speed things up a bit:
i += (1 << order) - 1;
Powered by blists - more mailing lists