On Mar 9, 2023, at 17:05, Zach O'Keefe <zokeefe@xxxxxxxxxx> wrote:
I think the hugepage alignment in their environment was somewhat luck.
One suggestion made was to change stack size to avoid alignment and
hugepage usage. That 'works' but seems kind of hackish.
That was my first thought, if the alignment was purely due to luck,
and not somebody manually specifying it. Agreed it's kind of hackish
if anyone can get bit by this by sheer luck.
I don't agree it's "hackish" at all, but I go more into that below.
Also, David H pointed out the somewhat recent commit to align sufficiently
large mappings to THP boundaries. This is going to make all stacks huge
page aligned.
I think that change was reverted by Linus in commit 0ba09b173387
("Revert "mm: align larger anonymous mappings on THP boundaries""),
until it's perf regressions were better understood -- and I haven't
seen a revamp of it.
It's too bad it was reverted, though I understand the concerns regarding it.
From my point of view, if an address is properly aligned and a caller is
asking for 2M+ to be mapped, it's going to be advantageous from a purely
system-focused point of view to do that mapping with a THP.