Huge Pages Ugly Tail

A service keeps a 40 GiB index in anonymous memory and probes it randomly. The team writes always to /sys/kernel/mm/transparent_hugepage/enabled. CPU time per query drops 12 percent and median latency improves, but p99 gets noticeably worse and the process occasionally stalls for more than 200 ms inside a page fault.

More than one option is correct. Select every statement that is true of this situation.

A

Switching the setting to madvise would keep the CPU win with no stalls, because madvise mode never performs compaction.

B

A 2 MiB mapping makes the page table walk one level deeper, so each remaining TLB miss now costs an extra memory reference.

C

Each huge-page fault must zero 2 MiB before the mapping is usable, so one fault does 512 times the clearing work of a 4 KiB fault.

D

With defrag set to always, a fault that cannot find a free 2 MiB block enters direct reclaim and compaction, which relocates physical pages synchronously in the faulting thread. That is the stall.

E

khugepaged scans existing 4 KiB mappings in the background and collapses them into huge pages, adding CPU work and brief lock contention that the application does not control.

F

TLB reach is unchanged, because the TLB still holds the same number of entries; the CPU win must come from somewhere else.