Skip to content

Commit 408d854

Browse files
Nick PigginLinus Torvalds
authored andcommitted
[PATCH] oom: use unreclaimable info
__alloc_pages currently starts shooting if page reclaim has failed to free up swap_cluster_max pages in one run through the priorities. This is not always a good indicator on its own, so make use of the all_unreclaimable logic as well: don't consider going OOM until all zones we're interested in are unreclaimable. Signed-off-by: Nick Piggin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6ddab3b commit 408d854

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mm/vmscan.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ struct scan_control {
6262
int swap_cluster_max;
6363

6464
int swappiness;
65+
66+
int all_unreclaimable;
6567
};
6668

6769
/*
@@ -925,6 +927,7 @@ static unsigned long shrink_zones(int priority, struct zone **zones,
925927
unsigned long nr_reclaimed = 0;
926928
int i;
927929

930+
sc->all_unreclaimable = 1;
928931
for (i = 0; zones[i] != NULL; i++) {
929932
struct zone *zone = zones[i];
930933

@@ -941,6 +944,8 @@ static unsigned long shrink_zones(int priority, struct zone **zones,
941944
if (zone->all_unreclaimable && priority != DEF_PRIORITY)
942945
continue; /* Let kswapd poll it */
943946

947+
sc->all_unreclaimable = 0;
948+
944949
nr_reclaimed += shrink_zone(priority, zone, sc);
945950
}
946951
return nr_reclaimed;
@@ -1021,6 +1026,9 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
10211026
if (sc.nr_scanned && priority < DEF_PRIORITY - 2)
10221027
blk_congestion_wait(WRITE, HZ/10);
10231028
}
1029+
/* top priority shrink_caches still had more to do? don't OOM, then */
1030+
if (!sc.all_unreclaimable)
1031+
ret = 1;
10241032
out:
10251033
for (i = 0; zones[i] != 0; i++) {
10261034
struct zone *zone = zones[i];

0 commit comments

Comments
 (0)