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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 81B03C433E0 for ; Tue, 2 Feb 2021 18:56:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 12CD464D79 for ; Tue, 2 Feb 2021 18:56:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12CD464D79 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A746B6B0006; Tue, 2 Feb 2021 13:56:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A4AC76B006C; Tue, 2 Feb 2021 13:56:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93B116B0070; Tue, 2 Feb 2021 13:56:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 7C6766B0006 for ; Tue, 2 Feb 2021 13:56:32 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 29DD93634 for ; Tue, 2 Feb 2021 18:56:32 +0000 (UTC) X-FDA: 77774233824.30.self82_020e52c275cd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 10048180B3AB8 for ; Tue, 2 Feb 2021 18:56:32 +0000 (UTC) X-HE-Tag: self82_020e52c275cd X-Filterd-Recvd-Size: 7889 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 18:56:31 +0000 (UTC) Received: by mail-ej1-f46.google.com with SMTP id a9so13241234ejr.2 for ; Tue, 02 Feb 2021 10:56:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=b8dqV4ylKlnWwc03tOmEAN2Blw3jDnjpV5EJfPDOmKU=; b=Y+fuyGQHiDe6MNsBQ0O0e7XLnR2NsPUPd8rl6IPZuXKRsS5x8ON2kvQHxHINmXzlaE m/U7FvnFEq4HpDCf6UtKLibRyVrylq92YHuZdHq/LoQ7RwTIqxcUIy7coMKKKReOZGV4 cOHsTVf+omWnJkTpxPWXYtgIgrGuPUiWGxDH0vCD/WP58mXVwoW6IfxuT3EBdDq59Wrr E5VmD4LZGhhUDSWPhznuGLOjJmIWPmdHynxUztSxZ5s7QL7dV0kTPqjClUs1YDSDUa6f l2FQAqf7Kk/kK7GUI9FnQH8IeMuE9K5NuiPgfAyiaF/Z8IXmghbVkdpQAMrSFxzVCr2E fgyw== 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=b8dqV4ylKlnWwc03tOmEAN2Blw3jDnjpV5EJfPDOmKU=; b=MMV78tQaJ13juFGSO18AAxEWYuiXIwClCv9Gavc2oKrw39T4mpILF7hKSPDApVCkRI +6GquRKJQog14pNh+TER0AdAXTJzyJ3UxBzVLLs4laSfrhAFleHB3u+ZdN3Vex4g93l3 U2pQ9XvCcEdjmBBuvp7Ej0qR5nrRtJ+43bdIkkGY5y9rWxhWpqFyLy11An/d1hxyh9vp cyq5mnZ4dWwe+XR/vMSm/PPX5yjQ4iqs8g384wFyjIkbUMJtBYjcegrctQVzF4K8y2k7 DFxyy6gQ1XeG+AzzaQrGTh3r8YsXN/JiNG14t5Xp6QbPPbH55+ttALNirdTsfaeSiLP5 +xAA== X-Gm-Message-State: AOAM531Hr6fKx1hqYeijhNI8CEwZt2rkxaIvv6KvCpxKu3yOAPFITcde r33DXP88NaA5UOI2nLtOxgjaAUku5Ba2yXbYbAc= X-Google-Smtp-Source: ABdhPJyS6nG61rjCK0u3XCj4CP0EfQc8rTngvcudG7aNnqqUuZId6yF4qo/HQ5cBAKuxD6OeX4dsS6AC0cy2dvpBT1g= X-Received: by 2002:a17:906:f841:: with SMTP id ks1mr23626709ejb.507.1612292190379; Tue, 02 Feb 2021 10:56:30 -0800 (PST) MIME-Version: 1.0 References: <20210126003411.2AC51464@viggo.jf.intel.com> <20210126003432.6E88B570@viggo.jf.intel.com> In-Reply-To: <20210126003432.6E88B570@viggo.jf.intel.com> From: Yang Shi Date: Tue, 2 Feb 2021 10:56:18 -0800 Message-ID: Subject: Re: [RFC][PATCH 11/13] mm/vmscan: Consider anonymous pages without swap To: Dave Hansen Cc: Linux Kernel Mailing List , Linux MM , kbusch@kernel.org, "Verma, Vishal L" , Yang Shi , David Rientjes , Huang Ying , Dan Williams , David Hildenbrand , Oscar Salvador Content-Type: text/plain; charset="UTF-8" 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 Mon, Jan 25, 2021 at 4:42 PM Dave Hansen wrote: > > > From: Keith Busch > > Reclaim anonymous pages if a migration path is available now that > demotion provides a non-swap recourse for reclaiming anon pages. > > Note that this check is subtly different from the > anon_should_be_aged() checks. This mechanism checks whether a > specific page in a specific context *can* actually be reclaimed, given > current swap space and cgroup limits > > anon_should_be_aged() is a much simpler and more prelimiary check > which just says whether there is a possibility of future reclaim. > > #Signed-off-by: Keith Busch > Cc: Keith Busch > [vishal: fixup the migration->demotion rename] > Signed-off-by: Vishal Verma > Signed-off-by: Dave Hansen > Cc: Yang Shi > Cc: David Rientjes > Cc: Huang Ying > Cc: Dan Williams > Cc: David Hildenbrand > Cc: osalvador > > -- > > Changes from Dave 10/2020: > * remove 'total_swap_pages' modification > > Changes from Dave 06/2020: > * rename reclaim_anon_pages()->can_reclaim_anon_pages() > > Note: Keith's Intel SoB is commented out because he is no > longer at Intel and his @intel.com mail will bouncee > --- > > b/mm/vmscan.c | 35 ++++++++++++++++++++++++++++++++--- > 1 file changed, 32 insertions(+), 3 deletions(-) > > diff -puN mm/vmscan.c~0009-mm-vmscan-Consider-anonymous-pages-without-swap mm/vmscan.c > --- a/mm/vmscan.c~0009-mm-vmscan-Consider-anonymous-pages-without-swap 2021-01-25 16:23:18.106866688 -0800 > +++ b/mm/vmscan.c 2021-01-25 16:23:18.111866688 -0800 > @@ -289,6 +289,34 @@ static bool writeback_throttling_sane(st > } > #endif > > +static inline bool can_reclaim_anon_pages(struct mem_cgroup *memcg, > + int node_id) > +{ > + if (memcg == NULL) { > + /* > + * For non-memcg reclaim, is there > + * space in any swap device? > + */ > + if (get_nr_swap_pages() > 0) > + return true; > + } else { > + /* Is the memcg below its swap limit? */ > + if (mem_cgroup_get_nr_swap_pages(memcg) > 0) > + return true; > + } > + > + /* > + * The page can not be swapped. > + * > + * Can it be reclaimed from this node via demotion? > + */ > + if (next_demotion_node(node_id) >= 0) > + return true; > + > + /* No way to reclaim anon pages */ > + return false; > +} > + > /* > * This misses isolated pages which are not accounted for to save counters. > * As the data only determines if reclaim or compaction continues, it is > @@ -300,7 +328,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 (can_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); > > @@ -2323,6 +2351,7 @@ enum scan_balance { > static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, > unsigned long *nr) > { > + struct pglist_data *pgdat = lruvec_pgdat(lruvec); > struct mem_cgroup *memcg = lruvec_memcg(lruvec); > unsigned long anon_cost, file_cost, total_cost; > int swappiness = mem_cgroup_swappiness(memcg); > @@ -2333,7 +2362,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 || !can_reclaim_anon_pages(memcg, pgdat->node_id)) { Just one minor thing about may_swap. It may be cleared by nr_boost_reclaim. But demotion should be fine for boost_reclaim. > scan_balance = SCAN_FILE; > goto out; > } > @@ -2708,7 +2737,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 (can_reclaim_anon_pages(NULL, pgdat->node_id)) > inactive_lru_pages += node_page_state(pgdat, NR_INACTIVE_ANON); > > return inactive_lru_pages > pages_for_compaction; > _ >