On 04/14/23 12:06, Mike Kravetz wrote: > Thanks Mel! > Apologies for not noticing when the bug was posted to the list. Otherwise, > I would have jumped on it. > > On 04/14/23 09:22, Mel Gorman wrote: > > A bug was reported by Yuanxi Liu where allocating 1G pages at runtime is > > taking an excessive amount of time for large amounts of memory. Further > > testing allocating huge pages that the cost is linear i.e. if allocating > > 1G pages in batches of 10 then the time to allocate nr_hugepages from > > 10->20->30->etc increases linearly even though 10 pages are allocated at > > each step. Profiles indicated that much of the time is spent checking the > > validity within already existing huge pages and then attempting a migration > > that fails after isolating the range, draining pages and a whole lot of > > other useless work. > > > > Commit eb14d4eefdc4 ("mm,page_alloc: drop unnecessary checks from > > pfn_range_valid_contig") removed two checks, one which ignored huge pages > > for contiguous allocations as huge pages can migrate. While there may be > > value on migrating a 2M page to satisfy a 1G allocation, it's pointless > > to move a 1G page for a new 1G allocation or scan for validity within an > > existing huge page. > > eb14d4eefdc4 was the last patch in Oscar's series "Make alloc_contig_range > handle Hugetlb pages". > https://lore.kernel.org/linux-mm/20210419075413.1064-1-osalvador@xxxxxxx/ > > It seems bailing out of alloc_contig_range when experiencing hugetlb > pages was an actual issue as the cover letter says: > David correctly pointed out that I was confusing alloc_contig_range and alloc_contig_pages. Sorry! -- Mike Kravetz