From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45427C48BE8 for ; Sat, 19 Jun 2021 02:34:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C75B16052B for ; Sat, 19 Jun 2021 02:34:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C75B16052B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0BE456B006E; Fri, 18 Jun 2021 22:34:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 095E66B0070; Fri, 18 Jun 2021 22:34:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E79956B0072; Fri, 18 Jun 2021 22:34:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0148.hostedemail.com [216.40.44.148]) by kanga.kvack.org (Postfix) with ESMTP id B4F386B006E for ; Fri, 18 Jun 2021 22:34:16 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3E220181AEF10 for ; Sat, 19 Jun 2021 02:34:16 +0000 (UTC) X-FDA: 78268904112.21.5813B69 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by imf11.hostedemail.com (Postfix) with ESMTP id 6465E20010BB for ; Sat, 19 Jun 2021 02:34:14 +0000 (UTC) IronPort-SDR: MAGQi2x0tWLFJPLRFbnSMWVLFs2hbgczbN+Rzm6bLRkwQ6E9MxnnI+MXhCl71QQeLF1gf7bcmx hS0alurCwPaw== X-IronPort-AV: E=McAfee;i="6200,9189,10019"; a="267789607" X-IronPort-AV: E=Sophos;i="5.83,284,1616482800"; d="scan'208";a="267789607" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2021 19:34:02 -0700 IronPort-SDR: o/iJRsDyUnI+QHJwsUmdMtmLyRnRD2HvDnYA9WtJ29HiUcQyeOSQAkg37ZNe7JTOw7Ak4z4l24 XduJHWH4vqww== X-IronPort-AV: E=Sophos;i="5.83,284,1616482800"; d="scan'208";a="555747358" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.159.119]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2021 19:34:00 -0700 From: "Huang, Ying" To: Zi Yan Cc: , , Dave Hansen , Yang Shi , Greg Thelen , Michal Hocko , Wei Xu , David Rientjes , Dan Williams , David Hildenbrand , osalvador Subject: Re: [PATCH -V8 07/10] mm/vmscan: add helper for querying ability to age anonymous pages References: <20210618061537.434999-1-ying.huang@intel.com> <20210618061537.434999-8-ying.huang@intel.com> <9E787EAE-BED4-4902-B34D-F08FD8F21D76@nvidia.com> Date: Sat, 19 Jun 2021 10:33:58 +0800 In-Reply-To: <9E787EAE-BED4-4902-B34D-F08FD8F21D76@nvidia.com> (Zi Yan's message of "Fri, 18 Jun 2021 11:45:50 -0400") Message-ID: <878s36poq1.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Authentication-Results: imf11.hostedemail.com; dkim=none; spf=none (imf11.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none) X-Stat-Signature: 38fez9rp9ugmqbghkq6irtkqe13dgfdx X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6465E20010BB X-HE-Tag: 1624070054-785883 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: Zi Yan writes: > On 18 Jun 2021, at 2:15, Huang Ying wrote: > >> From: Dave Hansen >> >> Anonymous pages are kept on their own LRU(s). These lists could >> theoretically always be scanned and maintained. But, without swap, >> there is currently nothing the kernel can *do* with the results of a >> scanned, sorted LRU for anonymous pages. >> >> A check for '!total_swap_pages' currently serves as a valid check as >> to whether anonymous LRUs should be maintained. However, another >> method will be added shortly: page demotion. >> >> Abstract out the 'total_swap_pages' checks into a helper, give it a >> logically significant name, and check for the possibility of page >> demotion. >> >> Signed-off-by: Dave Hansen >> Signed-off-by: "Huang, Ying" >> Reviewed-by: Yang Shi >> Reviewed-by: Greg Thelen >> Cc: Michal Hocko >> Cc: Wei Xu >> Cc: David Rientjes >> Cc: Dan Williams >> Cc: David Hildenbrand >> Cc: osalvador >> --- >> mm/vmscan.c | 28 +++++++++++++++++++++++++--- >> 1 file changed, 25 insertions(+), 3 deletions(-) >> >> diff --git a/mm/vmscan.c b/mm/vmscan.c >> index 7d5c7216a4b7..8654cec65522 100644 >> --- a/mm/vmscan.c >> +++ b/mm/vmscan.c >> @@ -2706,6 +2706,26 @@ static void get_scan_count(struct lruvec *lruvec,= struct scan_control *sc, >> } >> } >> >> +/* >> + * Anonymous LRU management is a waste if there is >> + * ultimately no way to reclaim the memory. >> + */ >> +bool anon_should_be_aged(struct lruvec *lruvec) >> +{ >> + struct pglist_data *pgdat =3D lruvec_pgdat(lruvec); >> + >> + /* Aging the anon LRU is valuable if swap is present: */ >> + if (total_swap_pages > 0) >> + return true; >> + >> + /* Also valuable if anon pages can be demoted: */ >> + if (next_demotion_node(pgdat->node_id) >=3D 0) > > !=3D NUMA_NO_NODE might be better, even though we know NUMA_NO_NODE > is currently set to -1. Sure. Will change this in the next version. Best Regards, Huang, Ying >> + return true; >> + >> + /* No way to reclaim anon pages. Should not age anon LRUs: */ >> + return false; >> +} >> + >> static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *s= c) >> { >> unsigned long nr[NR_LRU_LISTS]; >> @@ -2815,7 +2835,8 @@ static void shrink_lruvec(struct lruvec *lruvec, s= truct scan_control *sc) >> * Even if we did not try to evict anon pages at all, we want to >> * rebalance the anon lru active/inactive ratio. >> */ >> - if (total_swap_pages && inactive_is_low(lruvec, LRU_INACTIVE_ANON)) >> + if (anon_should_be_aged(lruvec) && >> + inactive_is_low(lruvec, LRU_INACTIVE_ANON)) >> shrink_active_list(SWAP_CLUSTER_MAX, lruvec, >> sc, LRU_ACTIVE_ANON); >> } >> @@ -3644,10 +3665,11 @@ static void age_active_anon(struct pglist_data *= pgdat, >> struct mem_cgroup *memcg; >> struct lruvec *lruvec; >> >> - if (!total_swap_pages) >> + lruvec =3D mem_cgroup_lruvec(NULL, pgdat); >> + >> + if (!anon_should_be_aged(lruvec)) >> return; >> >> - lruvec =3D mem_cgroup_lruvec(NULL, pgdat); >> if (!inactive_is_low(lruvec, LRU_INACTIVE_ANON)) >> return; >> >> --=20 >> 2.30.2 > > > =E2=80=94 > Best Regards, > Yan, Zi