mm/compaction: reduce the difference between low and high watermarks
authorMichal Clapinski <mclapinski@google.com>
Fri, 4 Apr 2025 11:11:03 +0000 (13:11 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 May 2025 00:48:10 +0000 (17:48 -0700)
Reduce the diff between low and high watermarks when compaction
proactiveness is set to high.  This allows users who set the proactiveness
really high to have more stable fragmentation score over time.

Link: https://lkml.kernel.org/r/20250404111103.1994507-3-mclapinski@google.com
Signed-off-by: Michal Clapinski <mclapinski@google.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/admin-guide/sysctl/vm.rst
mm/compaction.c

index 8290177..b325bfb 100644 (file)
@@ -131,6 +131,12 @@ to latency spikes in unsuspecting applications. The kernel employs
 various heuristics to avoid wasting CPU cycles if it detects that
 proactive compaction is not being effective.
 
+Setting the value above 80 will, in addition to lowering the acceptable level
+of fragmentation, make the compaction code more sensitive to increases in
+fragmentation, i.e. compaction will trigger more often, but reduce
+fragmentation by a smaller amount.
+This makes the fragmentation level more stable over time.
+
 Be careful when setting it to extreme values like 100, as that may
 cause excessive background compaction activity.
 
index f9ee06d..fe51a73 100644 (file)
@@ -2249,10 +2249,11 @@ static unsigned int fragmentation_score_node(pg_data_t *pgdat)
 
 static unsigned int fragmentation_score_wmark(bool low)
 {
-       unsigned int wmark_low;
+       unsigned int wmark_low, leeway;
 
        wmark_low = 100U - sysctl_compaction_proactiveness;
-       return low ? wmark_low : min(wmark_low + 10, 100U);
+       leeway = min(10U, wmark_low / 2);
+       return low ? wmark_low : min(wmark_low + leeway, 100U);
 }
 
 static bool should_proactive_compact_node(pg_data_t *pgdat)