From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Wilson Subject: [PATCH] mm: Throttle shrinkers harder Date: Thu, 10 Apr 2014 08:05:06 +0100 Message-ID: <1397113506-9177-1-git-send-email-chris@chris-wilson.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: linux-mm@kvack.org Cc: Rik van Riel , intel-gfx@lists.freedesktop.org, Dave Chinner , Hugh Dickins , Michal Hocko , Mel Gorman , Johannes Weiner , Andrew Morton , Glauber Costa List-Id: linux-mm.kvack.org 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 Cc: Andrew Morton Cc: Mel Gorman Cc: Michal Hocko Cc: Rik van Riel Cc: Johannes Weiner Cc: Dave Chinner Cc: Glauber Costa Cc: Hugh Dickins Cc: linux-mm@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