Skip to content

Commit

Permalink
[PATCH] mm: make shrink_all_memory try harder
Browse files Browse the repository at this point in the history
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 <rjw@sisk.pl>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Rafael J. Wysocki authored and Linus Torvalds committed Mar 22, 2006
1 parent d5d4b0a commit 248a030
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -1784,11 +1785,13 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
pg_data_t *pgdat;
unsigned long nr_to_free = nr_pages;
unsigned long ret = 0;
unsigned retry = 2;
struct reclaim_state reclaim_state = {
.reclaimed_slab = 0,
};

current->reclaim_state = &reclaim_state;
repeat:
for_each_pgdat(pgdat) {
unsigned long freed;

Expand All @@ -1798,6 +1801,10 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
if ((long)nr_to_free <= 0)
break;
}
if (retry-- && ret < nr_pages) {
blk_congestion_wait(WRITE, HZ/5);
goto repeat;
}
current->reclaim_state = NULL;
return ret;
}
Expand Down

0 comments on commit 248a030

Please sign in to comment.