[PATCH v6 00/11] make direct compaction more deterministic

From: Vlastimil Babka
Date: Wed Aug 10 2016 - 14:13:53 EST


Changes since v3
* The first part with cleanups (v4, v5) went separately to 4.8-rc1
* Rebased to 4.8-rc1
* Patch 1 - don't touch cached pfns in whole-zone compaction (Joonsoo)
* New patches 2 and 3 in response to Joonsoo pointing out missing adustments
to watermark checks in patch 7 - turns out we can remove those watermark
checks altogether.
* Patch 6 made less aggressive to avoid premature OOM (Joonsoo)

This is mostly a followup to Michal's oom detection rework, which highlighted
the need for direct compaction to provide better feedback in reclaim/compaction
loop, so that it can reliably recognize when compaction cannot make further
progress, and allocation should invoke OOM killer or fail. We've discussed
this at LSF/MM [1] where I proposed expanding the async/sync migration mode
used in compaction to more general "priorities". This patchset adds one new
priority that just overrides all the heuristics and makes compaction fully
scan all zones. I don't currently think that we need more fine-grained
priorities, but we'll see. Other than that there's some smaller fixes and
cleanups, mainly related to the THP-specific hacks.

I've tested this with stress-highalloc in GFP_KERNEL order-4 and
THP-like order-9 scenarios. There's some improvement for compaction stats
for the order-4, which is likely due to the better watermarks handling.
In the previous version I reported mostly noise wrt compaction stats, and
decreased direct reclaim - now the reclaim is without difference. I believe
this is due to the less aggressive compaction priority increase in patch 6.

"before" is a mmotm tree prior to 4.7 release plus the first part of the
series that was sent and merged separately

before after
order-4:

Compaction stalls 27216 30759
Compaction success 19598 25475
Compaction failures 7617 5283
Page migrate success 370510 464919
Page migrate failure 25712 27987
Compaction pages isolated 849601 1041581
Compaction migrate scanned 143146541 101084990
Compaction free scanned 208355124 144863510
Compaction cost 1403 1210

order-9:

Compaction stalls 7311 7401
Compaction success 1634 1683
Compaction failures 5677 5718
Page migrate success 194657 183988
Page migrate failure 4753 4170
Compaction pages isolated 498790 456130
Compaction migrate scanned 565371 524174
Compaction free scanned 4230296 4250744
Compaction cost 215 203

[1] https://lwn.net/Articles/684611/

Vlastimil Babka (11):
mm, compaction: make whole_zone flag ignore cached scanner positions
mm, compaction: cleanup unused functions
mm, compaction: rename COMPACT_PARTIAL to COMPACT_SUCCESS
mm, compaction: don't recheck watermarks after COMPACT_SUCCESS
mm, compaction: add the ultimate direct compaction priority
mm, compaction: more reliably increase direct compaction priority
mm, compaction: use correct watermark when checking compaction success
mm, compaction: create compact_gap wrapper
mm, compaction: use proper alloc_flags in __compaction_suitable()
mm, compaction: require only min watermarks for non-costly orders
mm, vmscan: make compaction_ready() more accurate and readable

include/linux/compaction.h | 32 +++++---
include/trace/events/compaction.h | 2 +-
mm/compaction.c | 154 +++++++++++++++++---------------------
mm/internal.h | 2 +-
mm/page_alloc.c | 22 +++---
mm/vmscan.c | 49 ++++++------
6 files changed, 128 insertions(+), 133 deletions(-)

--
2.9.2