[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_FD958236269FD3A7996FFCF29E9BAA4EA809@qq.com>
Date: Wed, 12 Apr 2023 02:24:26 +0800
From: wenyang.linux@...mail.com
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Wen Yang <wenyang.linux@...mail.com>,
Mel Gorman <mgorman@...hsingularity.net>,
Oscar Salvador <osalvador@...e.de>,
William Lam <william.lam@...edance.com>,
Fu Wei <wefu@...hat.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] mm: compaction: optimize compact_memory to comply with the admin-guide
From: Wen Yang <wenyang.linux@...mail.com>
For the /proc/sys/vm/compact_memory file, the admin-guide states:
When 1 is written to the file, all zones are compacted such that free
memory is available in contiguous blocks where possible. This can be
important for example in the allocation of huge pages although processes
will also directly compact memory as required
But it was not strictly followed, writing any value would cause all
zones to be compacted. In some critical scenarios, some applications
operating it, such as echo 0, have caused serious problems.
It has been slightly optimized to comply with the admin-guide.
Signed-off-by: Wen Yang <wenyang.linux@...mail.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Mel Gorman <mgorman@...hsingularity.net>
Cc: Oscar Salvador <osalvador@...e.de>
Cc: William Lam <william.lam@...edance.com>
Cc: Fu Wei <wefu@...hat.com>
Cc: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org
---
mm/compaction.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mm/compaction.c b/mm/compaction.c
index c8bcdea15f5f..3c4aa533d61c 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -2780,6 +2780,17 @@ static int compaction_proactiveness_sysctl_handler(struct ctl_table *table, int
static int sysctl_compaction_handler(struct ctl_table *table, int write,
void *buffer, size_t *length, loff_t *ppos)
{
+ struct ctl_table t;
+ int compact;
+ int ret;
+
+ t = *table;
+ t.data = &compact;
+
+ ret = proc_dointvec_minmax(&t, write, buffer, length, ppos);
+ if (ret)
+ return ret;
+
if (write)
compact_nodes();
@@ -3099,6 +3110,8 @@ static struct ctl_table vm_compaction[] = {
.maxlen = sizeof(int),
.mode = 0200,
.proc_handler = sysctl_compaction_handler,
+ .extra1 = SYSCTL_ONE,
+ .extra2 = SYSCTL_ONE,
},
{
.procname = "compaction_proactiveness",
--
2.37.2
Powered by blists - more mailing lists