On Fri, Jul 18, 2025 at 12:35 AM Usama Arif <usamaarif642@xxxxxxxxx> wrote: > > > > On 08/06/2025 08:35, Yafang Shao wrote: > > Background > > ---------- > > > > We have consistently configured THP to "never" on our production servers > > due to past incidents caused by its behavior: > > > > - Increased memory consumption > > THP significantly raises overall memory usage. > > > > - Latency spikes > > Random latency spikes occur due to more frequent memory compaction > > activity triggered by THP. > > > > - Lack of Fine-Grained Control > > THP tuning knobs are globally configured, making them unsuitable for > > containerized environments. When different workloads run on the same > > host, enabling THP globally (without per-workload control) can cause > > unpredictable behavior. > > > > Due to these issues, system administrators remain hesitant to switch to > > "madvise" or "always" modes—unless finer-grained control over THP > > behavior is implemented. > > > > Would this solution work and be carried over in fork+exec? As that is something > which is very common. How would that look like? The current implementation doesn't handle the fork+exec case properly. I've developed an updated version that addresses this issue, though I haven't submitted it for review yet. In the new version: khugepaged_fork() will verify process eligibility before entering __khugepaged_enter() If a parent process loses THP allocation privileges: 1. its child processes will skip __khugepaged_enter() 2. it will be removed from the khugepaged mm_slot. 3. the MMF_VM_HUGEPAGE will be cleared -- Regards Yafang