From patchwork Thu Dec 20 09:50:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 10738731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 99A1413A4 for ; Thu, 20 Dec 2018 09:51:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87FE128415 for ; Thu, 20 Dec 2018 09:51:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B4A728711; Thu, 20 Dec 2018 09:51:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A94428717 for ; Thu, 20 Dec 2018 09:51:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CC4B8E0005; Thu, 20 Dec 2018 04:51:13 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 056088E0003; Thu, 20 Dec 2018 04:51:12 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEAD68E0005; Thu, 20 Dec 2018 04:51:12 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 9523E8E0003 for ; Thu, 20 Dec 2018 04:51:12 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id x26so1071471pgc.5 for ; Thu, 20 Dec 2018 01:51:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=bFlrZBjUWwkKVtLETvH1CazL4niyqwbCd/ko3YIed4Y=; b=kbgLG3aIBk/02OeSSqpQhey54UIHx1bfVJ4N0CkoE7T7HTHPq7vOzvXrX4fpJ28PjK eXMxAvarj17xbCdjn+ZaNn1fQDYUNFCXECLTMdQvQyfdOoDStS2x2D8/oCA+wljMUIlD IgKyZrrzJMUApJxTiX3carhwb5xAi14MLlD0twfHBAh8ZMPmE9xd7GogGzIq8LVn0fzc cYKv6BPSuDNxfbKvs9GmdIXUNAtA/WgC08DtLblApsTXg9q/OAVi9PdEYF6CC60YaUaq yyaB+neSqKgT6ZNvwBOZjR4ObcXazzefXmbpJgkYGWYL4mwxaynJ9FcMzKmXfUsnQhu3 IXIA== X-Gm-Message-State: AA+aEWa9jwr5n1IdBnVRRwfsivfafpXC+J0JUc+hQfBcAJXRbYbRCwwG Ux6CjUJy6uzrIgaQrJi5oJrDBkNKm+6AbD2FuFjNzOj7iw//gq0LieDDsnz0p0enLmjOruuMa1l JlvVeg2fmKXeBrFOpl+nx/2atCZl4b6VsExmsjaC3LYXft73CFgBjk1Aqfh+35HWSlqHTs+kVPs l9krEU0+XDrg66uBUSLKngtAe/Z2KtRD67NoPpQyxUKTN04m8QXedPXbj8nidafiD2sT4srzCNv BYubqJlKbyCD8kfyS+HEX/SHzwbpVRjqmf87Q/tPzHnw+h8hNHLTT2DQwGR0i4jUal8eeI5bgmO 3YSh3VHJVThR1TjH3rGZACyXZ4Or4MDs8d0QlRTrCS2AFPJWe4mG2TJjdjG+l0yWA3hAF+bYNH/ I X-Received: by 2002:a65:65c9:: with SMTP id y9mr23044392pgv.438.1545299472258; Thu, 20 Dec 2018 01:51:12 -0800 (PST) X-Received: by 2002:a65:65c9:: with SMTP id y9mr23044339pgv.438.1545299470977; Thu, 20 Dec 2018 01:51:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545299470; cv=none; d=google.com; s=arc-20160816; b=Xmn0OIixzOK2UlQUoQI3NJ+XwWBWOydhD5p7jU82/MalMr1WZSbzzT41BtnBoDp6Y0 foqQStKx2aelsAqYomecs8bgk5ax6pZo6Ir0kLOAQBJrnEBvhSZ1cTzyK3bYT2J4ClHz xd/tklJvfYqkioExPcKpg7x1N4C2F2Rw94WpL8VF+T9zzrMu5A9u268PPISTN9YT4feF UdOuSZax6vFmlZzyKI3pHvB8dn2uEtz2CFUNJBlQH7MDmRRN7+b+0C7LhtQO52qJaTyy X/F3EQ/WjEFJ6up4/FNYibSK3Xoxqa/xi1oa+RrzTinTB5T0iWan8ltzj+egVXh1H2ak pFQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bFlrZBjUWwkKVtLETvH1CazL4niyqwbCd/ko3YIed4Y=; b=FrjJpYNtBgh1tPTqL+YewY0w19n+SnOh1ccpo9xQZs56yqqyrgNU1UngfDtdha/XND II3jq4psiHA8e4SRi1WK656qAIH/UjzCOY6nXOojbnA2YfJDZMYU/QWnN6HBLjBQpZox Xj41kUp1PrOMUGaBmRI4wXuzWWk4RQyTM9WMZzm/ptq89BekKoZus+5dZOAjzS9SCKfD CEIhSH9v7X+rGmAO4mz2NDXmRiaiVKPcC1JbHRxfgZJwSQBupcgaxxw0/EHiBlWxeFOH hz0zmnAWuf4v7jB6WGKUvrZxqatHgCSrsvAHO3SyN1RPCOF9gM9mbTbxw1mY7fHNsOix jZ5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="l/cOsm6S"; spf=pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kernelfans@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b5sor34345650pfj.35.2018.12.20.01.51.10 for (Google Transport Security); Thu, 20 Dec 2018 01:51:10 -0800 (PST) Received-SPF: pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="l/cOsm6S"; spf=pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kernelfans@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bFlrZBjUWwkKVtLETvH1CazL4niyqwbCd/ko3YIed4Y=; b=l/cOsm6SNToCov7U0QeU1WV0TKp3YyxFudL5VZe2kcjghnxG63U1wwxavHGZDGiR3i Rjixd+sslh+zH/CdsfIGiqp8V6qEixW3sBCVwukb51BTChhgzmHre0G7T5ZSysgY2lWp xfiP8HYvNxhv+PpbUhmKm0kuyGBX4mOjlaVM2ePCvepg2pCy7TJGw4JkL5noadc8hwJ0 k8yVcFt2xRJABe+JXADPcfx0eEjsTYOqkMzxSTZLVVFV6ecJJs2HPpLZbDt5YC38DVl2 50Ya/bk5/ZQu0qwBUs5G8EcU+n+MajYLy7Wp5QIvxjfgO/CD7qfHpqssKfUJiVzpflEQ OHaQ== X-Google-Smtp-Source: AFSGD/UgqYyt0OJR1caTO1JzmXFnV5rhJVHinuALAcpjMCINyFM7ITwObGiH2+ykYlNGtjKpzqqSuQ== X-Received: by 2002:a62:61c3:: with SMTP id v186mr23934902pfb.55.1545299470299; Thu, 20 Dec 2018 01:51:10 -0800 (PST) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 125sm33355206pfx.159.2018.12.20.01.51.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 01:51:09 -0800 (PST) From: Pingfan Liu To: linux-mm@kvack.org Cc: Pingfan Liu , linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , Michal Hocko , Vlastimil Babka , Mike Rapoport , Bjorn Helgaas , Jonathan Cameron , David Rientjes , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Subject: [PATCHv2 1/3] mm/numa: change the topo of build_zonelist_xx() Date: Thu, 20 Dec 2018 17:50:37 +0800 Message-Id: <1545299439-31370-2-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545299439-31370-1-git-send-email-kernelfans@gmail.com> References: <1545299439-31370-1-git-send-email-kernelfans@gmail.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP The current build_zonelist_xx func relies on pgdat instance to build zonelist, if a numa node is offline, there will no pgdat instance for it. But in some case, there is still requirement for zonelist of offline node, especially with nr_cpus option. This patch change these funcs topo to ease the building of zonelist for offline nodes. Signed-off-by: Pingfan Liu Cc: linuxppc-dev@lists.ozlabs.org Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Cc: Andrew Morton Cc: Michal Hocko Cc: Vlastimil Babka Cc: Mike Rapoport Cc: Bjorn Helgaas Cc: Jonathan Cameron Cc: David Rientjes Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman --- mm/page_alloc.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2ec9cc4..17dbf6e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5049,7 +5049,7 @@ static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref) * * Add all populated zones of a node to the zonelist. */ -static int build_zonerefs_node(pg_data_t *pgdat, struct zoneref *zonerefs) +static int build_zonerefs_node(int nid, struct zoneref *zonerefs) { struct zone *zone; enum zone_type zone_type = MAX_NR_ZONES; @@ -5057,7 +5057,7 @@ static int build_zonerefs_node(pg_data_t *pgdat, struct zoneref *zonerefs) do { zone_type--; - zone = pgdat->node_zones + zone_type; + zone = NODE_DATA(nid)->node_zones + zone_type; if (managed_zone(zone)) { zoneref_set_zone(zone, &zonerefs[nr_zones++]); check_highest_zone(zone_type); @@ -5186,20 +5186,20 @@ static int find_next_best_node(int node, nodemask_t *used_node_mask) * This results in maximum locality--normal zone overflows into local * DMA zone, if any--but risks exhausting DMA zone. */ -static void build_zonelists_in_node_order(pg_data_t *pgdat, int *node_order, - unsigned nr_nodes) +static void build_zonelists_in_node_order(struct zonelist *node_zonelists, + int *node_order, unsigned int nr_nodes) { struct zoneref *zonerefs; int i; - zonerefs = pgdat->node_zonelists[ZONELIST_FALLBACK]._zonerefs; + zonerefs = node_zonelists[ZONELIST_FALLBACK]._zonerefs; for (i = 0; i < nr_nodes; i++) { int nr_zones; pg_data_t *node = NODE_DATA(node_order[i]); - nr_zones = build_zonerefs_node(node, zonerefs); + nr_zones = build_zonerefs_node(node->node_id, zonerefs); zonerefs += nr_zones; } zonerefs->zone = NULL; @@ -5209,13 +5209,14 @@ static void build_zonelists_in_node_order(pg_data_t *pgdat, int *node_order, /* * Build gfp_thisnode zonelists */ -static void build_thisnode_zonelists(pg_data_t *pgdat) +static void build_thisnode_zonelists(struct zonelist *node_zonelists, + int nid) { struct zoneref *zonerefs; int nr_zones; - zonerefs = pgdat->node_zonelists[ZONELIST_NOFALLBACK]._zonerefs; - nr_zones = build_zonerefs_node(pgdat, zonerefs); + zonerefs = node_zonelists[ZONELIST_NOFALLBACK]._zonerefs; + nr_zones = build_zonerefs_node(nid, zonerefs); zonerefs += nr_zones; zonerefs->zone = NULL; zonerefs->zone_idx = 0; @@ -5228,15 +5229,14 @@ static void build_thisnode_zonelists(pg_data_t *pgdat) * may still exist in local DMA zone. */ -static void build_zonelists(pg_data_t *pgdat) +static void build_zonelists(struct zonelist *node_zonelists, int local_node) { static int node_order[MAX_NUMNODES]; int node, load, nr_nodes = 0; nodemask_t used_mask; - int local_node, prev_node; + int prev_node; /* NUMA-aware ordering of nodes */ - local_node = pgdat->node_id; load = nr_online_nodes; prev_node = local_node; nodes_clear(used_mask); @@ -5257,8 +5257,8 @@ static void build_zonelists(pg_data_t *pgdat) load--; } - build_zonelists_in_node_order(pgdat, node_order, nr_nodes); - build_thisnode_zonelists(pgdat); + build_zonelists_in_node_order(node_zonelists, node_order, nr_nodes); + build_thisnode_zonelists(node_zonelists, local_node); } #ifdef CONFIG_HAVE_MEMORYLESS_NODES @@ -5283,16 +5283,14 @@ static void setup_min_unmapped_ratio(void); static void setup_min_slab_ratio(void); #else /* CONFIG_NUMA */ -static void build_zonelists(pg_data_t *pgdat) +static void build_zonelists(struct zonelist *node_zonelists, int local_node) { int node, local_node; struct zoneref *zonerefs; int nr_zones; - local_node = pgdat->node_id; - - zonerefs = pgdat->node_zonelists[ZONELIST_FALLBACK]._zonerefs; - nr_zones = build_zonerefs_node(pgdat, zonerefs); + zonerefs = node_zonelists[ZONELIST_FALLBACK]._zonerefs; + nr_zones = build_zonerefs_node(local_node, zonerefs); zonerefs += nr_zones; /* @@ -5306,13 +5304,13 @@ static void build_zonelists(pg_data_t *pgdat) for (node = local_node + 1; node < MAX_NUMNODES; node++) { if (!node_online(node)) continue; - nr_zones = build_zonerefs_node(NODE_DATA(node), zonerefs); + nr_zones = build_zonerefs_node(node, zonerefs); zonerefs += nr_zones; } for (node = 0; node < local_node; node++) { if (!node_online(node)) continue; - nr_zones = build_zonerefs_node(NODE_DATA(node), zonerefs); + nr_zones = build_zonerefs_node(node, zonerefs); zonerefs += nr_zones; } @@ -5359,12 +5357,12 @@ static void __build_all_zonelists(void *data) * building zonelists is fine - no need to touch other nodes. */ if (self && !node_online(self->node_id)) { - build_zonelists(self); + build_zonelists(self->node_zonelists, self->node_id); } else { for_each_online_node(nid) { pg_data_t *pgdat = NODE_DATA(nid); - build_zonelists(pgdat); + build_zonelists(pgdat->node_zonelists, pgdat->node_id); } #ifdef CONFIG_HAVE_MEMORYLESS_NODES