Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1474100 > unrolled thread
| Started by | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| First post | 2016-09-01 09:00 +0200 |
| Last post | 2016-09-09 04:10 +0200 |
| Articles | 13 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v8 00/16] fix some type infos and bugs for arm64/of numa Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:00 +0200
[PATCH v8 05/16] arm64/numa: avoid inconsistent information to be printed Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:00 +0200
[PATCH v8 07/16] of_numa: Use pr_fmt() Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:00 +0200
[PATCH v8 04/16] of/numa: remove a duplicated warning Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:00 +0200
[PATCH v8 10/16] mm/memblock: add a new function memblock_alloc_near_nid Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:00 +0200
Re: [PATCH v8 10/16] mm/memblock: add a new function memblock_alloc_near_nid "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com> - 2016-09-09 06:00 +0200
[PATCH v8 12/16] arm64/numa: remove some useless code Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:00 +0200
[PATCH v8 06/16] of_numa: Use of_get_next_parent to simplify code Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:00 +0200
[PATCH v8 16/16] arm64/numa: define numa_distance as array to simplify code Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:00 +0200
[PATCH v8 01/16] of/numa: remove a duplicated pr_debug information Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:10 +0200
[PATCH v8 02/16] of/numa: fix a memory@ node can only contains one memory block Zhen Lei <thunder.leizhen@huawei.com> - 2016-09-01 09:10 +0200
Re: [PATCH v8 00/16] fix some type infos and bugs for arm64/of numa Will Deacon <will.deacon@arm.com> - 2016-09-08 13:10 +0200
Re: [PATCH v8 00/16] fix some type infos and bugs for arm64/of numa "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com> - 2016-09-09 04:10 +0200
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:00 +0200 |
| Subject | [PATCH v8 00/16] fix some type infos and bugs for arm64/of numa |
| Message-ID | <scu8F-5sK-3@gated-at.bofh.it> |
v7 -> v8:
Updated patches according to Will Deacon's review comments, thanks.
The changed patches is: 3, 5, 8, 9, 10, 11, 12, 13, 15
Patch 3 requires an ack from Rob Herring.
Patch 10 requires an ack from linux-mm.
Hi, Will:
Something should still be clarified:
Patch 5, I modified it according to my last reply. BTW, The last sentence
"srat_disabled() ? -EINVAL : 0" of arm64_acpi_numa_init should be moved
into acpi_numa_init, I think.
Patch 9, I still leave the code in arch/arm64.
1) the implementation of setup_per_cpu_areas on all platforms are different.
2) Although my implementation referred to PowerPC, but still something different.
Patch 15, I modified the description again. Can you take a look at it? If this patch is
dropped, the patch 14 should also be dropped.
Patch 16, How many times the function node_distance to be called rely on the APP(need many tasks
to be scheduled), I have not prepared yet, so I give up this patch as your advise.
v6 -> v7:
Fix a bug for this patch series when "numa=off" was set in bootargs, this
modification only impact patch 12.
Please refer https://lkml.org/lkml/2016/8/23/249 for more details.
@@ -119,13 +115,13 @@ static void __init setup_node_to_cpumask_map(void)
*/
void numa_store_cpu_info(unsigned int cpu)
{
- map_cpu_to_node(cpu, numa_off ? 0 : cpu_to_node_map[cpu]);
+ map_cpu_to_node(cpu, cpu_to_node_map[cpu]);
}
void __init early_map_cpu_to_node(unsigned int cpu, int nid)
{
/* fallback to node 0 */
- if (nid < 0 || nid >= MAX_NUMNODES)
+ if (nid < 0 || nid >= MAX_NUMNODES || numa_off)
nid = 0;
v5 -> v6:
Move memblk nid check from arch/arm64/mm/numa.c into drivers/of/of_numa.c,
because this check is arch independent.
This modification only related to patch 3, but impacted the contents of patch 7 and 8,
other patches have no change.
v4 -> v5:
This version has no code changes, just add "Acked-by: Rob Herring <robh@kernel.org>"
into patches 1, 2, 4, 6, 7, 13, 14. Because these patches rely on some acpi numa
patches, and the latter had not been upstreamed in 4.7, but upstreamed in 4.8-rc1,
so I resend my patches again.
v3 -> v4:
1. Packed three patches of Kefeng Wang, patch6-8.
2. Add 6 new patches(9-15) to enhance the numa on arm64.
v2 -> v3:
1. Adjust patch2 and patch5 according to Matthias Brugger's advice, to make the
patches looks more well. The final code have no change.
v1 -> v2:
1. Base on https://lkml.org/lkml/2016/5/24/679
2. Rewrote of_numa_parse_memory_nodes according to Rob Herring's advice. So that it looks more clear.
3. Rewrote patch 5 because some scenes were not considered before.
Kefeng Wang (3):
of_numa: Use of_get_next_parent to simplify code
of_numa: Use pr_fmt()
arm64: numa: Use pr_fmt()
Zhen Lei (13):
of/numa: remove a duplicated pr_debug information
of/numa: fix a memory@ node can only contains one memory block
of/numa: add nid check for memory block
of/numa: remove a duplicated warning
arm64/numa: avoid inconsistent information to be printed
arm64/numa: support HAVE_SETUP_PER_CPU_AREA
mm/memblock: add a new function memblock_alloc_near_nid
arm64/numa: support HAVE_MEMORYLESS_NODES
arm64/numa: remove some useless code
arm64/numa: remove the limitation that cpu0 must bind to node0
of/numa: remove the constraint on the distances of node pairs
Documentation: remove the constraint on the distances of node pairs
arm64/numa: define numa_distance as array to simplify code
Documentation/devicetree/bindings/numa.txt | 12 +-
arch/arm64/Kconfig | 12 ++
arch/arm64/include/asm/numa.h | 1 -
arch/arm64/kernel/acpi_numa.c | 4 +-
arch/arm64/kernel/smp.c | 1 +
arch/arm64/mm/numa.c | 190 ++++++++++++++---------------
drivers/of/of_numa.c | 88 +++++++------
include/linux/memblock.h | 1 +
mm/memblock.c | 28 +++++
9 files changed, 184 insertions(+), 153 deletions(-)
--
2.5.0
[toc] | [next] | [standalone]
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:00 +0200 |
| Subject | [PATCH v8 05/16] arm64/numa: avoid inconsistent information to be printed |
| Message-ID | <scu8G-5sK-25@gated-at.bofh.it> |
| In reply to | #1474100 |
numa_init may return error because of numa configuration error. So "No
NUMA configuration found" is inaccurate. In fact, specific configuration
error information should be immediately printed by the testing branch.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
arch/arm64/kernel/acpi_numa.c | 4 +++-
arch/arm64/mm/numa.c | 6 +++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kernel/acpi_numa.c b/arch/arm64/kernel/acpi_numa.c
index f85149c..f01fab6 100644
--- a/arch/arm64/kernel/acpi_numa.c
+++ b/arch/arm64/kernel/acpi_numa.c
@@ -105,8 +105,10 @@ int __init arm64_acpi_numa_init(void)
int ret;
ret = acpi_numa_init();
- if (ret)
+ if (ret) {
+ pr_info("Failed to initialise from firmware\n");
return ret;
+ }
return srat_disabled() ? -EINVAL : 0;
}
diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
index 5bb15ea..d97c6e2 100644
--- a/arch/arm64/mm/numa.c
+++ b/arch/arm64/mm/numa.c
@@ -335,8 +335,10 @@ static int __init numa_init(int (*init_func)(void))
if (ret < 0)
return ret;
- if (nodes_empty(numa_nodes_parsed))
+ if (nodes_empty(numa_nodes_parsed)) {
+ pr_info("No NUMA configuration found\n");
return -EINVAL;
+ }
ret = numa_register_nodes();
if (ret < 0)
@@ -367,8 +369,6 @@ static int __init dummy_numa_init(void)
if (numa_off)
pr_info("NUMA disabled\n"); /* Forced off on command line. */
- else
- pr_info("No NUMA configuration found\n");
pr_info("NUMA: Faking a node at [mem %#018Lx-%#018Lx]\n",
0LLU, PFN_PHYS(max_pfn) - 1);
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:00 +0200 |
| Subject | [PATCH v8 07/16] of_numa: Use pr_fmt() |
| Message-ID | <scu8G-5sK-29@gated-at.bofh.it> |
| In reply to | #1474100 |
From: Kefeng Wang <wangkefeng.wang@huawei.com>
Use pr_fmt to prefix kernel output.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: Rob Herring <robh@kernel.org>
---
drivers/of/of_numa.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
index 0d7459b..f63d4b0d 100644
--- a/drivers/of/of_numa.c
+++ b/drivers/of/of_numa.c
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define pr_fmt(fmt) "OF: NUMA: " fmt
+
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/nodemask.h>
@@ -49,10 +51,9 @@ static void __init of_numa_parse_cpu_nodes(void)
if (r)
continue;
- pr_debug("NUMA: CPU on %u\n", nid);
+ pr_debug("CPU on %u\n", nid);
if (nid >= MAX_NUMNODES)
- pr_warn("NUMA: Node id %u exceeds maximum value\n",
- nid);
+ pr_warn("Node id %u exceeds maximum value\n", nid);
else
node_set(nid, numa_nodes_parsed);
}
@@ -76,7 +77,7 @@ static int __init of_numa_parse_memory_nodes(void)
continue;
if (nid >= MAX_NUMNODES) {
- pr_warn("NUMA: Node id %u exceeds maximum value\n", nid);
+ pr_warn("Node id %u exceeds maximum value\n", nid);
r = -EINVAL;
}
@@ -85,7 +86,7 @@ static int __init of_numa_parse_memory_nodes(void)
if (!i || r) {
of_node_put(np);
- pr_err("NUMA: bad property in memory node\n");
+ pr_err("bad property in memory node\n");
return r ? : -EINVAL;
}
}
@@ -99,17 +100,17 @@ static int __init of_numa_parse_distance_map_v1(struct device_node *map)
int entry_count;
int i;
- pr_info("NUMA: parsing numa-distance-map-v1\n");
+ pr_info("parsing numa-distance-map-v1\n");
matrix = of_get_property(map, "distance-matrix", NULL);
if (!matrix) {
- pr_err("NUMA: No distance-matrix property in distance-map\n");
+ pr_err("No distance-matrix property in distance-map\n");
return -EINVAL;
}
entry_count = of_property_count_u32_elems(map, "distance-matrix");
if (entry_count <= 0) {
- pr_err("NUMA: Invalid distance-matrix\n");
+ pr_err("Invalid distance-matrix\n");
return -EINVAL;
}
@@ -124,7 +125,7 @@ static int __init of_numa_parse_distance_map_v1(struct device_node *map)
matrix++;
numa_set_distance(nodea, nodeb, distance);
- pr_debug("NUMA: distance[node%d -> node%d] = %d\n",
+ pr_debug("distance[node%d -> node%d] = %d\n",
nodea, nodeb, distance);
/* Set default distance of node B->A same as A->B */
@@ -171,7 +172,7 @@ int of_node_to_nid(struct device_node *device)
np = of_get_next_parent(np);
}
if (np && r)
- pr_warn("NUMA: Invalid \"numa-node-id\" property in node %s\n",
+ pr_warn("Invalid \"numa-node-id\" property in node %s\n",
np->name);
of_node_put(np);
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:00 +0200 |
| Subject | [PATCH v8 04/16] of/numa: remove a duplicated warning |
| Message-ID | <scu8G-5sK-31@gated-at.bofh.it> |
| In reply to | #1474100 |
This warning has been printed in of_numa_parse_cpu_nodes before.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Acked-by: Rob Herring <robh@kernel.org>
---
drivers/of/of_numa.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
index c1bd62c..625b057 100644
--- a/drivers/of/of_numa.c
+++ b/drivers/of/of_numa.c
@@ -179,13 +179,8 @@ int of_node_to_nid(struct device_node *device)
np->name);
of_node_put(np);
- if (!r) {
- if (nid >= MAX_NUMNODES)
- pr_warn("NUMA: Node id %u exceeds maximum value\n",
- nid);
- else
- return nid;
- }
+ if (!r)
+ return nid;
return NUMA_NO_NODE;
}
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:00 +0200 |
| Subject | [PATCH v8 10/16] mm/memblock: add a new function memblock_alloc_near_nid |
| Message-ID | <scu8G-5sK-35@gated-at.bofh.it> |
| In reply to | #1474100 |
If HAVE_MEMORYLESS_NODES is selected, and some memoryless numa nodes are
actually exist. The percpu variable areas and numa control blocks of that
memoryless numa nodes must be allocated from the nearest available node
to improve performance.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
include/linux/memblock.h | 1 +
mm/memblock.c | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 2925da2..8e866e0 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -290,6 +290,7 @@ static inline int memblock_get_region_node(const struct memblock_region *r)
phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid);
phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid);
+phys_addr_t memblock_alloc_near_nid(phys_addr_t size, phys_addr_t align, int nid);
phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align);
diff --git a/mm/memblock.c b/mm/memblock.c
index 483197e..6578fff 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1189,6 +1189,34 @@ again:
return ret;
}
+phys_addr_t __init memblock_alloc_near_nid(phys_addr_t size, phys_addr_t align, int nid)
+{
+ int i, best_nid, distance;
+ u64 pa;
+ DECLARE_BITMAP(nodes_map, MAX_NUMNODES);
+
+ bitmap_zero(nodes_map, MAX_NUMNODES);
+
+find_nearest_node:
+ best_nid = NUMA_NO_NODE;
+ distance = INT_MAX;
+
+ for_each_clear_bit(i, nodes_map, MAX_NUMNODES)
+ if (node_distance(nid, i) < distance) {
+ best_nid = i;
+ distance = node_distance(nid, i);
+ }
+
+ pa = memblock_alloc_nid(size, align, best_nid);
+ if (!pa) {
+ BUG_ON(best_nid == NUMA_NO_NODE);
+ bitmap_set(nodes_map, best_nid, 1);
+ goto find_nearest_node;
+ }
+
+ return pa;
+}
+
phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
{
return memblock_alloc_base_nid(size, align, max_addr, NUMA_NO_NODE,
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-09 06:00 +0200 |
| Subject | Re: [PATCH v8 10/16] mm/memblock: add a new function memblock_alloc_near_nid |
| Message-ID | <sfl8R-6bQ-5@gated-at.bofh.it> |
| In reply to | #1474106 |
Hi, linux-mm folks:
Can somebody help me to review this patch?
I ran scripts/get_maintainer.pl -f mm/memblock.c and scripts/get_maintainer.pl -f mm/, but
the results showed me that there is no maintainer.
To understand this patch should also read patch 11.
On 2016/9/1 14:55, Zhen Lei wrote:
> If HAVE_MEMORYLESS_NODES is selected, and some memoryless numa nodes are
> actually exist. The percpu variable areas and numa control blocks of that
> memoryless numa nodes must be allocated from the nearest available node
> to improve performance.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
> include/linux/memblock.h | 1 +
> mm/memblock.c | 28 ++++++++++++++++++++++++++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> index 2925da2..8e866e0 100644
> --- a/include/linux/memblock.h
> +++ b/include/linux/memblock.h
> @@ -290,6 +290,7 @@ static inline int memblock_get_region_node(const struct memblock_region *r)
>
> phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid);
> phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid);
> +phys_addr_t memblock_alloc_near_nid(phys_addr_t size, phys_addr_t align, int nid);
>
> phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align);
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 483197e..6578fff 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -1189,6 +1189,34 @@ again:
> return ret;
> }
>
> +phys_addr_t __init memblock_alloc_near_nid(phys_addr_t size, phys_addr_t align, int nid)
> +{
> + int i, best_nid, distance;
> + u64 pa;
> + DECLARE_BITMAP(nodes_map, MAX_NUMNODES);
> +
> + bitmap_zero(nodes_map, MAX_NUMNODES);
> +
> +find_nearest_node:
> + best_nid = NUMA_NO_NODE;
> + distance = INT_MAX;
> +
> + for_each_clear_bit(i, nodes_map, MAX_NUMNODES)
> + if (node_distance(nid, i) < distance) {
> + best_nid = i;
> + distance = node_distance(nid, i);
> + }
> +
> + pa = memblock_alloc_nid(size, align, best_nid);
> + if (!pa) {
> + BUG_ON(best_nid == NUMA_NO_NODE);
> + bitmap_set(nodes_map, best_nid, 1);
> + goto find_nearest_node;
> + }
> +
> + return pa;
> +}
> +
> phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
> {
> return memblock_alloc_base_nid(size, align, max_addr, NUMA_NO_NODE,
> --
> 2.5.0
>
>
>
> .
>
[toc] | [prev] | [next] | [standalone]
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:00 +0200 |
| Subject | [PATCH v8 12/16] arm64/numa: remove some useless code |
| Message-ID | <scu8G-5sK-39@gated-at.bofh.it> |
| In reply to | #1474100 |
When the deleted code is executed, only the bit of cpu0 was set on
cpu_possible_mask. So that, only set_cpu_numa_node(0, NUMA_NO_NODE); will
be executed. And map_cpu_to_node(0, 0) will soon be called. So these code
can be safely removed.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
arch/arm64/mm/numa.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
index 891bdaa..72f4539 100644
--- a/arch/arm64/mm/numa.c
+++ b/arch/arm64/mm/numa.c
@@ -95,7 +95,6 @@ void numa_clear_node(unsigned int cpu)
*/
static void __init setup_node_to_cpumask_map(void)
{
- unsigned int cpu;
int node;
/* setup nr_node_ids if not done yet */
@@ -108,9 +107,6 @@ static void __init setup_node_to_cpumask_map(void)
cpumask_clear(node_to_cpumask_map[node]);
}
- for_each_possible_cpu(cpu)
- set_cpu_numa_node(cpu, NUMA_NO_NODE);
-
/* cpumask_of_node() will now work */
pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids);
}
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:00 +0200 |
| Subject | [PATCH v8 06/16] of_numa: Use of_get_next_parent to simplify code |
| Message-ID | <scu8G-5sK-33@gated-at.bofh.it> |
| In reply to | #1474100 |
From: Kefeng Wang <wangkefeng.wang@huawei.com>
Use of_get_next_parent() instead of open-code.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: Rob Herring <robh@kernel.org>
---
drivers/of/of_numa.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
index 625b057..0d7459b 100644
--- a/drivers/of/of_numa.c
+++ b/drivers/of/of_numa.c
@@ -158,8 +158,6 @@ int of_node_to_nid(struct device_node *device)
np = of_node_get(device);
while (np) {
- struct device_node *parent;
-
r = of_property_read_u32(np, "numa-node-id", &nid);
/*
* -EINVAL indicates the property was not found, and
@@ -170,9 +168,7 @@ int of_node_to_nid(struct device_node *device)
if (r != -EINVAL)
break;
- parent = of_get_parent(np);
- of_node_put(np);
- np = parent;
+ np = of_get_next_parent(np);
}
if (np && r)
pr_warn("NUMA: Invalid \"numa-node-id\" property in node %s\n",
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:00 +0200 |
| Subject | [PATCH v8 16/16] arm64/numa: define numa_distance as array to simplify code |
| Message-ID | <scu8G-5sK-37@gated-at.bofh.it> |
| In reply to | #1474100 |
1. MAX_NUMNODES is base on CONFIG_NODES_SHIFT, the default value of the
latter is very small now.
2. Suppose the default value of MAX_NUMNODES is enlarged to 64, so the
size of numa_distance is 4K, it's still acceptable if run the Image
on other processors.
3. It will make function __node_distance quicker than before.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
arch/arm64/include/asm/numa.h | 1 -
arch/arm64/mm/numa.c | 74 +++----------------------------------------
2 files changed, 5 insertions(+), 70 deletions(-)
diff --git a/arch/arm64/include/asm/numa.h b/arch/arm64/include/asm/numa.h
index 600887e..9b6cc38 100644
--- a/arch/arm64/include/asm/numa.h
+++ b/arch/arm64/include/asm/numa.h
@@ -32,7 +32,6 @@ static inline const struct cpumask *cpumask_of_node(int node)
void __init arm64_numa_init(void);
int __init numa_add_memblk(int nodeid, u64 start, u64 end);
void __init numa_set_distance(int from, int to, int distance);
-void __init numa_free_distance(void);
void __init early_map_cpu_to_node(unsigned int cpu, int nid);
void numa_store_cpu_info(unsigned int cpu);
diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
index ef7e336..15ff117 100644
--- a/arch/arm64/mm/numa.c
+++ b/arch/arm64/mm/numa.c
@@ -33,8 +33,7 @@ EXPORT_SYMBOL(node_data);
nodemask_t numa_nodes_parsed __initdata;
static int cpu_to_node_map[NR_CPUS] = { [0 ... NR_CPUS-1] = NUMA_NO_NODE };
-static int numa_distance_cnt;
-static u8 *numa_distance;
+static u8 numa_distance[MAX_NUMNODES][MAX_NUMNODES];
static bool numa_off;
static __init int numa_parse_early_param(char *opt)
@@ -245,59 +244,6 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)
}
/**
- * numa_free_distance
- *
- * The current table is freed.
- */
-void __init numa_free_distance(void)
-{
- size_t size;
-
- if (!numa_distance)
- return;
-
- size = numa_distance_cnt * numa_distance_cnt *
- sizeof(numa_distance[0]);
-
- memblock_free(__pa(numa_distance), size);
- numa_distance_cnt = 0;
- numa_distance = NULL;
-}
-
-/**
- *
- * Create a new NUMA distance table.
- *
- */
-static int __init numa_alloc_distance(void)
-{
- size_t size;
- u64 phys;
- int i, j;
-
- size = nr_node_ids * nr_node_ids * sizeof(numa_distance[0]);
- phys = memblock_find_in_range(0, PFN_PHYS(max_pfn),
- size, PAGE_SIZE);
- if (WARN_ON(!phys))
- return -ENOMEM;
-
- memblock_reserve(phys, size);
-
- numa_distance = __va(phys);
- numa_distance_cnt = nr_node_ids;
-
- /* fill with the default distances */
- for (i = 0; i < numa_distance_cnt; i++)
- for (j = 0; j < numa_distance_cnt; j++)
- numa_distance[i * numa_distance_cnt + j] = i == j ?
- LOCAL_DISTANCE : REMOTE_DISTANCE;
-
- pr_debug("Initialized distance table, cnt=%d\n", numa_distance_cnt);
-
- return 0;
-}
-
-/**
* numa_set_distance - Set inter node NUMA distance from node to node.
* @from: the 'from' node to set distance
* @to: the 'to' node to set distance
@@ -312,12 +258,7 @@ static int __init numa_alloc_distance(void)
*/
void __init numa_set_distance(int from, int to, int distance)
{
- if (!numa_distance) {
- pr_warn_once("Warning: distance table not allocated yet\n");
- return;
- }
-
- if (from >= numa_distance_cnt || to >= numa_distance_cnt ||
+ if (from >= MAX_NUMNODES || to >= MAX_NUMNODES ||
from < 0 || to < 0) {
pr_warn_once("Warning: node ids are out of bound, from=%d to=%d distance=%d\n",
from, to, distance);
@@ -331,7 +272,7 @@ void __init numa_set_distance(int from, int to, int distance)
return;
}
- numa_distance[from * numa_distance_cnt + to] = distance;
+ numa_distance[from][to] = distance;
}
/**
@@ -339,9 +280,9 @@ void __init numa_set_distance(int from, int to, int distance)
*/
int __node_distance(int from, int to)
{
- if (from >= numa_distance_cnt || to >= numa_distance_cnt)
+ if (from >= MAX_NUMNODES || to >= MAX_NUMNODES)
return from == to ? LOCAL_DISTANCE : REMOTE_DISTANCE;
- return numa_distance[from * numa_distance_cnt + to];
+ return numa_distance[from][to];
}
EXPORT_SYMBOL(__node_distance);
@@ -381,11 +322,6 @@ static int __init numa_init(int (*init_func)(void))
nodes_clear(numa_nodes_parsed);
nodes_clear(node_possible_map);
nodes_clear(node_online_map);
- numa_free_distance();
-
- ret = numa_alloc_distance();
- if (ret < 0)
- return ret;
ret = init_func();
if (ret < 0)
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:10 +0200 |
| Subject | [PATCH v8 01/16] of/numa: remove a duplicated pr_debug information |
| Message-ID | <scuim-5Pb-21@gated-at.bofh.it> |
| In reply to | #1474100 |
This information will be printed in the subfunction numa_add_memblk.
They are not the same, but very similar.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Acked-by: Rob Herring <robh@kernel.org>
---
drivers/of/of_numa.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
index ed5a097..fb71b4e 100644
--- a/drivers/of/of_numa.c
+++ b/drivers/of/of_numa.c
@@ -88,10 +88,6 @@ static int __init of_numa_parse_memory_nodes(void)
break;
}
- pr_debug("NUMA: base = %llx len = %llx, node = %u\n",
- rsrc.start, rsrc.end - rsrc.start + 1, nid);
-
-
r = numa_add_memblk(nid, rsrc.start, rsrc.end + 1);
if (r)
break;
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-01 09:10 +0200 |
| Subject | [PATCH v8 02/16] of/numa: fix a memory@ node can only contains one memory block |
| Message-ID | <scuim-5Pb-45@gated-at.bofh.it> |
| In reply to | #1474100 |
For a normal memory@ devicetree node, its reg property can contains more
memory blocks.
Because we don't known how many memory blocks maybe contained, so we try
from index=0, increase 1 until error returned(the end).
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Acked-by: Rob Herring <robh@kernel.org>
---
drivers/of/of_numa.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
index fb71b4e..7b3fbdc 100644
--- a/drivers/of/of_numa.c
+++ b/drivers/of/of_numa.c
@@ -63,13 +63,9 @@ static int __init of_numa_parse_memory_nodes(void)
struct device_node *np = NULL;
struct resource rsrc;
u32 nid;
- int r = 0;
-
- for (;;) {
- np = of_find_node_by_type(np, "memory");
- if (!np)
- break;
+ int i, r;
+ for_each_node_by_type(np, "memory") {
r = of_property_read_u32(np, "numa-node-id", &nid);
if (r == -EINVAL)
/*
@@ -78,23 +74,18 @@ static int __init of_numa_parse_memory_nodes(void)
* "numa-node-id" property
*/
continue;
- else if (r)
- /* some other error */
- break;
- r = of_address_to_resource(np, 0, &rsrc);
- if (r) {
- pr_err("NUMA: bad reg property in memory node\n");
- break;
- }
+ for (i = 0; !r && !of_address_to_resource(np, i, &rsrc); i++)
+ r = numa_add_memblk(nid, rsrc.start, rsrc.end + 1);
- r = numa_add_memblk(nid, rsrc.start, rsrc.end + 1);
- if (r)
- break;
+ if (!i || r) {
+ of_node_put(np);
+ pr_err("NUMA: bad property in memory node\n");
+ return r ? : -EINVAL;
+ }
}
- of_node_put(np);
- return r;
+ return 0;
}
static int __init of_numa_parse_distance_map_v1(struct device_node *map)
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Date | 2016-09-08 13:10 +0200 |
| Message-ID | <sf5nt-53y-45@gated-at.bofh.it> |
| In reply to | #1474100 |
On Thu, Sep 01, 2016 at 02:54:51PM +0800, Zhen Lei wrote: > v7 -> v8: > Updated patches according to Will Deacon's review comments, thanks. > > The changed patches is: 3, 5, 8, 9, 10, 11, 12, 13, 15 > Patch 3 requires an ack from Rob Herring. > Patch 10 requires an ack from linux-mm. > > Hi, Will: > Something should still be clarified: > Patch 5, I modified it according to my last reply. BTW, The last sentence > "srat_disabled() ? -EINVAL : 0" of arm64_acpi_numa_init should be moved > into acpi_numa_init, I think. > > Patch 9, I still leave the code in arch/arm64. > 1) the implementation of setup_per_cpu_areas on all platforms are different. > 2) Although my implementation referred to PowerPC, but still something different. > > Patch 15, I modified the description again. Can you take a look at it? If this patch is > dropped, the patch 14 should also be dropped. > > Patch 16, How many times the function node_distance to be called rely on the APP(need many tasks > to be scheduled), I have not prepared yet, so I give up this patch as your advise. Ok, I'm trying to pick the pieces out of this patch series and it's not especially easy. As far as I can tell: Patch 3 needs an ack from the device-tree folks Patch 10 needs an ack from the memblock folks Patch 11 depends on patch 10 Patches 14,15,16 can wait for the time being (I still don't see their value). So, I could pick up patches 1-2, 4-9 and 12-13 but it's not clear whether that makes any sense. The whole series seems to be a mix of trivial printk cleanups, a bunch of core OF stuff, some new features and then some questionable changes at the end. Please throw me a clue, Will
[toc] | [prev] | [next] | [standalone]
| From | "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2016-09-09 04:10 +0200 |
| Message-ID | <sfjqp-5jW-1@gated-at.bofh.it> |
| In reply to | #1479100 |
On 2016/9/8 19:01, Will Deacon wrote: > On Thu, Sep 01, 2016 at 02:54:51PM +0800, Zhen Lei wrote: >> v7 -> v8: >> Updated patches according to Will Deacon's review comments, thanks. >> >> The changed patches is: 3, 5, 8, 9, 10, 11, 12, 13, 15 >> Patch 3 requires an ack from Rob Herring. >> Patch 10 requires an ack from linux-mm. >> >> Hi, Will: >> Something should still be clarified: >> Patch 5, I modified it according to my last reply. BTW, The last sentence >> "srat_disabled() ? -EINVAL : 0" of arm64_acpi_numa_init should be moved >> into acpi_numa_init, I think. >> >> Patch 9, I still leave the code in arch/arm64. >> 1) the implementation of setup_per_cpu_areas on all platforms are different. >> 2) Although my implementation referred to PowerPC, but still something different. >> >> Patch 15, I modified the description again. Can you take a look at it? If this patch is >> dropped, the patch 14 should also be dropped. >> >> Patch 16, How many times the function node_distance to be called rely on the APP(need many tasks >> to be scheduled), I have not prepared yet, so I give up this patch as your advise. > > Ok, I'm trying to pick the pieces out of this patch series and it's not > especially easy. As far as I can tell: > > Patch 3 needs an ack from the device-tree folks Rob just acked. > > Patch 10 needs an ack from the memblock folks I'll immediately send a email to remind them. > > Patch 11 depends on patch 10 > > Patches 14,15,16 can wait for the time being (I still don't see their > value). OK, that's no problem. So I put them in the end beforehand. > > So, I could pick up patches 1-2, 4-9 and 12-13 but it's not clear whether Now you can also add patch 3. > that makes any sense. The whole series seems to be a mix of trivial printk The most valueable patches are: patch 2, 9, 11. The other is just because of a programmer wants the code to be nice. > cleanups, a bunch of core OF stuff, some new features and then some > questionable changes at the end. > > Please throw me a clue, > > Will > > . >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web