linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Tang Chen <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: zhugh.fnst@cn.fujitsu.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, tangchen@cn.fujitsu.com,
	mingo@kernel.org, douly.fnst@cn.fujitsu.com, hpa@zytor.com
Subject: [tip:x86/apic] x86/numa: Online memory-less nodes at boot time
Date: Thu, 22 Sep 2016 12:09:51 -0700	[thread overview]
Message-ID: <tip-2532fc318db0e1fe68e01407ee27634c76916e44@git.kernel.org> (raw)
In-Reply-To: <1472114120-3281-2-git-send-email-douly.fnst@cn.fujitsu.com>

Commit-ID:  2532fc318db0e1fe68e01407ee27634c76916e44
Gitweb:     http://git.kernel.org/tip/2532fc318db0e1fe68e01407ee27634c76916e44
Author:     Tang Chen <tangchen@cn.fujitsu.com>
AuthorDate: Thu, 25 Aug 2016 16:35:14 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 21 Sep 2016 21:18:38 +0200

x86/numa: Online memory-less nodes at boot time

For now, x86 does not support memory-less node. A node without memory
will not be onlined, and the cpus on it will be mapped to the other
online nodes with memory in init_cpu_to_node(). The reason of doing this
is to ensure each cpu has mapped to a node with memory, so that it will
be able to allocate local memory for that cpu.

But we don't have to do it in this way.

In this series of patches, we are going to construct cpu <-> node mapping
for all possible cpus at boot time, which is a persistent mapping. It means
that the cpu will be mapped to the node which it belongs to, and will never
be changed. If a node has only cpus but no memory, the cpus on it will be
mapped to a memory-less node. And the memory-less node should be onlined.

Allocate pgdats for all memory-less nodes and online them at boot
time. Then build zonelists for these nodes. As a result, when cpus on these
memory-less nodes try to allocate memory from local node, it will
automatically fall back to the proper zones in the zonelists.

Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: mika.j.penttila@gmail.com
Cc: len.brown@intel.com
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: rafael@kernel.org
Cc: rjw@rjwysocki.net
Cc: yasu.isimatu@gmail.com
Cc: linux-mm@kvack.org
Cc: linux-acpi@vger.kernel.org
Cc: isimatu.yasuaki@jp.fujitsu.com
Cc: gongzhaogang@inspur.com
Cc: tj@kernel.org
Cc: izumi.taku@jp.fujitsu.com
Cc: cl@linux.com
Cc: chen.tang@easystack.cn
Cc: akpm@linux-foundation.org
Cc: kamezawa.hiroyu@jp.fujitsu.com
Cc: lenb@kernel.org
Link: http://lkml.kernel.org/r/1472114120-3281-2-git-send-email-douly.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/mm/numa.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index fb68210..3f35b48 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -722,22 +722,19 @@ void __init x86_numa_init(void)
 	numa_init(dummy_numa_init);
 }
 
-static __init int find_near_online_node(int node)
+static void __init init_memory_less_node(int nid)
 {
-	int n, val;
-	int min_val = INT_MAX;
-	int best_node = -1;
+	unsigned long zones_size[MAX_NR_ZONES] = {0};
+	unsigned long zholes_size[MAX_NR_ZONES] = {0};
 
-	for_each_online_node(n) {
-		val = node_distance(node, n);
+	/* Allocate and initialize node data. Memory-less node is now online.*/
+	alloc_node_data(nid);
+	free_area_init_node(nid, zones_size, 0, zholes_size);
 
-		if (val < min_val) {
-			min_val = val;
-			best_node = n;
-		}
-	}
-
-	return best_node;
+	/*
+	 * All zonelists will be built later in start_kernel() after per cpu
+	 * areas are initialized.
+	 */
 }
 
 /*
@@ -766,8 +763,10 @@ void __init init_cpu_to_node(void)
 
 		if (node == NUMA_NO_NODE)
 			continue;
+
 		if (!node_online(node))
-			node = find_near_online_node(node);
+			init_memory_less_node(node);
+
 		numa_set_node(cpu, node);
 	}
 }

  reply	other threads:[~2016-09-22 19:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25  8:35 [PATCH v12 0/7] Make cpuid <-> nodeid mapping persistent Dou Liyang
2016-08-25  8:35 ` [PATCH v12 1/7] x86, memhp, numa: Online memory-less nodes at boot time Dou Liyang
2016-09-22 19:09   ` tip-bot for Tang Chen [this message]
2016-08-25  8:35 ` [PATCH v12 2/7] x86, acpi, cpu-hotplug: Enable acpi to register all possible cpus " Dou Liyang
2016-08-25  8:57   ` Dou Liyang
2016-09-22 19:10   ` [tip:x86/apic] x86/acpi: " tip-bot for Gu Zheng
2016-08-25  8:35 ` [PATCH v12 3/7] x86, acpi, cpu-hotplug: Introduce cpuid_to_apicid[] array to store persistent cpuid <-> apicid mapping Dou Liyang
2016-09-22 19:10   ` [tip:x86/apic] x86/acpi: Introduce persistent storage for " tip-bot for Gu Zheng
2016-10-04  6:02     ` Yinghai Lu
2016-10-05 14:04       ` Thomas Gleixner
2016-10-06  4:53         ` Yinghai Lu
2016-10-06  8:06           ` Dou Liyang
2016-10-06 21:20             ` Yinghai Lu
2016-10-07  4:35               ` Dou Liyang
2016-10-07 12:50                 ` Thomas Gleixner
2016-10-07 13:00                   ` Thomas Gleixner
2016-10-07 18:55                     ` Yinghai Lu
2016-10-08  5:22                     ` Dou Liyang
2016-10-07 11:02               ` Thomas Gleixner
2016-10-07 11:04               ` Thomas Gleixner
2016-10-07 13:07             ` Thomas Gleixner
2016-10-08  4:14               ` Dou Liyang
2016-08-25  8:35 ` [PATCH v12 4/7] x86, acpi, cpu-hotplug: Enable MADT APIs to return disabled apicid Dou Liyang
2016-09-22 19:11   ` [tip:x86/apic] x86/acpi: Enable MADT APIs to return disabled apicids tip-bot for Gu Zheng
2016-08-25  8:35 ` [PATCH v12 5/7] x86, acpi, cpu-hotplug: Set persistent cpuid <-> nodeid mapping when booting Dou Liyang
2016-09-22 19:11   ` [tip:x86/apic] x86/acpi: " tip-bot for Gu Zheng
2016-08-25  8:35 ` [PATCH v12 6/7] acpi: Provide the mechanism to validate processors in the ACPI tables Dou Liyang
2016-09-22 19:12   ` [tip:x86/apic] acpi: Provide " tip-bot for Dou Liyang
2016-08-25  8:35 ` [PATCH v12 7/7] acpi: Provide the interface to validate the proc_id Dou Liyang
2016-09-22 19:12   ` [tip:x86/apic] acpi: Validate processor id when mapping the processor tip-bot for Dou Liyang
2016-08-25  9:08 ` [PATCH v12 0/7] Make cpuid <-> nodeid mapping persistent Dou Liyang
2016-09-02  6:57 ` Dou Liyang
2016-09-13 11:33   ` Dou Liyang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-2532fc318db0e1fe68e01407ee27634c76916e44@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=douly.fnst@cn.fujitsu.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tangchen@cn.fujitsu.com \
    --cc=tglx@linutronix.de \
    --cc=zhugh.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).