Skip to content

Commit

Permalink
[PATCH] oom: reclaim_mapped on oom
Browse files Browse the repository at this point in the history
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 <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Sep 26, 2006
1 parent 408d854 commit 4ff1ffb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,11 @@ static unsigned long shrink_inactive_list(unsigned long max_scan,
return nr_reclaimed;
}

static inline int zone_is_near_oom(struct zone *zone)
{
return zone->pages_scanned >= (zone->nr_active + zone->nr_inactive)*3;
}

/*
* This moves pages from the active list to the inactive list.
*
Expand Down Expand Up @@ -732,6 +737,9 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
long distress;
long swap_tendency;

if (zone_is_near_oom(zone))
goto force_reclaim_mapped;

/*
* `distress' is a measure of how much trouble we're having
* reclaiming pages. 0 -> no problems. 100 -> great trouble.
Expand Down Expand Up @@ -767,6 +775,7 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
* memory onto the inactive list.
*/
if (swap_tendency >= 100)
force_reclaim_mapped:
reclaim_mapped = 1;
}

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

0 comments on commit 4ff1ffb

Please sign in to comment.