* Transparent Hugepage Nit
@ 2013-01-15 20:50 John McCorquodale
2013-01-15 21:26 ` Andi Kleen
0 siblings, 1 reply; 3+ messages in thread
From: John McCorquodale @ 2013-01-15 20:50 UTC (permalink / raw)
To: linux-kernel
Suppose a hugepage-aligned mmap(MAP_ANONYMOUS) mapping has been madvise()d
HUGEPAGE. If a subeqeuent call to mremap() grows the mapping and has to
move the mapping, the hugepage-alignment is not preserved in the choice of
new address (in 3.7.2).
I can workaround this by doing a 1-hugepage-oversized remap to find a new
aligned address and then size it back down MREMAP_FIXED, but that's probably
a lot of frags to 4k pages and back that aren't necessary.
Should it not be the case that mremap(MAYMOVE) on something advised hugepage
ALWAYS chooses a hugepage-aligned address? This would be handy when doing the
initial allocation too: mmap, madvise, mremap (to the same size) to get
alignment.
Cheers,
-mcq
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Transparent Hugepage Nit
2013-01-15 20:50 Transparent Hugepage Nit John McCorquodale
@ 2013-01-15 21:26 ` Andi Kleen
2013-01-16 15:50 ` Rob Landley
0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2013-01-15 21:26 UTC (permalink / raw)
To: John McCorquodale; +Cc: linux-kernel
John McCorquodale <mcq@rockgeek.org> writes:
> Suppose a hugepage-aligned mmap(MAP_ANONYMOUS) mapping has been madvise()d
> HUGEPAGE. If a subeqeuent call to mremap() grows the mapping and has to
> move the mapping, the hugepage-alignment is not preserved in the choice of
> new address (in 3.7.2).
>
> I can workaround this by doing a 1-hugepage-oversized remap to find a new
> aligned address and then size it back down MREMAP_FIXED, but that's probably
> a lot of frags to 4k pages and back that aren't necessary.
>
> Should it not be the case that mremap(MAYMOVE) on something advised hugepage
> ALWAYS chooses a hugepage-aligned address? This would be handy when doing the
> initial allocation too: mmap, madvise, mremap (to the same size) to get
> alignment.
The hole searching currently doesn't know anything about transparent
huge pages. There were some discussions on fixing it. But it's
essentially a trade off between memory fragmentation and huge page
optimization: aggressively aligning to 2MB can lose address space
in holes.
Usually if the program uses large enough mappings and enough memory
it shouldn't be a problem.
-Andi
--
ak@linux.intel.com -- Speaking for myself only
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Transparent Hugepage Nit
2013-01-15 21:26 ` Andi Kleen
@ 2013-01-16 15:50 ` Rob Landley
0 siblings, 0 replies; 3+ messages in thread
From: Rob Landley @ 2013-01-16 15:50 UTC (permalink / raw)
To: Andi Kleen; +Cc: John McCorquodale, linux-kernel
On 01/15/2013 03:26:58 PM, Andi Kleen wrote:
> John McCorquodale <mcq@rockgeek.org> writes:
>
> > Suppose a hugepage-aligned mmap(MAP_ANONYMOUS) mapping has been
> madvise()d
> > HUGEPAGE. If a subeqeuent call to mremap() grows the mapping and
> has to
> > move the mapping, the hugepage-alignment is not preserved in the
> choice of
> > new address (in 3.7.2).
> >
> > I can workaround this by doing a 1-hugepage-oversized remap to find
> a new
> > aligned address and then size it back down MREMAP_FIXED, but that's
> probably
> > a lot of frags to 4k pages and back that aren't necessary.
> >
> > Should it not be the case that mremap(MAYMOVE) on something advised
> hugepage
> > ALWAYS chooses a hugepage-aligned address? This would be handy
> when doing the
> > initial allocation too: mmap, madvise, mremap (to the same size) to
> get
> > alignment.
>
> The hole searching currently doesn't know anything about transparent
> huge pages. There were some discussions on fixing it. But it's
> essentially a trade off between memory fragmentation and huge page
> optimization: aggressively aligning to 2MB can lose address space
> in holes.
>
> Usually if the program uses large enough mappings and enough memory
> it shouldn't be a problem.
Possibly we should just document that doing mremap() on a hugepage
loses the hugepageness, and consider it pilot error to do that?
Rob
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-01-16 16:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-15 20:50 Transparent Hugepage Nit John McCorquodale
2013-01-15 21:26 ` Andi Kleen
2013-01-16 15:50 ` Rob Landley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox