Skip to content

Commit 4ff1ffb

Browse files
Nick PigginLinus Torvalds
authored andcommitted
[PATCH] oom: reclaim_mapped on oom
Potentially it takes several scans of the lru lists before we can even start reclaiming pages. mapped pages, with young ptes can take 2 passes on the active list + one on the inactive list. But reclaim_mapped may not always kick in instantly, so it could take even more than that. Raise the threshold for marking a zone as all_unreclaimable from a factor of 4 time the pages in the zone to 6. Introduce a mechanism to force reclaim_mapped if we've reached a factor 3 and still haven't made progress. Previously, a customer doing stress testing was able to easily OOM the box after using only a small fraction of its swap (~100MB). After the patches, it would only OOM after having used up all swap (~800MB). Signed-off-by: Nick Piggin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 408d854 commit 4ff1ffb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mm/vmscan.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,11 @@ static unsigned long shrink_inactive_list(unsigned long max_scan,
697697
return nr_reclaimed;
698698
}
699699

700+
static inline int zone_is_near_oom(struct zone *zone)
701+
{
702+
return zone->pages_scanned >= (zone->nr_active + zone->nr_inactive)*3;
703+
}
704+
700705
/*
701706
* This moves pages from the active list to the inactive list.
702707
*
@@ -732,6 +737,9 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
732737
long distress;
733738
long swap_tendency;
734739

740+
if (zone_is_near_oom(zone))
741+
goto force_reclaim_mapped;
742+
735743
/*
736744
* `distress' is a measure of how much trouble we're having
737745
* reclaiming pages. 0 -> no problems. 100 -> great trouble.
@@ -767,6 +775,7 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
767775
* memory onto the inactive list.
768776
*/
769777
if (swap_tendency >= 100)
778+
force_reclaim_mapped:
770779
reclaim_mapped = 1;
771780
}
772781

@@ -1161,7 +1170,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
11611170
if (zone->all_unreclaimable)
11621171
continue;
11631172
if (nr_slab == 0 && zone->pages_scanned >=
1164-
(zone->nr_active + zone->nr_inactive) * 4)
1173+
(zone->nr_active + zone->nr_inactive) * 6)
11651174
zone->all_unreclaimable = 1;
11661175
/*
11671176
* If we've done a decent amount of scanning and

0 commit comments

Comments
 (0)