From patchwork Fri Jun 25 07:32:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12343845 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 8E02DC48BC2 for ; Fri, 25 Jun 2021 07:33:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 44FFE61426 for ; Fri, 25 Jun 2021 07:33:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44FFE61426 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 0F3C28D0008; Fri, 25 Jun 2021 03:33:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02EBE8D0002; Fri, 25 Jun 2021 03:33:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEAAB8D0008; Fri, 25 Jun 2021 03:33:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id ADBE68D0002 for ; Fri, 25 Jun 2021 03:33:40 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 35A61231CF for ; Fri, 25 Jun 2021 07:33:39 +0000 (UTC) X-FDA: 78291431358.10.A4485AE Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf13.hostedemail.com (Postfix) with ESMTP id 922A0E00025F for ; Fri, 25 Jun 2021 07:33:38 +0000 (UTC) IronPort-SDR: q3D8yZAUhvTJZWKf7AUNYW26XY0Pg/UmUr2eQqXDSeY4wZ+pm31d1F96b+RBE0OlEmqv6qGxx9 DrnXw8yWC2sw== X-IronPort-AV: E=McAfee;i="6200,9189,10025"; a="188008068" X-IronPort-AV: E=Sophos;i="5.83,298,1616482800"; d="scan'208";a="188008068" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2021 00:33:36 -0700 IronPort-SDR: NSFMj7XbFgLvOw8gMekN598DkwnQ1ypoaHNK5Xy+mbVxzSW2VZ3hShm9BCQqml9e6qyBWA0p0K zXIueUO91tKA== X-IronPort-AV: E=Sophos;i="5.83,298,1616482800"; d="scan'208";a="488085915" Received: from msun2-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl1.ccr.corp.intel.com) ([10.254.215.50]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2021 00:33:28 -0700 From: Huang Ying To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Dave Hansen , "Huang, Ying" , Yang Shi , Yang Shi , Michal Hocko , Wei Xu , osalvador , Zi Yan , David Rientjes , Dan Williams , David Hildenbrand Subject: [PATCH -V9 8/9] mm/vmscan: never demote for memcg reclaim Date: Fri, 25 Jun 2021 15:32:03 +0800 Message-Id: <20210625073204.1005986-9-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210625073204.1005986-1-ying.huang@intel.com> References: <20210625073204.1005986-1-ying.huang@intel.com> MIME-Version: 1.0 Authentication-Results: imf13.hostedemail.com; dkim=none; spf=none (imf13.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=ying.huang@intel.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none) X-Stat-Signature: 7rtq8tphmqn7u5jrwwx9w8bpb7xsyrq7 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 922A0E00025F X-HE-Tag: 1624606418-728028 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: Dave Hansen Global reclaim aims to reduce the amount of memory used on a given node or set of nodes. Migrating pages to another node serves this purpose. memcg reclaim is different. Its goal is to reduce the total memory consumption of the entire memcg, across all nodes. Migration does not assist memcg reclaim because it just moves page contents between nodes rather than actually reducing memory consumption. Signed-off-by: Dave Hansen Signed-off-by: "Huang, Ying" Suggested-by: Yang Shi Reviewed-by: Yang Shi Cc: Michal Hocko Cc: Wei Xu Cc: osalvador Cc: Zi Yan Cc: David Rientjes Cc: Dan Williams Cc: David Hildenbrand --- changes from 20210618: * Avoid to scan anon lists for demotion for cgroup reclaim. --- mm/vmscan.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index fce43c7970d7..e3cc356369fd 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -540,8 +540,9 @@ static inline bool can_reclaim_anon_pages(struct mem_cgroup *memcg, * The page can not be swapped. * * Can it be reclaimed from this node via demotion? + * But it's pointless to do demotion in memcg reclaim. */ - if ((!sc || !sc->no_demotion) && + if ((!sc || (!sc->no_demotion && !cgroup_reclaim(sc))) && next_demotion_node(node_id) != NUMA_NO_NODE) return true; @@ -1276,6 +1277,9 @@ static bool migrate_demote_page_ok(struct page *page, if (sc->no_demotion) return false; + /* It is pointless to do demotion in memcg reclaim */ + if (cgroup_reclaim(sc)) + return false; next_nid = next_demotion_node(page_to_nid(page)); if (next_nid == NUMA_NO_NODE) return false; @@ -2759,7 +2763,7 @@ static bool anon_can_be_aged(struct pglist_data *pgdat, return true; /* Also valuable if anon pages can be demoted: */ - if (!sc->no_demotion && + if (!sc->no_demotion && !cgroup_reclaim(sc) && next_demotion_node(pgdat->node_id) != NUMA_NO_NODE) return true;