Skip to content

Commit 7964c06

Browse files
LiuHui-Jasontorvalds
authored andcommitted
mm: compaction: fix echo 1 > compact_memory return error issue
when run the folloing command under shell, it will return error sh/$ echo 1 > /proc/sys/vm/compact_memory sh/$ sh: write error: Bad address After strace, I found the following log: ... write(1, "1\n", 2) = 3 write(1, "", 4294967295) = -1 EFAULT (Bad address) write(2, "echo: write error: Bad address\n", 31echo: write error: Bad address ) = 31 This tells system return 3(COMPACT_COMPLETE) after write data to compact_memory. The fix is to make the system just return 0 instead 3(COMPACT_COMPLETE) from sysctl_compaction_handler after compaction_nodes finished. Signed-off-by: Jason Liu <[email protected]> Suggested-by: David Rientjes <[email protected]> Acked-by: Mel Gorman <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Minchan Kim <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Acked-by: David Rientjes <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c0232ae commit 7964c06

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mm/compaction.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ static int compact_node(int nid)
12101210
}
12111211

12121212
/* Compact all nodes in the system */
1213-
static int compact_nodes(void)
1213+
static void compact_nodes(void)
12141214
{
12151215
int nid;
12161216

@@ -1219,8 +1219,6 @@ static int compact_nodes(void)
12191219

12201220
for_each_online_node(nid)
12211221
compact_node(nid);
1222-
1223-
return COMPACT_COMPLETE;
12241222
}
12251223

12261224
/* The written value is actually unused, all memory is compacted */
@@ -1231,7 +1229,7 @@ int sysctl_compaction_handler(struct ctl_table *table, int write,
12311229
void __user *buffer, size_t *length, loff_t *ppos)
12321230
{
12331231
if (write)
1234-
return compact_nodes();
1232+
compact_nodes();
12351233

12361234
return 0;
12371235
}

0 commit comments

Comments
 (0)