During testing of i915.ko with working texture sets larger than RAM, we
encounter OOM with plenty of memory still trapped within writeback, e.g:

[   42.386039] active_anon:10134 inactive_anon:1900781 isolated_anon:32
 active_file:33 inactive_file:39 isolated_file:0
 unevictable:0 dirty:0 writeback:337627 unstable:0
 free:11985 slab_reclaimable:9458 slab_unreclaimable:23614
 mapped:41 shmem:1560769 pagetables:1276 bounce:0

If we throttle for writeback following shrink_slab, this gives us time
to wait upon the writeback generated by the i915.ko shinker:

[ 4756.750808] active_anon:24386 inactive_anon:900793 isolated_anon:0
 active_file:23 inactive_file:20 isolated_file:0
 unevictable:0 dirty:0 writeback:0 unstable:0
 free:5550 slab_reclaimable:5184 slab_unreclaimable:4888
 mapped:3 shmem:472393 pagetables:1249 bounce:0

(Sadly though the test is still failing.)

Testcase: igt/gem_tiled_swapping
References: https://bugs.freedesktop.org/show_bug.cgi?id=72742
Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: Mel Gorman <mgor...@suse.de>
Cc: Michal Hocko <mho...@suse.cz>
Cc: Rik van Riel <r...@redhat.com>
Cc: Johannes Weiner <han...@cmpxchg.org>
Cc: Dave Chinner <dchin...@redhat.com>
Cc: Glauber Costa <glom...@openvz.org>
Cc: Hugh Dickins <hu...@google.com>
Cc: linux...@kvack.org
---
 mm/vmscan.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index a9c74b409681..8c2cb1150d17 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -135,6 +135,10 @@ unsigned long vm_total_pages;      /* The total number of 
pages which the VM controls
 static LIST_HEAD(shrinker_list);
 static DECLARE_RWSEM(shrinker_rwsem);
 
+static bool throttle_direct_reclaim(gfp_t gfp_mask,
+                                   struct zonelist *zonelist,
+                                   nodemask_t *nodemask);
+
 #ifdef CONFIG_MEMCG
 static bool global_reclaim(struct scan_control *sc)
 {
@@ -1521,7 +1525,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct 
lruvec *lruvec,
         * of pages under pages flagged for immediate reclaim and stall if any
         * are encountered in the nr_immediate check below.
         */
-       if (nr_writeback && nr_writeback == nr_taken)
+       if (nr_writeback > nr_taken / 2)
                zone_set_flag(zone, ZONE_WRITEBACK);
 
        /*
@@ -2465,6 +2469,12 @@ static unsigned long do_try_to_free_pages(struct 
zonelist *zonelist,
                                                WB_REASON_TRY_TO_FREE_PAGES);
                        sc->may_writepage = 1;
                }
+
+               if (global_reclaim(sc) &&
+                   throttle_direct_reclaim(sc->gfp_mask,
+                                           zonelist,
+                                           sc->nodemask))
+                       aborted_reclaim = true;
        } while (--sc->priority >= 0 && !aborted_reclaim);
 
 out:
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to