From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751301AbdEaPUM (ORCPT ); Wed, 31 May 2017 11:20:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:47105 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751187AbdEaPUK (ORCPT ); Wed, 31 May 2017 11:20:10 -0400 Date: Wed, 31 May 2017 17:20:07 +0200 From: Michal Hocko To: Andrew Morton Cc: David Rientjes , Minchan Kim , Johannes Weiner , Mel Gorman , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch v2] mm, vmscan: avoid thrashing anon lru when free + file is low Message-ID: <20170531152007.GS27783@dhcp22.suse.cz> References: <20170418013659.GD21354@bbox> <20170419001405.GA13364@bbox> <20170420060904.GA3720@bbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrew, it seems that this patch fallen through cracks. I am sorry if this was due to my review feedback because it turned out that I missed the point and later added my Acked-by. Sorry about that On Mon 01-05-17 14:34:21, David Rientjes wrote: > The purpose of the code that commit 623762517e23 ("revert 'mm: vmscan: do > not swap anon pages just because free+file is low'") reintroduces is to > prefer swapping anonymous memory rather than trashing the file lru. > > If the anonymous inactive lru for the set of eligible zones is considered > low, however, or the length of the list for the given reclaim priority > does not allow for effective anonymous-only reclaiming, then avoid > forcing SCAN_ANON. Forcing SCAN_ANON will end up thrashing the small > list and leave unreclaimed memory on the file lrus. > > If the inactive list is insufficient, fallback to balanced reclaim so the > file lru doesn't remain untouched. > > Suggested-by: Minchan Kim > Signed-off-by: David Rientjes > --- > to akpm: this issue has been possible since at least 3.15, so it's > probably not high priority for 4.12 but applies cleanly if it can sneak > in > > mm/vmscan.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2204,8 +2204,17 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg, > } > > if (unlikely(pgdatfile + pgdatfree <= total_high_wmark)) { > - scan_balance = SCAN_ANON; > - goto out; > + /* > + * Force SCAN_ANON if there are enough inactive > + * anonymous pages on the LRU in eligible zones. > + * Otherwise, the small LRU gets thrashed. > + */ > + if (!inactive_list_is_low(lruvec, false, sc, false) && > + lruvec_lru_size(lruvec, LRU_INACTIVE_ANON, sc->reclaim_idx) > + >> sc->priority) { > + scan_balance = SCAN_ANON; > + goto out; > + } > } > } > > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id 359466B02F3 for ; Wed, 31 May 2017 11:20:11 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id d127so3548548wmf.15 for ; Wed, 31 May 2017 08:20:11 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id o3si13814891wmi.82.2017.05.31.08.20.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 31 May 2017 08:20:09 -0700 (PDT) Date: Wed, 31 May 2017 17:20:07 +0200 From: Michal Hocko Subject: Re: [patch v2] mm, vmscan: avoid thrashing anon lru when free + file is low Message-ID: <20170531152007.GS27783@dhcp22.suse.cz> References: <20170418013659.GD21354@bbox> <20170419001405.GA13364@bbox> <20170420060904.GA3720@bbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: David Rientjes , Minchan Kim , Johannes Weiner , Mel Gorman , linux-kernel@vger.kernel.org, linux-mm@kvack.org Andrew, it seems that this patch fallen through cracks. I am sorry if this was due to my review feedback because it turned out that I missed the point and later added my Acked-by. Sorry about that On Mon 01-05-17 14:34:21, David Rientjes wrote: > The purpose of the code that commit 623762517e23 ("revert 'mm: vmscan: do > not swap anon pages just because free+file is low'") reintroduces is to > prefer swapping anonymous memory rather than trashing the file lru. > > If the anonymous inactive lru for the set of eligible zones is considered > low, however, or the length of the list for the given reclaim priority > does not allow for effective anonymous-only reclaiming, then avoid > forcing SCAN_ANON. Forcing SCAN_ANON will end up thrashing the small > list and leave unreclaimed memory on the file lrus. > > If the inactive list is insufficient, fallback to balanced reclaim so the > file lru doesn't remain untouched. > > Suggested-by: Minchan Kim > Signed-off-by: David Rientjes > --- > to akpm: this issue has been possible since at least 3.15, so it's > probably not high priority for 4.12 but applies cleanly if it can sneak > in > > mm/vmscan.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2204,8 +2204,17 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg, > } > > if (unlikely(pgdatfile + pgdatfree <= total_high_wmark)) { > - scan_balance = SCAN_ANON; > - goto out; > + /* > + * Force SCAN_ANON if there are enough inactive > + * anonymous pages on the LRU in eligible zones. > + * Otherwise, the small LRU gets thrashed. > + */ > + if (!inactive_list_is_low(lruvec, false, sc, false) && > + lruvec_lru_size(lruvec, LRU_INACTIVE_ANON, sc->reclaim_idx) > + >> sc->priority) { > + scan_balance = SCAN_ANON; > + goto out; > + } > } > } > > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org