On 11/02/2025 00:40, Nico Pache wrote: > setting /transparent_hugepages/enabled=always allows applications > to benefit from THPs without having to madvise. However, the pf handler > takes very few considerations to decide weather or not to actually use a > THP. This can lead to a lot of wasted memory. khugepaged only operates > on memory that was either allocated with enabled=always or MADV_HUGEPAGE. > > Introduce the ability to set enabled=defer, which will prevent THPs from > being allocated by the page fault handler unless madvise is set, > leaving it up to khugepaged to decide which allocations will collapse to a > THP. This should allow applications to benefits from THPs, while curbing > some of the memory waste. > > Signed-off-by: Nico Pache <npache@xxxxxxxxxx> > --- > include/linux/huge_mm.h | 15 +++++++++++++-- > mm/huge_memory.c | 31 +++++++++++++++++++++++++++---- > 2 files changed, 40 insertions(+), 6 deletions(-) > > diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h > index 93e509b6c00e..fb381ca720ea 100644 > --- a/include/linux/huge_mm.h > +++ b/include/linux/huge_mm.h > @@ -44,6 +44,7 @@ enum transparent_hugepage_flag { > TRANSPARENT_HUGEPAGE_UNSUPPORTED, > TRANSPARENT_HUGEPAGE_FLAG, > TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG, > + TRANSPARENT_HUGEPAGE_DEFER_PF_INST_FLAG, No strong preference, but maybe just TRANSPARENT_HUGEPAGE_DEFER_FLAG might be better?