Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3775423pxb; Tue, 26 Jan 2021 04:37:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzX209DeW7QoLCSJ+1SnC7lijQueRTbqpME/xvuhFN1BuJZGFlLGTFPi7aly77Kj0oZUf9f X-Received: by 2002:aa7:d44c:: with SMTP id q12mr4378695edr.368.1611664636859; Tue, 26 Jan 2021 04:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611664636; cv=none; d=google.com; s=arc-20160816; b=mRtEocdQoCNY3QmwDI+ZvcdOAlI1qs+vrYHYVp3lb3AECkYXSgDIwuhq+fgmAxeMlh nNEAaiChg755w8WxQzjfnbNrpj5IzLBwb17Im09YIrdEDPijz7AIGwAbconJ5lMa23eJ SypF53ipbvdSYfg2MO3su4CFdgVMUmHcBzDau2QIuNuheaH0u43pIBr3fO6czpcailR1 M1s5pnE7vfP96qw2VJiM/jYk2TKjo5XQGSGVzVc9SiLPmw9PmuEd7fcO5Dd2pYS5YaNF 0t6C+qvp/Zj7yRk8Xxry3pu1I2UFML4CdPlNGDVmJsPFKUZEK4hhrE6Evmr7vW9UcYqR 0NDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:in-reply-to:references:date:from:cc :to:subject:ironport-sdr:ironport-sdr; bh=8dDCmzSLc19gfGhYRPIPCG4QAtkNwbiuusgr96jj+OU=; b=yUwzq6mm+zjFYESZflH5a2DMTQqKcpMF7uH6wYFeGZHCdGS3MXDQXhxz8u9EiwHlZ1 eDVwNulqUn/2dZSTdKVo4Xjqbc0Qvyb/TO0zmEuaf51qMS4zMQHvuaym311BPPO7dbUs lT/oUoZOxl4siZPnfSuKH5g6OnWHfkeiKy4RiZhrWOs6Stu63P7Vd1bngH9zbjt2+fb9 1JVKBWg9sxjgAtKC/c2DTFWTVsVWv8f57gLeXHFm0bmzJA4EQRWJR4uGlkglQXYUdVuM eJxZdOETua7TnQMcdtNfoSMGZcmvTgyfNfsEv5ybblqoh0xj85D7OJaA5lnyDqY6R6vA yiFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v12si8386735edy.585.2021.01.26.04.36.52; Tue, 26 Jan 2021 04:37:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403989AbhAZKY5 (ORCPT + 99 others); Tue, 26 Jan 2021 05:24:57 -0500 Received: from mga01.intel.com ([192.55.52.88]:43142 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732001AbhAZB2E (ORCPT ); Mon, 25 Jan 2021 20:28:04 -0500 IronPort-SDR: D/L+8cbkkC8zK9KfaBNPV5gk7j8XDlaFCZQ3XaWNvIbsiAEGsZDxVE28R7xE5rKoZd71Sv4VOr eXScGKYA0Wdw== X-IronPort-AV: E=McAfee;i="6000,8403,9875"; a="198609634" X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="198609634" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2021 16:41:54 -0800 IronPort-SDR: yjZzL65jbf8kL4CjrDWZSh8ZXuZY8FWi/yazcxGLjzSlYBgqp5wBe4v2QEJ/yuGBbMmwgrs0PI HgI3BhCipgXw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="361754925" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga008.fm.intel.com with ESMTP; 25 Jan 2021 16:41:54 -0800 Subject: [RFC][PATCH 12/13] mm/vmscan: never demote for memcg reclaim To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Dave Hansen , yang.shi@linux.alibaba.com, rientjes@google.com, ying.huang@intel.com, dan.j.williams@intel.com, david@redhat.com, osalvador@suse.de From: Dave Hansen Date: Mon, 25 Jan 2021 16:34:34 -0800 References: <20210126003411.2AC51464@viggo.jf.intel.com> In-Reply-To: <20210126003411.2AC51464@viggo.jf.intel.com> Message-Id: <20210126003434.BD7626A8@viggo.jf.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Suggested-by: Yang Shi Cc: David Rientjes Cc: Huang Ying Cc: Dan Williams Cc: David Hildenbrand Cc: osalvador --- b/mm/vmscan.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff -puN mm/vmscan.c~never-demote-for-memcg-reclaim mm/vmscan.c --- a/mm/vmscan.c~never-demote-for-memcg-reclaim 2021-01-25 16:23:19.180866685 -0800 +++ b/mm/vmscan.c 2021-01-25 16:23:19.185866685 -0800 @@ -290,7 +290,8 @@ static bool writeback_throttling_sane(st #endif static inline bool can_reclaim_anon_pages(struct mem_cgroup *memcg, - int node_id) + int node_id, + struct scan_control *sc) { if (memcg == NULL) { /* @@ -328,7 +329,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 (can_reclaim_anon_pages(NULL, zone_to_nid(zone))) + if (can_reclaim_anon_pages(NULL, zone_to_nid(zone), NULL)) nr += zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_ANON) + zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_ANON); @@ -1065,7 +1066,8 @@ static enum page_references page_check_r return PAGEREF_RECLAIM; } -static bool migrate_demote_page_ok(struct page *page) +static bool migrate_demote_page_ok(struct page *page, + struct scan_control *sc) { int next_nid = next_demotion_node(page_to_nid(page)); @@ -1073,6 +1075,10 @@ static bool migrate_demote_page_ok(struc VM_BUG_ON_PAGE(PageHuge(page), page); VM_BUG_ON_PAGE(PageLRU(page), page); + /* It is pointless to do demotion in memcg reclaim */ + if (cgroup_reclaim(sc)) + return false; + if (next_nid == NUMA_NO_NODE) return false; if (PageTransHuge(page) && !thp_migration_supported()) @@ -1329,7 +1335,7 @@ retry: * Before reclaiming the page, try to relocate * its contents to another node. */ - if (do_demote_pass && migrate_demote_page_ok(page)) { + if (do_demote_pass && migrate_demote_page_ok(page, sc)) { list_add(&page->lru, &demote_pages); unlock_page(page); continue; @@ -2362,7 +2368,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 || !can_reclaim_anon_pages(memcg, pgdat->node_id)) { + if (!sc->may_swap || !can_reclaim_anon_pages(memcg, pgdat->node_id, sc)) { scan_balance = SCAN_FILE; goto out; } @@ -2737,7 +2743,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 (can_reclaim_anon_pages(NULL, pgdat->node_id)) + if (can_reclaim_anon_pages(NULL, pgdat->node_id, sc)) inactive_lru_pages += node_page_state(pgdat, NR_INACTIVE_ANON); return inactive_lru_pages > pages_for_compaction; _