Skip to content

Commit

Permalink
ZEN: INTERACTIVE: Enable background reclaim of hugepages
Browse files Browse the repository at this point in the history
Use [defer+madvise] as default khugepaged defrag strategy:

For some reason, the default strategy to respond to THP fault fallbacks
is still just madvise, meaning stall if the program wants transparent
hugepages, but don't trigger a background reclaim / compaction if THP
begins to fail allocations.  This creates a snowball affect where we
still use the THP code paths, but we almost always fail once a system
has been active and busy for a while.

The option "defer" was created for interactive systems where THP can
still improve performance.  If we have to fallback to a regular page due
to an allocation failure or anything else, we will trigger a background
reclaim and compaction so future THP attempts succeed and previous
attempts eventually have their smaller pages combined without stalling
running applications.

We still want madvise to stall applications that explicitely want THP,
so defer+madvise _does_ make a ton of sense.  Make it the default for
interactive systems, especially if the kernel maintainer left
transparent hugepages on "always".

Reasoning and details in the original patch: https://lwn.net/Articles/711248/
  • Loading branch information
heftig committed Jan 27, 2020
1 parent 394ae0c commit 11c4c38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions init/Kconfig
Expand Up @@ -89,6 +89,7 @@ config ZEN_INTERACTIVE
Mem dirty before bg writeback..: 10 % -> 20 %
Mem dirty before sync writeback: 20 % -> 50 %
Compact unevictable pages......: yes -> no
Background-reclaim hugepages...: no -> yes

config BROKEN
bool
Expand Down
4 changes: 4 additions & 0 deletions mm/huge_memory.c
Expand Up @@ -53,7 +53,11 @@ unsigned long transparent_hugepage_flags __read_mostly =
#ifdef CONFIG_TRANSPARENT_HUGEPAGE_MADVISE
(1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)|
#endif
#ifdef CONFIG_ZEN_INTERACTIVE
(1<<TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG)|
#else
(1<<TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG)|
#endif
(1<<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG)|
(1<<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG);

Expand Down

0 comments on commit 11c4c38

Please sign in to comment.