It looks like newer kernels (4.6 and above) support a "defer" option for 
THP behavior (4.11 and above also support "defer+madvise"). This behavior 
is set via /sys/kernel/mm/transparent_hugepage/defrag (separate from 
/sys/kernel/mm/transparent_hugepage/enabled). With the defer options on, 
allocations avoid [synchronously] attempting to compact memory, and should 
avoid the huge outliers discussed earlier.

See Andrea Arcangeli's FOSDEM slides from Feb, 2017 
<https://fosdem.org/2017/schedule/event/iaas_20yealin/attachments/slides/1498/export/events/attachments/iaas_20yealin/slides/1498/VM.pdf>
 for 
some details. 

cat /sys/kernel/mm/transparent_hugepage/defrag will show you the available 
options on your system. Looking up the kernel function defrag_show() is 
probably the easiest way to check for this on a given kernel's sources:
Starting with 4.11, it shows "[always] defer defer+madvise madvise never" 
(http://elixir.free-electrons.com/linux/v4.11/source/mm/huge_memory.c#L219)
Starting with 4.6 , it shows "[always] defer madvise never" 
(http://elixir.free-electrons.com/linux/v4.6/source/mm/huge_memory.c#L380)
Prior versions (4.5 and earlier) did not have a defer option... And 
RHEL/CentOS don't either (not up to RHEL 7.3 anyway).

Personally, I'll need to kick this around a bit to see if it seems to 
really works before starting to recommend using it (in place of "never") in 
cases where people care about avoiding huge outliers. Unfortunately, the 
latest RHEL, CentOS, versions don't yet have the "defer" option, And only 
the latest Ubuntu LTS (16.04.02) does. So many of the production 
environments run by people I get to interact with does yet have the 
feature. It may take a while to get real production experience with 
"defer". But assuming it delivers on the promised behavior, it does present 
a compelling argument for upgrading to the latest releases when they start 
supporting the feature. E.g. for Ubuntu users, moving to Ubuntu LTS 
16.04.02 (or some later release), switching THP enabled to "always" and THP 
defrag to "defer" may provide a very real performance boost.







-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to