From patchwork Wed Oct 16 22:11:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 11194515 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0471F76 for ; Wed, 16 Oct 2019 22:14:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFE6D207FF for ; Wed, 16 Oct 2019 22:14:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFE6D207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 51BA78E0008; Wed, 16 Oct 2019 18:14:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4CF508E0001; Wed, 16 Oct 2019 18:14:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 397518E0008; Wed, 16 Oct 2019 18:14:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 10BA88E0001 for ; Wed, 16 Oct 2019 18:14:18 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id B8B35824556B for ; Wed, 16 Oct 2019 22:14:17 +0000 (UTC) X-FDA: 76051052154.04.meal71_850487583c60 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,dave.hansen@linux.intel.com,:linux-kernel@vger.kernel.org::dan.j.williams@intel.com:dave.hansen@linux.intel.com:keith.busch@intel.com,RULES_HIT:30004:30054:30064,0,RBL:192.55.52.93:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: meal71_850487583c60 X-Filterd-Recvd-Size: 4568 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Oct 2019 22:14:16 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 15:14:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,305,1566889200"; d="scan'208";a="225945438" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga002.fm.intel.com with ESMTP; 16 Oct 2019 15:14:15 -0700 Subject: [PATCH 4/4] mm/vmscan: Consider anonymous pages without swap To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org,dan.j.williams@intel.com,Dave Hansen ,keith.busch@intel.com From: Dave Hansen Date: Wed, 16 Oct 2019 15:11:54 -0700 References: <20191016221148.F9CCD155@viggo.jf.intel.com> In-Reply-To: <20191016221148.F9CCD155@viggo.jf.intel.com> Message-Id: <20191016221154.CDD7064D@viggo.jf.intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Keith Busch Age and reclaim anonymous pages if a migration path is available. The node has other recourses for inactive anonymous pages beyond swap, Signed-off-by: Keith Busch Co-developed-by: Dave Hansen Signed-off-by: Dave Hansen --- b/include/linux/swap.h | 20 ++++++++++++++++++++ b/mm/vmscan.c | 10 +++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff -puN include/linux/swap.h~0006-mm-vmscan-Consider-anonymous-pages-without-swap include/linux/swap.h --- a/include/linux/swap.h~0006-mm-vmscan-Consider-anonymous-pages-without-swap 2019-10-16 15:06:59.474952590 -0700 +++ b/include/linux/swap.h 2019-10-16 15:06:59.481952590 -0700 @@ -680,5 +680,25 @@ static inline bool mem_cgroup_swap_full( } #endif +static inline bool reclaim_anon_pages(struct mem_cgroup *memcg, + int node_id) +{ + /* Always age anon pages when we have swap */ + if (memcg == NULL) { + if (get_nr_swap_pages() > 0) + return true; + } else { + if (mem_cgroup_get_nr_swap_pages(memcg) > 0) + return true; + } + + /* Also age anon pages if we can auto-migrate them */ + if (next_migration_node(node_id) >= 0) + return true; + + /* No way to reclaim anon pages */ + return false; +} + #endif /* __KERNEL__*/ #endif /* _LINUX_SWAP_H */ diff -puN mm/vmscan.c~0006-mm-vmscan-Consider-anonymous-pages-without-swap mm/vmscan.c --- a/mm/vmscan.c~0006-mm-vmscan-Consider-anonymous-pages-without-swap 2019-10-16 15:06:59.477952590 -0700 +++ b/mm/vmscan.c 2019-10-16 15:06:59.482952590 -0700 @@ -327,7 +327,7 @@ unsigned long zone_reclaimable_pages(str nr = zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_FILE) + zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_FILE); - if (get_nr_swap_pages() > 0) + if (reclaim_anon_pages(NULL, zone_to_nid(zone))) nr += zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_ANON) + zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_ANON); @@ -2166,7 +2166,7 @@ static bool inactive_list_is_low(struct * If we don't have swap space, anonymous page deactivation * is pointless. */ - if (!file && !total_swap_pages) + if (!file && !reclaim_anon_pages(NULL, pgdat->node_id)) return false; inactive = lruvec_lru_size(lruvec, inactive_lru, sc->reclaim_idx); @@ -2241,7 +2241,7 @@ static void get_scan_count(struct lruvec enum lru_list lru; /* If we have no swap space, do not bother scanning anon pages. */ - if (!sc->may_swap || mem_cgroup_get_nr_swap_pages(memcg) <= 0) { + if (!sc->may_swap || !reclaim_anon_pages(memcg, pgdat->node_id)) { scan_balance = SCAN_FILE; goto out; } @@ -2604,7 +2604,7 @@ static inline bool should_continue_recla */ pages_for_compaction = compact_gap(sc->order); inactive_lru_pages = node_page_state(pgdat, NR_INACTIVE_FILE); - if (get_nr_swap_pages() > 0) + if (!reclaim_anon_pages(NULL, pgdat->node_id)) inactive_lru_pages += node_page_state(pgdat, NR_INACTIVE_ANON); if (sc->nr_reclaimed < pages_for_compaction && inactive_lru_pages > pages_for_compaction) @@ -3289,7 +3289,7 @@ static void age_active_anon(struct pglis { struct mem_cgroup *memcg; - if (!total_swap_pages) + if (!reclaim_anon_pages(NULL, pgdat->node_id)) return; memcg = mem_cgroup_iter(NULL, NULL, NULL);