Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1729275yba; Thu, 25 Apr 2019 04:55:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZYt3yCveGcjuCdPeesJnxZ9PGX8FPbf4ja1Xu/dNA/n6hoZqvNrP+xOmk49c0POnNXe7C X-Received: by 2002:a63:c944:: with SMTP id y4mr37297080pgg.257.1556193358785; Thu, 25 Apr 2019 04:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556193358; cv=none; d=google.com; s=arc-20160816; b=yTDLF+bzHaqeLspNMXqI4swn8F/nnURSMqn8j1GN/fziSHtxYVeY8YU5lYB0hVjRO0 4uvFmBsRCHdCh/NubK0SQaYJ9DuXDrMw42UhpzOmeWjZ/9dqdfLnMPkqH6LrtS3CSS9I +jyt1Yc8Ss1n3EJMke0zXjjRtfnM652/mnG34nkh17kTbcpxEfWjzdXI9Imgg+Ku+oUu pX7Oc+grW5u0cuUg1k9UDTpF8A3JhXJmk8BloSeWmh2z2SxR7tk2qnJu2H+tvxVGIlQr XNuZ+LT7B25aMQTFUAofaWWBOMI0g+NlbHmzfVU/ta6NbElF/bEvU1o3BZqKxDuW0Cbm Y0lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=hqI7L/58NB/51uxAiM/Mz2T2sXjRz7XBu7fn1ORtLXQ=; b=c/t0yBblbQoeyrxTAJnHCOgCZIpWZhvkHPFYeG4WAISDNhoIsGgxxvEbGvm1mlx2F7 01gt1vJldg94/c3ezfahEAGuMqpwyyCdk6qpFtk0M7fMApi5DJdIG4qJ18juD+Ws5efx ndXkeIpx9K7FoS99enP+9dDED0oMBEXjxl1L4Pd/7tUsaUSnDWCRmCn2cYGVlzLQ+yZZ mvDNZPSL4BZMToDlCnMQzBvmKbKBNsT6tv0w9jZ31oXvEt8YrbVw0/cT7oqDfVO9VQwS OXk8+6JHRktY1XfQKQyI6Wp8SQRTS8Xt6fX7rY4FnPbUgrG7IGM//IDdE19w5wpfV7OT Asag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id p6si21718861pfd.19.2019.04.25.04.55.30; Thu, 25 Apr 2019 04:55:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2388303AbfDYBmw (ORCPT + 99 others); Wed, 24 Apr 2019 21:42:52 -0400 Received: from mga11.intel.com ([192.55.52.93]:25341 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388188AbfDYBms (ORCPT ); Wed, 24 Apr 2019 21:42:48 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2019 18:42:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,391,1549958400"; d="scan'208";a="152134236" Received: from zz23f_aep_wp03.sh.intel.com ([10.239.85.39]) by FMSMGA003.fm.intel.com with ESMTP; 24 Apr 2019 18:42:47 -0700 From: Fan Du To: akpm@linux-foundation.org, mhocko@suse.com, fengguang.wu@intel.com, dan.j.williams@intel.com, dave.hansen@intel.com, xishi.qiuxishi@alibaba-inc.com, ying.huang@intel.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Fan Du Subject: [RFC PATCH 4/5] mm, page alloc: build fallback list on per node type basis Date: Thu, 25 Apr 2019 09:21:34 +0800 Message-Id: <1556155295-77723-5-git-send-email-fan.du@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1556155295-77723-1-git-send-email-fan.du@intel.com> References: <1556155295-77723-1-git-send-email-fan.du@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On box with both DRAM and PMEM managed by mm system, Usually node 0, 1 are DRAM nodes, nodes 2, 3 are PMEM nodes. nofallback list are same as before, fallback list are not redesigned to be arranged by node type basis, iow, allocation request of DRAM page start from node 0 will go through node0->node1->node2->node3 zonelists. Signed-off-by: Fan Du --- include/linux/mmzone.h | 8 ++++++++ mm/page_alloc.c | 42 ++++++++++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index d3ee9f9..8c37e1c 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -939,6 +939,14 @@ static inline int is_node_dram(int nid) return test_bit(PGDAT_DRAM, &pgdat->flags); } +static inline int is_node_same_type(int nida, int nidb) +{ + if (node_isset(nida, numa_nodes_pmem)) + return node_isset(nidb, numa_nodes_pmem); + else + return node_isset(nidb, numa_nodes_dram); +} + static inline void set_node_type(int nid) { pg_data_t *pgdat = NODE_DATA(nid); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c6ce20a..a408a91 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5372,7 +5372,7 @@ int numa_zonelist_order_handler(struct ctl_table *table, int write, * * Return: node id of the found node or %NUMA_NO_NODE if no node is found. */ -static int find_next_best_node(int node, nodemask_t *used_node_mask) +static int find_next_best_node(int node, nodemask_t *used_node_mask, int need_same_type) { int n, val; int min_val = INT_MAX; @@ -5380,7 +5380,7 @@ static int find_next_best_node(int node, nodemask_t *used_node_mask) const struct cpumask *tmp = cpumask_of_node(0); /* Use the local node if we haven't already */ - if (!node_isset(node, *used_node_mask)) { + if (need_same_type && !node_isset(node, *used_node_mask)) { node_set(node, *used_node_mask); return node; } @@ -5391,6 +5391,12 @@ static int find_next_best_node(int node, nodemask_t *used_node_mask) if (node_isset(n, *used_node_mask)) continue; + if (need_same_type && !is_node_same_type(node, n)) + continue; + + if (!need_same_type && is_node_same_type(node, n)) + continue; + /* Use the distance array to find the distance */ val = node_distance(node, n); @@ -5472,31 +5478,35 @@ static void build_zonelists(pg_data_t *pgdat) int node, load, nr_nodes = 0; nodemask_t used_mask; int local_node, prev_node; + int need_same_type; /* NUMA-aware ordering of nodes */ local_node = pgdat->node_id; load = nr_online_nodes; prev_node = local_node; - nodes_clear(used_mask); memset(node_order, 0, sizeof(node_order)); - while ((node = find_next_best_node(local_node, &used_mask)) >= 0) { - /* - * We don't want to pressure a particular node. - * So adding penalty to the first node in same - * distance group to make it round-robin. - */ - if (node_distance(local_node, node) != - node_distance(local_node, prev_node)) - node_load[node] = load; + for (need_same_type = 1; need_same_type >= 0; need_same_type--) { + nodes_clear(used_mask); + while ((node = find_next_best_node(local_node, &used_mask, + need_same_type)) >= 0) { + /* + * We don't want to pressure a particular node. + * So adding penalty to the first node in same + * distance group to make it round-robin. + */ + if (node_distance(local_node, node) != + node_distance(local_node, prev_node)) + node_load[node] = load; - node_order[nr_nodes++] = node; - prev_node = node; - load--; + node_order[nr_nodes++] = node; + prev_node = node; + load--; + } } - build_zonelists_in_node_order(pgdat, node_order, nr_nodes); build_thisnode_zonelists(pgdat); + } #ifdef CONFIG_HAVE_MEMORYLESS_NODES -- 1.8.3.1