Re: [PATCH] mm: page_alloc: Assume huge tail pages are valid when allocating contiguous pages
From: Michal Hocko
Date: Fri Apr 14 2023 - 04:55:10 EST
On Fri 14-04-23 09:22:22, Mel Gorman wrote:
[...]
> +
> + /*
> + * Do not migrate huge pages that span the size of the region
> + * being allocated contiguous. e.g. Do not migrate a 1G page
> + * for a 1G allocation request. CMA is an exception as the
> + * region may be reserved for hardware that requires physical
> + * memory without a MMU or scatter/gather capability.
> + *
> + * Note that the compound check is race-prone versus
> + * free/split/collapse but it should be safe and result in
> + * a premature skip or a useless migration attempt.
> + */
> + if (PageHuge(page) && compound_nr(page) >= nr_pages &&
> + !is_migrate_cma_page(page)) {
> + return false;
Is the CMA check working as expected? The function sounds quite generic
and I agree that it would make sense if it was generic but it is used
only for GB pages in fact and unless I am missing something it would
allow to migrate CMA pages and potentially allocate over that region
without any possibility to migrate GB page out so the CMA region would
be essentially unusable for CMA users. GB pages already have their CMA
allocator path before we get to alloc_contig_pages. Or do I miss
something?
--
Michal Hocko
SUSE Labs