===================================================================
--- kernel-2.6.28.orig/mm/vmscan.c
+++ kernel-2.6.28/mm/vmscan.c
-@@ -1024,6 +1024,47 @@ int isolate_lru_page(struct page *page)
+@@ -52,6 +52,12 @@ struct scan_control {
+ /* Incremented by the number of inactive pages that were scanned */
+ unsigned long nr_scanned;
+
++ /* Number of pages freed so far during a call to shrink_zones() */
++ unsigned long nr_reclaimed;
++
++ /* How many pages shrink_list() should reclaim */
++ unsigned long nr_to_reclaim;
++
+ /* This context's GFP mask */
+ gfp_t gfp_mask;
+
+@@ -72,6 +78,12 @@ struct scan_control {
+
+ int order;
+
++ /*
++ * Intend to reclaim enough contenious memory rather than to reclaim
++ * enough amount memory. I.e, it's the mode for high order allocation.
++ */
++ bool lumpy_reclaim_mode;
++
+ /* Which cgroup do we reclaim from */
+ struct mem_cgroup *mem_cgroup;
+
+@@ -549,7 +561,6 @@ void putback_lru_page(struct page *page)
+ }
+ #endif /* CONFIG_UNEVICTABLE_LRU */
+
+-
+ /*
+ * shrink_page_list() returns the number of reclaimed pages
+ */
+@@ -613,8 +624,10 @@ static unsigned long shrink_page_list(st
+
+ referenced = page_referenced(page, 1, sc->mem_cgroup);
+ /* In active use or really unfreeable? Activate it. */
+- if (sc->order <= PAGE_ALLOC_COSTLY_ORDER &&
+- referenced && page_mapping_inuse(page))
++ if ( ( sc->order <= PAGE_ALLOC_COSTLY_ORDER &&
++ referenced && page_mapping_inuse(page)
++ ) || sc->lumpy_reclaim_mode /* ignore refrences in lumpy reclaim mode */
++ )
+ goto activate_locked;
+
+ #ifdef CONFIG_SWAP
+@@ -1024,6 +1037,47 @@ int isolate_lru_page(struct page *page)
}
/*
* shrink_inactive_list() is a helper for shrink_zone(). It returns the number
* of reclaimed pages
*/
-@@ -1088,15 +1129,8 @@ static unsigned long shrink_inactive_lis
+@@ -1047,7 +1101,7 @@ static unsigned long shrink_inactive_lis
+ unsigned long nr_freed;
+ unsigned long nr_active;
+ unsigned int count[NR_LRU_LISTS] = { 0, };
+- int mode = ISOLATE_INACTIVE;
++ int mode = sc->lumpy_reclaim_mode ? ISOLATE_BOTH : ISOLATE_INACTIVE;
+
+ /*
+ * If we need a large contiguous chunk of memory, or have
+@@ -1088,15 +1142,8 @@ static unsigned long shrink_inactive_lis
nr_scanned += nr_scan;
nr_freed = shrink_page_list(&page_list, sc, PAGEOUT_IO_ASYNC);
/*
* The attempt at page out may have made some
+@@ -1404,6 +1451,20 @@ static void get_scan_ratio(struct zone *
+ percent[1] = 100 - percent[0];
+ }
+
++static void set_lumpy_reclaim_mode(int priority, struct scan_control *sc)
++{
++ /*
++ * If we need a large contiguous chunk of memory, or have
++ * trouble getting a small set of contiguous pages, we
++ * will reclaim both active and inactive pages.
++ */
++ if (sc->order > PAGE_ALLOC_COSTLY_ORDER)
++ sc->lumpy_reclaim_mode = 1;
++ else if (sc->order && priority < DEF_PRIORITY - 2)
++ sc->lumpy_reclaim_mode = 1;
++ else
++ sc->lumpy_reclaim_mode = 0;
++}
+
+ /*
+ * This is a basic per-zone page freer. Used by both kswapd and direct reclaim.
+@@ -1419,6 +1480,8 @@ static unsigned long shrink_zone(int pri
+
+ get_scan_ratio(zone, sc, percent);
+
++ set_lumpy_reclaim_mode(priority, sc);
++
+ for_each_evictable_lru(l) {
+ if (scan_global_lru(sc)) {
+ int file = is_file_lru(l);