From: Michal Clapinski <mclapinski@google.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>,
Pasha Tatashin <tatashin@google.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Michal Clapinski <mclapinski@google.com>
Subject: [PATCH v4 2/2] mm/compaction: reduce the difference between low and high watermarks
Date: Fri, 4 Apr 2025 13:11:03 +0200 [thread overview]
Message-ID: <20250404111103.1994507-3-mclapinski@google.com> (raw)
In-Reply-To: <20250404111103.1994507-1-mclapinski@google.com>
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.
Signed-off-by: Michal Clapinski <mclapinski@google.com>
---
Documentation/admin-guide/sysctl/vm.rst | 6 ++++++
mm/compaction.c | 5 +++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-guide/sysctl/vm.rst
index f48eaa98d22d2..d716ff1f37b57 100644
--- a/Documentation/admin-guide/sysctl/vm.rst
+++ b/Documentation/admin-guide/sysctl/vm.rst
@@ -130,6 +130,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.
diff --git a/mm/compaction.c b/mm/compaction.c
index 4ff6b6e1db2da..f29a09def4515 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -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)
--
2.49.0.504.g3bcea36a83-goog
prev parent reply other threads:[~2025-04-04 11:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-04 11:11 [PATCH v4 0/2] mm/compaction: allow more aggressive proactive compaction Michal Clapinski
2025-04-04 11:11 ` [PATCH v4 1/2] mm/compaction: remove low watermark cap for " Michal Clapinski
2025-04-04 11:11 ` Michal Clapinski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250404111103.1994507-3-mclapinski@google.com \
--to=mclapinski@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tatashin@google.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox