linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC] [PATCH] memcg: fix infinite loop
@ 2009-01-15  6:07 Li Zefan
  2009-01-15  6:15 ` Balbir Singh
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Li Zefan @ 2009-01-15  6:07 UTC (permalink / raw)
  To: Balbir Singh, KAMEZAWA Hiroyuki; +Cc: Daisuke Nishimura, linux-mm@kvack.org

1. task p1 is in /memcg/0
2. p1 does mmap(4096*2, MAP_LOCKED)
3. echo 4096 > /memcg/0/memory.limit_in_bytes

The above 'echo' will never return, unless p1 exited or freed the memory.
The cause is we can't reclaim memory from p1, so the while loop in
mem_cgroup_resize_limit() won't break.

This patch fixes it by decrementing retry_count regardless the return value
of mem_cgroup_hierarchical_reclaim().

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 mm/memcontrol.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index fb62b43..1995098 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1524,11 +1524,10 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
 {
 
 	int retry_count = MEM_CGROUP_RECLAIM_RETRIES;
-	int progress;
 	u64 memswlimit;
 	int ret = 0;
 
-	while (retry_count) {
+	while (retry_count--) {
 		if (signal_pending(current)) {
 			ret = -EINTR;
 			break;
@@ -1551,9 +1550,7 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
 		if (!ret)
 			break;
 
-		progress = mem_cgroup_hierarchical_reclaim(memcg, GFP_KERNEL,
-							   false);
-  		if (!progress)			retry_count--;
+		mem_cgroup_hierarchical_reclaim(memcg, GFP_KERNEL, false);
 	}
 
 	return ret;
@@ -1563,13 +1560,13 @@ int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,
 				unsigned long long val)
 {
 	int retry_count = MEM_CGROUP_RECLAIM_RETRIES;
-	u64 memlimit, oldusage, curusage;
+	u64 memlimit;
 	int ret;
 
 	if (!do_swap_account)
 		return -EINVAL;
 
-	while (retry_count) {
+	while (retry_count--) {
 		if (signal_pending(current)) {
 			ret = -EINTR;
 			break;
@@ -1592,11 +1589,7 @@ int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,
 		if (!ret)
 			break;
 
-		oldusage = res_counter_read_u64(&memcg->memsw, RES_USAGE);
 		mem_cgroup_hierarchical_reclaim(memcg, GFP_KERNEL, true);
-		curusage = res_counter_read_u64(&memcg->memsw, RES_USAGE);
-		if (curusage >= oldusage)
-			retry_count--;
 	}
 	return ret;
 }
-- 
1.5.4.rc3


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-01-19 10:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-15  6:07 [RFC] [PATCH] memcg: fix infinite loop Li Zefan
2009-01-15  6:15 ` Balbir Singh
2009-01-15  6:31   ` KAMEZAWA Hiroyuki
2009-01-15  7:14     ` Li Zefan
2009-01-15  7:21       ` KAMEZAWA Hiroyuki
2009-01-15  7:26         ` Balbir Singh
2009-01-15  7:32         ` Li Zefan
2009-01-15  7:35           ` KAMEZAWA Hiroyuki
2009-01-15  6:16 ` Daisuke Nishimura
2009-01-15  6:27   ` Li Zefan
2009-01-19  8:49 ` KAMEZAWA Hiroyuki
2009-01-19  9:57   ` Balbir Singh
2009-01-19 10:07     ` KAMEZAWA Hiroyuki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).