<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [ILK/HSW]igt/gem_tiled_swapping randomly causes OOM killer"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=72742#c48">Comment # 48</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [ILK/HSW]igt/gem_tiled_swapping randomly causes OOM killer"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=72742">bug 72742</a>
              from <span class="vcard"><a class="email" href="mailto:chris@chris-wilson.co.uk" title="Chris Wilson <chris@chris-wilson.co.uk>"> <span class="fn">Chris Wilson</span></a>
</span></b>
        <pre>Alternate idea,

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:</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>