Re: MAP_POPULATE vs. MADV_HUGEPAGES

From: Michal Hocko
Date: Thu Mar 16 2017 - 08:34:55 EST


On Wed 15-03-17 18:50:32, Avi Kivity wrote:
> A user is trying to allocate 1TB of anonymous memory in parallel on 48 cores
> (4 NUMA nodes). The kernel ends up spinning in isolate_freepages_block().

Which kernel version is that? What is the THP defrag mode
(/sys/kernel/mm/transparent_hugepage/defrag)?

> I thought to help it along by using MAP_POPULATE, but then my MADV_HUGEPAGE
> won't be seen until after mmap() completes, with pages already populated.
> Are MAP_POPULATE and MADV_HUGEPAGE mutually exclusive?

Why do you need MADV_HUGEPAGE?

> Is my only option to serialize those memory allocations, and fault in those
> pages manually? Or perhaps use mlock()?

I am still not 100% sure I see what you are trying to achieve, though.
So you do not want all those processes to contend inside the compaction
while still allocate as many huge pages as possible?

--
Michal Hocko
SUSE Labs