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=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 B30EBC432C0 for ; Thu, 21 Nov 2019 15:21:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 767C320674 for ; Thu, 21 Nov 2019 15:21:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 767C320674 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.page Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2753B6B0327; Thu, 21 Nov 2019 10:21:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FE716B033A; Thu, 21 Nov 2019 10:21:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 114026B033B; Thu, 21 Nov 2019 10:21:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id ED5486B0327 for ; Thu, 21 Nov 2019 10:21:06 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 60281181AEF1E for ; Thu, 21 Nov 2019 15:21:06 +0000 (UTC) X-FDA: 76180647732.30.wool57_60e549377e529 X-HE-Tag: wool57_60e549377e529 X-Filterd-Recvd-Size: 4811 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 21 Nov 2019 15:21:05 +0000 (UTC) X-Originating-IP: 153.3.140.100 Received: from localhost.localdomain.localdomain (unknown [153.3.140.100]) (Authenticated sender: fly@kernel.page) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 164201C0003; Thu, 21 Nov 2019 15:20:57 +0000 (UTC) From: Pengfei Li To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, mhocko@kernel.org, vbabka@suse.cz, cl@linux.com, iamjoonsoo.kim@lge.com, guro@fb.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Pengfei Li Subject: [RFC v1 09/19] mm, vmscan: use for_each_node in shrink_zones() Date: Thu, 21 Nov 2019 23:18:01 +0800 Message-Id: <20191121151811.49742-10-fly@kernel.page> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191121151811.49742-1-fly@kernel.page> References: <20191121151811.49742-1-fly@kernel.page> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: In shrink_zones(), we want to traverse node instead of zone, so use for_each_node instead of for_each_zone. Signed-off-by: Pengfei Li --- mm/vmscan.c | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index b5256ef682c2..2b0e51525c3a 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2910,6 +2910,25 @@ static inline bool compaction_ready(struct zone *z= one, struct scan_control *sc) return zone_watermark_ok_safe(zone, 0, watermark, sc->reclaim_idx); } =20 +static bool +node_compaction_ready(struct nlist_traverser *t, struct scan_control *sc= ) +{ + bool node_ready =3D true; + struct zone *zone; + + do { + zone =3D traverser_zone(t); + + if (compaction_ready(zone, sc)) + sc->compaction_ready =3D true; + else + node_ready =3D false; + + } while (t->usable_zones); + + return node_ready; +} + /* * This is the direct reclaim path, for page-allocating processes. We o= nly * try to reclaim pages from zones which will satisfy the caller's alloc= ation @@ -2920,12 +2939,12 @@ static inline bool compaction_ready(struct zone *= zone, struct scan_control *sc) */ static void shrink_zones(struct nodelist *nodelist, struct scan_control = *sc) { - struct nlist_traverser t; - struct zone *zone; unsigned long nr_soft_reclaimed; unsigned long nr_soft_scanned; gfp_t orig_mask; - pg_data_t *last_pgdat =3D NULL; + pg_data_t *pgdat; + struct nlist_traverser t; + int node; =20 /* * If the number of buffer_heads in the machine exceeds the maximum @@ -2938,14 +2957,17 @@ static void shrink_zones(struct nodelist *nodelis= t, struct scan_control *sc) sc->reclaim_idx =3D gfp_zone(sc->gfp_mask); } =20 - for_each_zone_nlist_nodemask(zone, &t, nodelist, + for_each_node_nlist_nodemask(node, &t, nodelist, sc->reclaim_idx, sc->nodemask) { + + pgdat =3D NODE_DATA(node); + /* * Take care memory controller reclaiming has small influence * to global LRU. */ if (!cgroup_reclaim(sc)) { - if (!cpuset_zone_allowed(zone, + if (!cpuset_node_allowed(node, GFP_KERNEL | __GFP_HARDWALL)) continue; =20 @@ -2960,18 +2982,7 @@ static void shrink_zones(struct nodelist *nodelist= , struct scan_control *sc) */ if (IS_ENABLED(CONFIG_COMPACTION) && sc->order > PAGE_ALLOC_COSTLY_ORDER && - compaction_ready(zone, sc)) { - sc->compaction_ready =3D true; - continue; - } - - /* - * Shrink each node in the zonelist once. If the - * zonelist is ordered by zone (not the default) then a - * node may be shrunk multiple times but in that case - * the user prefers lower zones being preserved. - */ - if (zone->zone_pgdat =3D=3D last_pgdat) + node_compaction_ready(&t, sc)) continue; =20 /* @@ -2981,7 +2992,7 @@ static void shrink_zones(struct nodelist *nodelist,= struct scan_control *sc) * and balancing, not for a memcg's limit. */ nr_soft_scanned =3D 0; - nr_soft_reclaimed =3D mem_cgroup_soft_limit_reclaim(zone->zone_pgdat, + nr_soft_reclaimed =3D mem_cgroup_soft_limit_reclaim(pgdat, sc->order, sc->gfp_mask, &nr_soft_scanned); sc->nr_reclaimed +=3D nr_soft_reclaimed; @@ -2989,11 +3000,7 @@ static void shrink_zones(struct nodelist *nodelist= , struct scan_control *sc) /* need some check for avoid more shrink_zone() */ } =20 - /* See comment about same check for global reclaim above */ - if (zone->zone_pgdat =3D=3D last_pgdat) - continue; - last_pgdat =3D zone->zone_pgdat; - shrink_node(zone->zone_pgdat, sc); + shrink_node(pgdat, sc); } =20 /* --=20 2.23.0