linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] MIPS: SGI-IP27: Fix node_distance
@ 2020-01-09 12:23 Thomas Bogendoerfer
  2020-01-09 12:23 ` [PATCH 2/3] MIPS: Loongson64: Fix node_distance() Thomas Bogendoerfer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2020-01-09 12:23 UTC (permalink / raw)
  To: Paul Burton; +Cc: Ralf Baechle, James Hogan, linux-mips, linux-kernel

node_distance must return values starting from 10 up to 255. 10 means
local, 255 unreachable.

Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 arch/mips/sgi-ip27/ip27-memory.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index 563aad5e6398..a0c717662eb1 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -148,25 +148,25 @@ static int __init compute_node_distance(nasid_t nasid_a, nasid_t nasid_b)
 		} while ((brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)));
 	}
 
+	if (nasid_a == nasid_b)
+		return LOCAL_DISTANCE;
+
+	if (router_a == router_b)
+		return LOCAL_DISTANCE + 1;
+
 	if (router_a == NULL) {
 		pr_info("node_distance: router_a NULL\n");
-		return -1;
+		return 255;
 	}
 	if (router_b == NULL) {
 		pr_info("node_distance: router_b NULL\n");
-		return -1;
+		return 255;
 	}
 
-	if (nasid_a == nasid_b)
-		return 0;
-
-	if (router_a == router_b)
-		return 1;
-
 	router_distance = 100;
 	router_recurse(router_a, router_b, 2);
 
-	return router_distance;
+	return LOCAL_DISTANCE + router_distance;
 }
 
 static void __init init_topology_matrix(void)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] MIPS: Loongson64: Fix node_distance()
  2020-01-09 12:23 [PATCH 1/3] MIPS: SGI-IP27: Fix node_distance Thomas Bogendoerfer
@ 2020-01-09 12:23 ` Thomas Bogendoerfer
  2020-01-09 12:23 ` [PATCH 3/3] MIPS: mm: Place per_cpu on different nodes, if NUMA is enabled Thomas Bogendoerfer
  2020-01-09 18:52 ` [PATCH 1/3] MIPS: SGI-IP27: Fix node_distance Paul Burton
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2020-01-09 12:23 UTC (permalink / raw)
  To: Paul Burton
  Cc: Huacai Chen, Jiaxun Yang, Ralf Baechle, James Hogan, linux-mips,
	linux-kernel

Local node distance is defined as LOCAL_DISTANCE, which is 10. Use the
define to give back correct local distance.

Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 arch/mips/loongson64/numa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
index ef94a2278561..e5b40c5e3296 100644
--- a/arch/mips/loongson64/numa.c
+++ b/arch/mips/loongson64/numa.c
@@ -75,7 +75,7 @@ static int __init compute_node_distance(int row, int col)
 				loongson_sysconf.cores_per_package;
 
 	if (col == row)
-		return 0;
+		return LOCAL_DISTANCE;
 	else if (package_row == package_col)
 		return 40;
 	else
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] MIPS: mm: Place per_cpu on different nodes, if NUMA is enabled
  2020-01-09 12:23 [PATCH 1/3] MIPS: SGI-IP27: Fix node_distance Thomas Bogendoerfer
  2020-01-09 12:23 ` [PATCH 2/3] MIPS: Loongson64: Fix node_distance() Thomas Bogendoerfer
@ 2020-01-09 12:23 ` Thomas Bogendoerfer
  2020-01-09 18:52 ` [PATCH 1/3] MIPS: SGI-IP27: Fix node_distance Paul Burton
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2020-01-09 12:23 UTC (permalink / raw)
  To: Paul Burton; +Cc: Ralf Baechle, James Hogan, linux-mips, linux-kernel

Implement placing of per_cpu into memory, which is local to the CPU.

Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 arch/mips/Kconfig   |  8 ++++++++
 arch/mips/mm/init.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ed8e28b0fb3e..cf56b3211a2b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2696,6 +2696,14 @@ config NUMA
 config SYS_SUPPORTS_NUMA
 	bool
 
+config HAVE_SETUP_PER_CPU_AREA
+	def_bool y
+	depends on NUMA
+
+config NEED_PER_CPU_EMBED_FIRST_CHUNK
+	def_bool y
+	depends on NUMA
+
 config RELOCATABLE
 	bool "Relocatable kernel"
 	depends on SYS_SUPPORTS_RELOCATABLE && (CPU_MIPS32_R2 || CPU_MIPS64_R2 || CPU_MIPS32_R6 || CPU_MIPS64_R6 || CAVIUM_OCTEON_SOC)
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 50f9ed8c6c1b..79684000de0e 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -508,6 +508,51 @@ void __ref free_initmem(void)
 		free_initmem_default(POISON_FREE_INITMEM);
 }
 
+#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
+unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
+EXPORT_SYMBOL(__per_cpu_offset);
+
+static int __init pcpu_cpu_distance(unsigned int from, unsigned int to)
+{
+	return node_distance(cpu_to_node(from), cpu_to_node(to));
+}
+
+static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size,
+				       size_t align)
+{
+	return memblock_alloc_try_nid(size, align, __pa(MAX_DMA_ADDRESS),
+				      MEMBLOCK_ALLOC_ACCESSIBLE,
+				      cpu_to_node(cpu));
+}
+
+static void __init pcpu_fc_free(void *ptr, size_t size)
+{
+	memblock_free_early(__pa(ptr), size);
+}
+
+void __init setup_per_cpu_areas(void)
+{
+	unsigned long delta;
+	unsigned int cpu;
+	int rc;
+
+	/*
+	 * Always reserve area for module percpu variables.  That's
+	 * what the legacy allocator did.
+	 */
+	rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE,
+				    PERCPU_DYNAMIC_RESERVE, PAGE_SIZE,
+				    pcpu_cpu_distance,
+				    pcpu_fc_alloc, pcpu_fc_free);
+	if (rc < 0)
+		panic("Failed to initialize percpu areas.");
+
+	delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
+	for_each_possible_cpu(cpu)
+		__per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu];
+}
+#endif
+
 #ifndef CONFIG_MIPS_PGD_C0_CONTEXT
 unsigned long pgd_current[NR_CPUS];
 #endif
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] MIPS: SGI-IP27: Fix node_distance
  2020-01-09 12:23 [PATCH 1/3] MIPS: SGI-IP27: Fix node_distance Thomas Bogendoerfer
  2020-01-09 12:23 ` [PATCH 2/3] MIPS: Loongson64: Fix node_distance() Thomas Bogendoerfer
  2020-01-09 12:23 ` [PATCH 3/3] MIPS: mm: Place per_cpu on different nodes, if NUMA is enabled Thomas Bogendoerfer
@ 2020-01-09 18:52 ` Paul Burton
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Burton @ 2020-01-09 18:52 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: Paul Burton, Ralf Baechle, James Hogan, linux-mips, linux-kernel,
	linux-mips

Hello,

Thomas Bogendoerfer wrote:
> node_distance must return values starting from 10 up to 255. 10 means
> local, 255 unreachable.

Series applied to mips-next.

> MIPS: SGI-IP27: Fix node_distance
>   commit a20ebc047a4a
>   https://git.kernel.org/mips/c/a20ebc047a4a
>   
>   Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
>   Signed-off-by: Paul Burton <paulburton@kernel.org>
> 
> MIPS: Loongson64: Fix node_distance()
>   commit a14879e149c9
>   https://git.kernel.org/mips/c/a14879e149c9
>   
>   Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
>   Signed-off-by: Paul Burton <paulburton@kernel.org>
> 
> MIPS: mm: Place per_cpu on different nodes, if NUMA is enabled
>   commit f3c560a61b4e
>   https://git.kernel.org/mips/c/f3c560a61b4e
>   
>   Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
>   Signed-off-by: Paul Burton <paulburton@kernel.org>

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paulburton@kernel.org to report it. ]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-09 18:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09 12:23 [PATCH 1/3] MIPS: SGI-IP27: Fix node_distance Thomas Bogendoerfer
2020-01-09 12:23 ` [PATCH 2/3] MIPS: Loongson64: Fix node_distance() Thomas Bogendoerfer
2020-01-09 12:23 ` [PATCH 3/3] MIPS: mm: Place per_cpu on different nodes, if NUMA is enabled Thomas Bogendoerfer
2020-01-09 18:52 ` [PATCH 1/3] MIPS: SGI-IP27: Fix node_distance Paul Burton

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).