Re: [RFC PATCH] mm: align anon mmap for THP

From: Kirill A. Shutemov
Date: Mon Jan 14 2019 - 08:50:10 EST


On Fri, Jan 11, 2019 at 03:28:37PM -0800, Mike Kravetz wrote:
> Ok, I just wanted to ask the question. I've seen application code doing
> the 'mmap sufficiently large area' then unmap to get desired alignment
> trick. Was wondering if there was something we could do to help.

Application may want to get aligned allocation for different reasons.
It should be okay for userspace to ask for size + (alignment - PAGE_SIZE)
and then round up the address to get the alignment. We basically do the
same on kernel side.

For THP, I believe, kernel already does The Right Thingâ for most users.
User still may want to get speific range as THP (to avoid false sharing or
something). But still I believe userspace has all required tools to get it
right.

--
Kirill A. Shutemov