[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <AD13664F485EE54694E29A7F9D5BE1AF4D35F3@039-SN2MPN1-021.039d.mgd.msft.net>
Date: Thu, 27 Dec 2012 11:21:48 +0000
From: Liu Hui-R64343 <r64343@...escale.com>
To: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: "mgorman@...e.de" <mgorman@...e.de>
Subject: echo 1 > /proc/sys/vm/compact_memory -> sh: write error: Bad address
I met one error when does the following command:
sh/$ echo 1 > /proc/sys/vm/compact_memory
sh/$ sh: write error: Bad address
After using strace, I find the following:
...
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
>From the code, we can see it will return COMPACT_COMPLETE = 3 always when write.
/* Compact all nodes in the system */
static int compact_nodes(void)
{
int nid;
/* Flush pending updates to the LRU lists */
lru_add_drain_all();
for_each_online_node(nid)
compact_node(nid);
return COMPACT_COMPLETE;
}
/* The written value is actually unused, all memory is compacted */
int sysctl_compact_memory;
/* This is the entry point for compacting all nodes via /proc/sys/vm */
int sysctl_compaction_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
{
if (write)
return compact_nodes();
return 0;
}
I think we can't simply return COMPACT_COMPLETE, instead, we need return *length.
The following patch can fix this issue:
diff --git a/mm/compaction.c b/mm/compaction.c
index c4bc5ac..d3cb27f 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -732,8 +732,10 @@ int sysctl_compact_memory;
int sysctl_compaction_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
{
- if (write)
- return compact_nodes();
+ if (write) {
+ compact_nodes();
+ return *length;
+ }
return 0;
}
Anyone can comment on it? Thanks a lot.
Happy Holiday.
Best Regards,
Jason Liu
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists