[PATCH] mm: prevent page thrashing

From: Minchan Kim
Date: Wed Jan 28 2015 - 00:01:57 EST


No-Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>
---
mm/vmscan.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 671e47edb584..b258df552e3a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2143,6 +2143,25 @@ out:
denominator);
break;
case SCAN_FILE:
+ if (file && global_reclaim(sc)) {
+ unsigned long zonefile;
+ unsigned long zonefree;
+
+ zonefree = zone_page_state(zone,
+ NR_FREE_PAGES);
+ zonefile = zone_page_state(zone,
+ NR_ACTIVE_FILE) +
+ zone_page_state(zone,
+ NR_INACTIVE_FILE);
+
+ /* OOM is better than code thrashing */
+ if (zonefile + zonefree <=
+ high_wmark_pages(zone)) {
+ size = 0;
+ scan = 0;
+ }
+ break;
+ }
case SCAN_ANON:
/* Scan one type exclusively */
if ((scan_balance == SCAN_FILE) != file) {
--
1.9.1


--
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/