[RFC][PATCH -mm 2/2] mm: make shrink_all_memory try harder

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make shrink_all_memory() repeat the attempts to free more memory if there
seems to be no pages to free.


Signed-off-by: Rafael J. Wysocki <[email protected]>
---
 mm/vmscan.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

Index: linux-2.6.16-rc4-mm2/mm/vmscan.c
===================================================================
--- linux-2.6.16-rc4-mm2.orig/mm/vmscan.c
+++ linux-2.6.16-rc4-mm2/mm/vmscan.c
@@ -33,6 +33,7 @@
 #include <linux/cpuset.h>
 #include <linux/notifier.h>
 #include <linux/rwsem.h>
+#include <linux/delay.h>
 
 #include <asm/tlbflush.h>
 #include <asm/div64.h>
@@ -1793,17 +1794,24 @@ unsigned long shrink_all_memory(unsigned
 	struct reclaim_state reclaim_state = {
 		.reclaimed_slab = 0,
 	};
+	int retry = 2;
 
 	current->reclaim_state = &reclaim_state;
-	for_each_pgdat(pgdat) {
-		unsigned long freed;
+	do {
+		for_each_pgdat(pgdat) {
+			unsigned long freed;
 
-		freed = balance_pgdat(pgdat, nr_to_free, 0);
-		ret += freed;
-		nr_to_free -= freed;
-		if (nr_to_free <= 0)
+			freed = balance_pgdat(pgdat, nr_to_free, 0);
+			ret += freed;
+			nr_to_free -= freed;
+			if (nr_to_free <= 0)
+				break;
+		}
+		if (ret > 0)
 			break;
-	}
+		if (retry)
+			msleep_interruptible(100);
+	} while (retry--);
 	current->reclaim_state = NULL;
 	return ret;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux