On Mon, Mar 06, 2023 at 03:57:30PM -0800, Mike Kravetz wrote: > One of our product teams recently experienced 'memory bloat' in their > environment. The application in this environment is the JVM which > creates hundreds of threads. Threads are ultimately created via > pthread_create which also creates the thread stacks. pthread attributes > are modified so that stacks are 2MB in size. It just so happens that > due to allocation patterns, all their stacks are at 2MB boundaries. The > system has THP always set, so a huge page is allocated at the first > (write) fault when libpthread initializes the stack. Do you happen to have an strace (or similar) so we can understand what the application is doing? My understanding is that for a normal app (like, say, 'cat'), we'll allow up to an 8MB stack, but we only create a VMA that is 4kB in size and set the VM_GROWSDOWN flag on it (to allow it to magically grow). Therefore we won't create a 2MB page because the VMA is too small. It sounds like the pthread library is maybe creating a 2MB stack as a 2MB VMA, and that's why we're seeing this behaviour?