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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 12C06C43460 for ; Fri, 2 Apr 2021 00:18:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A24AB61056 for ; Fri, 2 Apr 2021 00:18:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A24AB61056 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2EDB06B014A; Thu, 1 Apr 2021 20:18:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C4C26B014B; Thu, 1 Apr 2021 20:18:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18C336B014C; Thu, 1 Apr 2021 20:18:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id F1B786B014A for ; Thu, 1 Apr 2021 20:18:17 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B2C9D180002B3 for ; Fri, 2 Apr 2021 00:18:17 +0000 (UTC) X-FDA: 77985515034.28.B0238A5 Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) by imf20.hostedemail.com (Postfix) with ESMTP id 92027D7 for ; Fri, 2 Apr 2021 00:18:16 +0000 (UTC) Received: by mail-io1-f48.google.com with SMTP id e8so3920568iok.5 for ; Thu, 01 Apr 2021 17:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7k6TmguUsUmCTAXHQ4UdteGe/Bb76fZ4Cj6VWmBAXaE=; b=p4Y0+JcIoi0RggWAp3uZZzVwjdDesIRWg7dxK4mTnYHlS2DxUC/Xx94UIOUpB1LwY2 QPTKOZ08hy7lWgPSQIf1juTP5GveibLpWEucX7IuoLniPeiHeMjNUwLjodd3aULiYSiw exZTFcjxwTA5jflcePSZxzdWtp1qf/pWClG1MJc4m8MrXVVxhv2YnLuL6Vj7jGj5nIJc GS+vTSM5W8JLSFootcD9qIAGAx97jGrC6Ul6Q9tkJ49LJ0eBLKlJTJl84EkfoelQgOg+ 9onHpvHe7j+WaXTTcWXcAZHXWGWaBvRTSUBeeJO7RfBKr+/X3sz9jCUv/bIJ8xOypZYA iLCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7k6TmguUsUmCTAXHQ4UdteGe/Bb76fZ4Cj6VWmBAXaE=; b=TVwQAVwP3GVleUoQq3IvoayqUOxw2l5cd5Q3S5OcWu+86xbxoJR1A74ysu3hCPDB+W GT7SRFH/2F788i1o/pKqL6lCs/qdoRosjRN2VykZpDOXzrz0CPrcf5fbCD9ehfQeZEGW rrUxvOydQ3VhFbnSuI1d5sfUonv7lFHDo++fAO/xMj1IGRqZlVNpfaK86HqRduBv+ohV gQBuYkXdqsRYVC7RbVe5HPf2JCDWnsAEH5z/M5a2iRCZkzaFjPVZ2LNGpt2NWEMV1PcW pvdhQrg/1mDR7KoAr0WijqY7qg9tpZeAcnVCaRaXUmHJKDXntNFk+gOXUUzN8QzBXewa pUNA== X-Gm-Message-State: AOAM530Ly0ZdEgoKWGqDS6lv/i67lgTRj4M38rutgftPkp4t2a89qDKb C8m1oSjXuHm+fJpRF9pE23/QaQTJDKWDJQLO3xH3VA== X-Google-Smtp-Source: ABdhPJyxImQI4bY3SJ9N8eb20WUK5oZvs7v4iYN33lZSZ8t7H7RrriNem8/FXZXzy5sfwoOQes2pbfyfxEp0DdM5qzE= X-Received: by 2002:a05:6638:210d:: with SMTP id n13mr10275763jaj.100.1617322696489; Thu, 01 Apr 2021 17:18:16 -0700 (PDT) MIME-Version: 1.0 References: <20210401183216.443C4443@viggo.jf.intel.com> <20210401183233.64A91C97@viggo.jf.intel.com> In-Reply-To: <20210401183233.64A91C97@viggo.jf.intel.com> From: Wei Xu Date: Thu, 1 Apr 2021 17:18:04 -0700 Message-ID: Subject: Re: [PATCH 09/10] mm/vmscan: never demote for memcg reclaim To: Dave Hansen Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yang.shi@linux.alibaba.com, shy828301@gmail.com, David Rientjes , ying.huang@intel.com, Dan Williams , david@redhat.com, osalvador@suse.de Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: fumqir71x64t8m3oddnubmk3s9ca8eyb X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 92027D7 Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=mail-io1-f48.google.com; client-ip=209.85.166.48 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617322696-821666 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: On Thu, Apr 1, 2021 at 11:35 AM Dave Hansen wrote: > > > 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 > Reviewed-by: Yang Shi > Cc: Wei Xu > 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-03-31 15:17:20.476000239 -0700 > +++ b/mm/vmscan.c 2021-03-31 15:17:20.487000239 -0700 > @@ -288,7 +288,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) I don't see "sc" gets used in can_reclaim_anon_pages(). Remove it? > { > if (memcg == NULL) { > /* > @@ -326,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 (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); > > @@ -1064,7 +1065,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)); > > @@ -1072,6 +1074,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()) > @@ -1328,7 +1334,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; > _