Skip to contentSkip to conversation

sh: remove NUMA and SPARSEMEM support

PATCH Superseded Mike Rapoport 3 participants 15 messages Apr 13 – Apr 28

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover sh: remove NUMA and SPARSEMEM support

From: "Mike Rapoport (Microsoft)" <[email protected]>

Hi,

NUMA support for SuperH was introduced a long time ago by commit b241cb0c885e ("sh: Support for multiple nodes.")

"... for boards with many different memory blocks that are
otherwise unused (SH7722/SH7785 URAM and so forth)"

In reality, this added 128K of memory on sh7722 and sh7785 and 256K on shx3 at the expense of all the NUMA related code in the kernel.

For build of v7.0-rc7 with defconfig and the same configuration with CONFIG_NUMA disabled, bloat-o-meter reports difference of ~76k. Disabling CONFIG_SPARSMEM on top increases the difference to ~94k. And that's only overhead in code and static data that does not take into the account data structures allocated at run time.

And all this overhead has been there for nothing for almost 8 years because since commit ac21fc2dcb40 ("sh: switch to NO_BOOTMEM") those additional "nodes" could not be used by the core MM because the maximal pfn for ZONE_NORMAL was cut out at the end of the normal memory.

Mike Rapoport (Microsoft) (10):
sh: remove CONFIG_NUMA and realted configuration options
sh: mm: remove numa.c
sh: mm: drop allocate_pgdat()
sh: remove setup_bootmem_node() and plat_mem_setup()
sh: drop dead code guarded by #ifdef CONFIG_NUMA
sh: drop include/asm/mmzone.h
init/Kconfig: drop ARCH_WANT_NUMA_VARIABLE_LOCALITY
sh: init: remove call the memblock_set_node()
sh: remove SPARSEMEM related entries from Kconfig
sh: drop include/asm/sparsemem.h

 arch/sh/Kconfig                        |  8 ----
 arch/sh/configs/migor_defconfig        |  1 -
 arch/sh/configs/sdk7786_defconfig      |  1 -
 arch/sh/configs/se7722_defconfig       |  1 -
 arch/sh/configs/shx3_defconfig         |  1 -
 arch/sh/configs/ul2_defconfig          |  1 -
 arch/sh/include/asm/mmu.h              |  2 +
 arch/sh/include/asm/mmzone.h           | 42 --------------------
 arch/sh/include/asm/setup.h            |  3 ++
 arch/sh/include/asm/sparsemem.h        | 12 ------
 arch/sh/include/asm/topology.h         | 13 -------
 arch/sh/kernel/cpu/sh4a/setup-sh7366.c |  5 ---
 arch/sh/kernel/cpu/sh4a/setup-sh7722.c |  7 ----
 arch/sh/kernel/cpu/sh4a/setup-sh7723.c |  1 -
 arch/sh/kernel/cpu/sh4a/setup-sh7724.c |  1 -
 arch/sh/kernel/cpu/sh4a/setup-sh7757.c |  5 ---
 arch/sh/kernel/cpu/sh4a/setup-sh7785.c |  7 ----
 arch/sh/kernel/cpu/sh4a/setup-sh7786.c |  5 ---
 arch/sh/kernel/cpu/sh4a/setup-shx3.c   | 18 ---------
 arch/sh/kernel/setup.c                 |  7 ----
 arch/sh/kernel/topology.c              | 12 ------
 arch/sh/kernel/vmcore_info.c           |  4 --
 arch/sh/mm/Kconfig                     | 29 --------------
 arch/sh/mm/Makefile                    |  1 -
 arch/sh/mm/init.c                      | 24 ------------
 arch/sh/mm/numa.c                      | 53 --------------------------
 arch/sh/mm/sram.c                      |  3 +-
 init/Kconfig                           |  7 ----
 28 files changed, 6 insertions(+), 268 deletions(-)
 delete mode 100644 arch/sh/include/asm/mmzone.h
 delete mode 100644 arch/sh/include/asm/sparsemem.h
 delete mode 100644 arch/sh/mm/numa.c

base-commit: 591cd656a1bf5ea94a222af5ef2ee76df029c1d2 --
2.53.0

#1 lore raw

PATCH 1/10 sh: remove CONFIG_NUMA and realted configuration options

From: "Mike Rapoport (Microsoft)" <[email protected]>

NUMA support for SuperH was introduced a long time ago by commit b241cb0c885e ("sh: Support for multiple nodes.")

"... for boards with many different memory blocks that are
otherwise unused (SH7722/SH7785 URAM and so forth)"

In reality, this added 128K of memory on sh7722 and sh7785 and 256K on shx3 at the expense of all the NUMA related code in the kernel.

For build of v7.0-rc7 with defconfig and the same configuration with CONFIG_NUMA disabled, bloat-o-meter reports difference of ~76k. Disabling CONFIG_SPARSMEM on top increases the difference to ~94k. And that's only overhead in code and static data that does not take into the account data structures allocated at run time.

And all this overhead has been there for nothing for almost 8 years because since commit ac21fc2dcb40 ("sh: switch to NO_BOOTMEM") those additional "nodes" could not be used by the core MM because the maximal pfn for ZONE_NORMAL was cut out at the end of the normal memory.

Start removing NUMA support on sh with removing CONFIG_NUMA and related configuration options in arch/sh/Kconfig and arch/sh/mm/Kconfig.

---
 arch/sh/configs/migor_defconfig   |  1 -
 arch/sh/configs/sdk7786_defconfig |  1 -
 arch/sh/configs/se7722_defconfig  |  1 -
 arch/sh/configs/shx3_defconfig    |  1 -
 arch/sh/configs/ul2_defconfig     |  1 -
 arch/sh/mm/Kconfig                | 19 -------------------
 6 files changed, 24 deletions(-)
arch/sh/configs/migor_defconfig +0 -1
index 1d9d543eef4c..db993616f14e 100644
@@ -9,7 +9,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_CPU_SUBTYPE_SH7722=y
 CONFIG_MEMORY_START=0x0c000000
-CONFIG_NUMA=y
 # CONFIG_MIGRATION is not set
 CONFIG_SH_MIGOR=y
 # CONFIG_SH_TIMER_CMT is not set
arch/sh/configs/sdk7786_defconfig +0 -1
index d6fa3a422e24..36e6dd0622f7 100644
@@ -41,7 +41,6 @@ CONFIG_CPU_SUBTYPE_SH7786=y
 CONFIG_MEMORY_START=0x40000000
 CONFIG_MEMORY_SIZE=0x20000000
 CONFIG_PMB=y
-CONFIG_NUMA=y
 CONFIG_HUGETLB_PAGE_SIZE_64MB=y
 CONFIG_KSM=y
 CONFIG_SH_STORE_QUEUES=y
arch/sh/configs/se7722_defconfig +0 -1
index 85b8eb013b79..2908611b118e 100644
@@ -10,7 +10,6 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_CPU_SUBTYPE_SH7722=y
 CONFIG_MEMORY_START=0x0c000000
-CONFIG_NUMA=y
 CONFIG_SH_STORE_QUEUES=y
 CONFIG_SH_7722_SOLUTION_ENGINE=y
 # CONFIG_SH_TIMER_CMT is not set
arch/sh/configs/shx3_defconfig +0 -1
index 0cb69a0b92cb..22c242cf89f7 100644
@@ -29,7 +29,6 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_CPU_SUBTYPE_SHX3=y
 CONFIG_MEMORY_START=0x0c000000
-CONFIG_NUMA=y
 CONFIG_PAGE_SIZE_64KB=y
 CONFIG_SH_STORE_QUEUES=y
 CONFIG_SH_X3PROTO=y
arch/sh/configs/ul2_defconfig +0 -1
index 0d1c858754db..ff15d68dd12d 100644
@@ -10,7 +10,6 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_CPU_SUBTYPE_SH7366=y
 CONFIG_MEMORY_SIZE=0x01f00000
-CONFIG_NUMA=y
 # CONFIG_MIGRATION is not set
 # CONFIG_SH_DSP is not set
 # CONFIG_SH_TIMER_CMT is not set
arch/sh/mm/Kconfig +0 -19
index 1862411665ab..71fecbbb080e 100644
@@ -112,27 +112,8 @@ config VSYSCALL
 	  For systems with an MMU that can afford to give up a page,
 	  (the default value) say Y.
 
-config NUMA
-	bool "Non-Uniform Memory Access (NUMA) Support"
-	depends on MMU && SYS_SUPPORTS_NUMA
-	select ARCH_WANT_NUMA_VARIABLE_LOCALITY
-	default n
-	help
-	  Some SH systems have many various memories scattered around
-	  the address space, each with varying latencies. This enables
-	  support for these blocks by binding them to nodes and allowing
-	  memory policies to be used for prioritizing and controlling
-	  allocation behaviour.
-
-config NODES_SHIFT
-	int
-	default "3" if CPU_SUBTYPE_SHX3
-	default "1"
-	depends on NUMA
-
 config ARCH_FLATMEM_ENABLE
 	def_bool y
-	depends on !NUMA
 
 config ARCH_SPARSEMEM_ENABLE
 	def_bool y
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/10 sh: mm: remove numa.c

In reply to Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

Since CONFIG_NUMA is removed, numa.c won't be ever compiled.

Remove it.

---
 arch/sh/mm/Makefile |  1 -
 arch/sh/mm/numa.c   | 53 ---------------------------------------------
 2 files changed, 54 deletions(-)
 delete mode 100644 arch/sh/mm/numa.c
arch/sh/mm/Makefile +0 -1
index f69ddc70b146..7033947955d6 100644
@@ -37,7 +37,6 @@ endif
 obj-$(CONFIG_DEBUG_FS)		+= $(debugfs-y)
 obj-$(CONFIG_HUGETLB_PAGE)	+= hugetlbpage.o
 obj-$(CONFIG_PMB)		+= pmb.o
-obj-$(CONFIG_NUMA)		+= numa.o
 obj-$(CONFIG_IOREMAP_FIXED)	+= ioremap_fixed.o
 obj-$(CONFIG_UNCACHED_MAPPING)	+= uncached.o
 obj-$(CONFIG_HAVE_SRAM_POOL)	+= sram.o
arch/sh/mm/numa.c deleted +0 -53

53 lines not on this page · raw message

Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/10 sh: mm: drop allocate_pgdat()

In reply to Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

allocate_pgdat() function used to allocate the node data structure and initialize its node_start_pfn and node_spanned_pages fields.

Without CONFIG_NUMA there is no need to allocate the node data and setting node_start_pfn and node_spanned_pages are redundant because they are anyway overwritten later by core MM.

Remove allocate_pgdat() function.

---
 arch/sh/mm/init.c | 16 ----------------
 1 file changed, 16 deletions(-)
arch/sh/mm/init.c +0 -16
index 464a3a63e2fa..977392b478b3 100644
@@ -199,20 +199,6 @@ void __init page_table_range_init(unsigned long start, unsigned long end,
 }
 #endif	/* CONFIG_MMU */
 
-void __init allocate_pgdat(unsigned int nid)
-{
-	unsigned long start_pfn, end_pfn;
-
-	get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
-
-#ifdef CONFIG_NUMA
-	alloc_node_data(nid);
-#endif
-
-	NODE_DATA(nid)->node_start_pfn = start_pfn;
-	NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
-}
-
 static void __init do_init_bootmem(void)
 {
 	unsigned long start_pfn, end_pfn;
@@ -222,8 +208,6 @@ static void __init do_init_bootmem(void)
 	for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL)
 		__add_active_range(0, start_pfn, end_pfn);
 
-	/* All of system RAM sits in node 0 for the non-NUMA case */
-	allocate_pgdat(0);
 	node_set_online(0);
 
 	plat_mem_setup();
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/10 sh: remove setup_bootmem_node() and plat_mem_setup()

In reply to Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

setup_bootmem_node() and plat_mem_setup() were needed to setup NUMA "nodes" for URAM memory ranges. Since there is no NUMA support anymore, these functions are not needed.

Remove them.

---
 arch/sh/kernel/cpu/sh4a/setup-sh7366.c |  5 -----
 arch/sh/kernel/cpu/sh4a/setup-sh7722.c |  6 ------
 arch/sh/kernel/cpu/sh4a/setup-sh7757.c |  4 ----
 arch/sh/kernel/cpu/sh4a/setup-sh7785.c |  6 ------
 arch/sh/kernel/cpu/sh4a/setup-sh7786.c |  4 ----
 arch/sh/kernel/cpu/sh4a/setup-shx3.c   | 17 -----------------
 arch/sh/mm/init.c                      |  7 -------
 7 files changed, 49 deletions(-)
arch/sh/kernel/cpu/sh4a/setup-sh7366.c +0 -5
index 6676beef053e..0a4ceb9785f6 100644
@@ -381,8 +381,3 @@ void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
 }
-
-void __init plat_mem_setup(void)
-{
-	/* TODO: Register Node 1 */
-}
arch/sh/kernel/cpu/sh4a/setup-sh7722.c +0 -6
index 0c6757ef63f4..2180819a1455 100644
@@ -658,9 +658,3 @@ void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
 }
-
-void __init plat_mem_setup(void)
-{
-	/* Register the URAM space as Node 1 */
-	setup_bootmem_node(1, 0x055f0000, 0x05610000);
-}
arch/sh/kernel/cpu/sh4a/setup-sh7757.c +0 -4
index 2ad19a0c5e04..1f4396da00e5 100644
@@ -1239,7 +1239,3 @@ void __init plat_irq_setup_pins(int mode)
 		BUG();
 	}
 }
-
-void __init plat_mem_setup(void)
-{
-}
arch/sh/kernel/cpu/sh4a/setup-sh7785.c +0 -6
index 3b4a414d60a9..95c3cc15a443 100644
@@ -600,9 +600,3 @@ void __init plat_irq_setup_pins(int mode)
 		BUG();
 	}
 }
-
-void __init plat_mem_setup(void)
-{
-	/* Register the URAM space as Node 1 */
-	setup_bootmem_node(1, 0xe55f0000, 0xe5610000);
-}
arch/sh/kernel/cpu/sh4a/setup-sh7786.c +0 -4
index c048842d8a58..a46d6c3241a9 100644
@@ -783,10 +783,6 @@ void __init plat_irq_setup_pins(int mode)
 	}
 }
 
-void __init plat_mem_setup(void)
-{
-}
-
 static int __init sh7786_devices_setup(void)
 {
 	int ret, irq;
arch/sh/kernel/cpu/sh4a/setup-shx3.c +0 -17
index 7014d6d199b3..3197ec2a65cd 100644
@@ -377,20 +377,3 @@ void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
 }
-
-void __init plat_mem_setup(void)
-{
-	unsigned int nid = 1;
-
-	/* Register CPU#0 URAM space as Node 1 */
-	setup_bootmem_node(nid++, 0x145f0000, 0x14610000);	/* CPU0 */
-
-#if 0
-	/* XXX: Not yet.. */
-	setup_bootmem_node(nid++, 0x14df0000, 0x14e10000);	/* CPU1 */
-	setup_bootmem_node(nid++, 0x155f0000, 0x15610000);	/* CPU2 */
-	setup_bootmem_node(nid++, 0x15df0000, 0x15e10000);	/* CPU3 */
-#endif
-
-	setup_bootmem_node(nid++, 0x16000000, 0x16020000);	/* CSM */
-}
arch/sh/mm/init.c +0 -7
index 977392b478b3..b34ba42d1e18 100644
@@ -38,11 +38,6 @@ void __init generic_mem_init(void)
 	memblock_add(__MEMORY_START, __MEMORY_SIZE);
 }
 
-void __init __weak plat_mem_setup(void)
-{
-	/* Nothing to see here, move along. */
-}
-
 #ifdef CONFIG_MMU
 static pte_t *__get_pte_phys(unsigned long addr)
 {
@@ -209,8 +204,6 @@ static void __init do_init_bootmem(void)
 		__add_active_range(0, start_pfn, end_pfn);
 
 	node_set_online(0);
-
-	plat_mem_setup();
 }
 
 static void __init early_reserve_mem(void)
Signature · 1 line
2.53.0
#5 lore raw

PATCH 5/10 sh: drop dead code guarded by #ifdef CONFIG_NUMA

In reply to Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

and NUMA-related comments.

---
 arch/sh/include/asm/topology.h | 13 -------------
 arch/sh/kernel/setup.c         |  1 -
 arch/sh/kernel/topology.c      | 12 ------------
 arch/sh/kernel/vmcore_info.c   |  4 ----
 arch/sh/mm/sram.c              |  3 +--
 5 files changed, 1 insertion(+), 32 deletions(-)
arch/sh/include/asm/topology.h +0 -13
index 1db470e02456..a3c31754ba5f 100644
@@ -2,19 +2,6 @@
 #ifndef _ASM_SH_TOPOLOGY_H
 #define _ASM_SH_TOPOLOGY_H
 
-#ifdef CONFIG_NUMA
-
-#define cpu_to_node(cpu)	((void)(cpu),0)
-
-#define cpumask_of_node(node)	((void)node, cpu_online_mask)
-
-#define pcibus_to_node(bus)	((void)(bus), -1)
-#define cpumask_of_pcibus(bus)	(pcibus_to_node(bus) == -1 ? \
-					cpu_all_mask : \
-					cpumask_of_node(pcibus_to_node(bus)))
-
-#endif
-
 #define mc_capable()    (1)
 
 const struct cpumask *cpu_coregroup_mask(int cpu);
arch/sh/kernel/setup.c +0 -1
index 039a51291002..5e25c1db4d61 100644
@@ -227,7 +227,6 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn,
 	/*
 	 * Also make sure that there is a PMB mapping that covers this
 	 * range before we attempt to activate it, to avoid reset by MMU.
-	 * We can hit this path with NUMA or memory hot-add.
 	 */
 	pmb_bolt_mapping((unsigned long)__va(start), start, end - start,
 			 PAGE_KERNEL);
arch/sh/kernel/topology.c +0 -12
index 2d2a7509b565..906b7b1d5443 100644
@@ -57,18 +57,6 @@ static int __init topology_init(void)
 			       __func__, i, ret);
 	}
 
-#if defined(CONFIG_NUMA) && !defined(CONFIG_SMP)
-	/*
-	 * In the UP case, make sure the CPU association is still
-	 * registered under each node. Without this, sysfs fails
-	 * to make the connection between nodes other than node0
-	 * and cpu0.
-	 */
-	for_each_online_node(i)
-		if (i != numa_node_id())
-			register_cpu_under_node(raw_smp_processor_id(), i);
-#endif
-
 	return 0;
 }
 subsys_initcall(topology_init);
arch/sh/kernel/vmcore_info.c +0 -4
index a244a204a1b1..9f029b4a7e63 100644
@@ -5,10 +5,6 @@
 
 void arch_crash_save_vmcoreinfo(void)
 {
-#ifdef CONFIG_NUMA
-	VMCOREINFO_SYMBOL(node_data);
-	VMCOREINFO_LENGTH(node_data, MAX_NUMNODES);
-#endif
 #ifdef CONFIG_X2TLB
 	VMCOREINFO_CONFIG(X2TLB);
 #endif
arch/sh/mm/sram.c +1 -2
index 2d8fa718d55e..208080f072df 100644
@@ -16,8 +16,7 @@
  * This provides a standard SRAM pool for tiny memories that can be
  * added either by the CPU or the platform code. Typical SRAM sizes
  * to be inserted in to the pool will generally be less than the page
- * size, with anything more reasonably sized handled as a NUMA memory
- * node.
+ * size.
  */
 struct gen_pool *sram_pool;
 
Signature · 1 line
2.53.0
#6 lore raw

PATCH 6/10 sh: drop include/asm/mmzone.h

In reply to Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

include/asm/mmzone.h was required for declarations of NUMA related functionality.

The only function declared there that's not related to NUMA is __add_active_range().

Move __add_active_range() declaration to include/asm/setup.h and drop include/asm/mmzone.h

---
 arch/sh/include/asm/mmzone.h           | 42 --------------------------
 arch/sh/include/asm/setup.h            |  3 ++
 arch/sh/kernel/cpu/sh4a/setup-sh7722.c |  1 -
 arch/sh/kernel/cpu/sh4a/setup-sh7723.c |  1 -
 arch/sh/kernel/cpu/sh4a/setup-sh7724.c |  1 -
 arch/sh/kernel/cpu/sh4a/setup-sh7757.c |  1 -
 arch/sh/kernel/cpu/sh4a/setup-sh7785.c |  1 -
 arch/sh/kernel/cpu/sh4a/setup-sh7786.c |  1 -
 arch/sh/kernel/cpu/sh4a/setup-shx3.c   |  1 -
 arch/sh/kernel/setup.c                 |  2 --
 arch/sh/mm/init.c                      |  1 -
 11 files changed, 3 insertions(+), 52 deletions(-)
 delete mode 100644 arch/sh/include/asm/mmzone.h
arch/sh/include/asm/mmzone.h deleted +0 -42
deleted file mode 100644
index 63f88b465e39..000000000000
@@ -1,42 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __ASM_SH_MMZONE_H
-#define __ASM_SH_MMZONE_H
-
-#ifdef CONFIG_NUMA
-#include <linux/numa.h>
-
-static inline int pfn_to_nid(unsigned long pfn)
-{
-	int nid;
-
-	for (nid = 0; nid < MAX_NUMNODES; nid++)
-		if (pfn >= node_start_pfn(nid) && pfn <= node_end_pfn(nid))
-			break;
-
-	return nid;
-}
-
-static inline struct pglist_data *pfn_to_pgdat(unsigned long pfn)
-{
-	return NODE_DATA(pfn_to_nid(pfn));
-}
-
-/* arch/sh/mm/numa.c */
-void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end);
-#else
-static inline void
-setup_bootmem_node(int nid, unsigned long start, unsigned long end)
-{
-}
-#endif /* CONFIG_NUMA */
-
-/* Platform specific mem init */
-void __init plat_mem_setup(void);
-
-/* arch/sh/kernel/setup.c */
-void __init __add_active_range(unsigned int nid, unsigned long start_pfn,
-			       unsigned long end_pfn);
-/* arch/sh/mm/init.c */
-void __init allocate_pgdat(unsigned int nid);
-
-#endif /* __ASM_SH_MMZONE_H */
arch/sh/include/asm/setup.h +3 -0
index 84bb23a771f3..6bd5b0d87abe 100644
@@ -23,4 +23,7 @@ void check_for_initrd(void);
 void per_cpu_trap_init(void);
 void sh_fdt_init(phys_addr_t dt_phys);
 
+void __add_active_range(unsigned int nid, unsigned long start_pfn,
+			unsigned long end_pfn);
+
 #endif /* _SH_SETUP_H */
arch/sh/kernel/cpu/sh4a/setup-sh7722.c +0 -1
index 2180819a1455..5e2c24c518b4 100644
@@ -16,7 +16,6 @@
 #include <linux/usb/m66592.h>
 
 #include <asm/clock.h>
-#include <asm/mmzone.h>
 #include <asm/siu.h>
 #include <asm/platform_early.h>
 
arch/sh/kernel/cpu/sh4a/setup-sh7723.c +0 -1
index d64d28c4f059..5c24ff407c89 100644
@@ -17,7 +17,6 @@
 
 #include <asm/cacheflush.h>
 #include <asm/clock.h>
-#include <asm/mmzone.h>
 #include <asm/platform_early.h>
 
 #include <cpu/sh7723.h>
arch/sh/kernel/cpu/sh4a/setup-sh7724.c +0 -1
index ef4b26a4b3d6..9441e4a0f402 100644
@@ -24,7 +24,6 @@
 #include <asm/cacheflush.h>
 #include <asm/suspend.h>
 #include <asm/clock.h>
-#include <asm/mmzone.h>
 #include <asm/platform_early.h>
 
 #include <cpu/dma-register.h>
arch/sh/kernel/cpu/sh4a/setup-sh7757.c +0 -1
index 1f4396da00e5..3750b598d6bd 100644
@@ -21,7 +21,6 @@
 #include <cpu/dma-register.h>
 #include <cpu/sh7757.h>
 
-#include <asm/mmzone.h>
 #include <asm/platform_early.h>
 
 static struct plat_sci_port scif2_platform_data = {
arch/sh/kernel/cpu/sh4a/setup-sh7785.c +0 -1
index 95c3cc15a443..13f08c44fb02 100644
@@ -13,7 +13,6 @@
 #include <linux/sh_dma.h>
 #include <linux/sh_timer.h>
 #include <linux/sh_intc.h>
-#include <asm/mmzone.h>
 #include <asm/platform_early.h>
 #include <cpu/dma-register.h>
 
arch/sh/kernel/cpu/sh4a/setup-sh7786.c +0 -1
index a46d6c3241a9..79484c598b83 100644
@@ -22,7 +22,6 @@
 #include <linux/sh_intc.h>
 #include <linux/usb/ohci_pdriver.h>
 #include <cpu/dma-register.h>
-#include <asm/mmzone.h>
 #include <asm/platform_early.h>
 
 static struct plat_sci_port scif0_platform_data = {
arch/sh/kernel/cpu/sh4a/setup-shx3.c +0 -1
index 3197ec2a65cd..93cdd1ee888d 100644
@@ -13,7 +13,6 @@
 #include <linux/sh_timer.h>
 #include <linux/sh_intc.h>
 #include <cpu/shx3.h>
-#include <asm/mmzone.h>
 #include <asm/platform_early.h>
 
 /*
arch/sh/kernel/setup.c +0 -2
index 5e25c1db4d61..2f2764061003 100644
@@ -23,7 +23,6 @@
 #include <linux/smp.h>
 #include <linux/err.h>
 #include <linux/crash_dump.h>
-#include <linux/mmzone.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
@@ -41,7 +40,6 @@
 #include <asm/clock.h>
 #include <asm/smp.h>
 #include <asm/mmu_context.h>
-#include <asm/mmzone.h>
 #include <asm/processor.h>
 #include <asm/sparsemem.h>
 #include <asm/platform_early.h>
arch/sh/mm/init.c +0 -1
index b34ba42d1e18..31a9676efbe3 100644
@@ -20,7 +20,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/export.h>
 #include <asm/mmu_context.h>
-#include <asm/mmzone.h>
 #include <asm/kexec.h>
 #include <asm/tlb.h>
 #include <asm/cacheflush.h>
Signature · 1 line
2.53.0
#7 lore raw

PATCH 7/10 init/Kconfig: drop ARCH_WANT_NUMA_VARIABLE_LOCALITY

In reply to Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

sh was the only architecture that selected ARCH_WANT_NUMA_VARIABLE_LOCALITY.

With NUMA support on sh gone, there is no need in this configuration option.

Remove it.

---
 init/Kconfig | 7 -------
 1 file changed, 7 deletions(-)
init/Kconfig +0 -7
index 7484cd703bc1..c31fb292729f 100644
@@ -987,16 +987,9 @@ config CC_STRINGOP_OVERFLOW
 config ARCH_SUPPORTS_INT128
 	bool
 
-# For architectures that (ab)use NUMA to represent different memory regions
-# all cpu-local but of different latencies, such as SuperH.
-#
-config ARCH_WANT_NUMA_VARIABLE_LOCALITY
-	bool
-
 config NUMA_BALANCING
 	bool "Memory placement aware NUMA scheduler"
 	depends on ARCH_SUPPORTS_NUMA_BALANCING
-	depends on !ARCH_WANT_NUMA_VARIABLE_LOCALITY
 	depends on SMP && NUMA && MIGRATION && !PREEMPT_RT
 	help
 	  This option adds support for automatic NUMA aware memory/task placement.
Signature · 1 line
2.53.0
#8 lore raw

PATCH 8/10 sh: init: remove call the memblock_set_node()

In reply to Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

Without CONFIG_NUMA, the call to memblock_set_node() is not needed.

Remove it.

---
 arch/sh/kernel/setup.c | 3 ---
 1 file changed, 3 deletions(-)
arch/sh/kernel/setup.c +0 -3
index 2f2764061003..43d0f7b62b03 100644
@@ -228,9 +228,6 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn,
 	 */
 	pmb_bolt_mapping((unsigned long)__va(start), start, end - start,
 			 PAGE_KERNEL);
-
-	memblock_set_node(PFN_PHYS(start_pfn), PFN_PHYS(end_pfn - start_pfn),
-			  &memblock.memory, nid);
 }
 
 void __init __weak plat_early_device_setup(void)
Signature · 1 line
2.53.0
#9 lore raw

PATCH 9/10 sh: remove SPARSEMEM related entries from Kconfig

In reply to Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

Without NUMA support, SPARSEMEM related configuration options only create unnecessary overhead.

Remove them.

---
 arch/sh/Kconfig    |  8 --------
 arch/sh/mm/Kconfig | 10 ----------
 2 files changed, 18 deletions(-)
arch/sh/Kconfig +0 -8
index d5795067befa..29d55f12ad50 100644
@@ -390,7 +390,6 @@ config CPU_SUBTYPE_SH7723
 	select CPU_SH4A
 	select CPU_SHX2
 	select ARCH_SHMOBILE
-	select ARCH_SPARSEMEM_ENABLE
 	select SYS_SUPPORTS_SH_CMT
 	select PINCTRL
 	help
@@ -401,7 +400,6 @@ config CPU_SUBTYPE_SH7724
 	select CPU_SH4A
 	select CPU_SHX2
 	select ARCH_SHMOBILE
-	select ARCH_SPARSEMEM_ENABLE
 	select SYS_SUPPORTS_SH_CMT
 	select PINCTRL
 	help
@@ -442,8 +440,6 @@ config CPU_SUBTYPE_SH7785
 	bool "Support SH7785 processor"
 	select CPU_SH4A
 	select CPU_SHX2
-	select ARCH_SPARSEMEM_ENABLE
-	select SYS_SUPPORTS_NUMA
 	select PINCTRL
 
 config CPU_SUBTYPE_SH7786
@@ -477,8 +473,6 @@ config CPU_SUBTYPE_SH7722
 	select CPU_SH4AL_DSP
 	select CPU_SHX2
 	select ARCH_SHMOBILE
-	select ARCH_SPARSEMEM_ENABLE
-	select SYS_SUPPORTS_NUMA
 	select SYS_SUPPORTS_SH_CMT
 	select PINCTRL
 
@@ -487,8 +481,6 @@ config CPU_SUBTYPE_SH7366
 	select CPU_SH4AL_DSP
 	select CPU_SHX2
 	select ARCH_SHMOBILE
-	select ARCH_SPARSEMEM_ENABLE
-	select SYS_SUPPORTS_NUMA
 	select SYS_SUPPORTS_SH_CMT
 
 endchoice
arch/sh/mm/Kconfig +0 -10
index 71fecbbb080e..c7d889a1a9d7 100644
@@ -115,16 +115,6 @@ config VSYSCALL
 config ARCH_FLATMEM_ENABLE
 	def_bool y
 
-config ARCH_SPARSEMEM_ENABLE
-	def_bool y
-	select SPARSEMEM_STATIC
-
-config ARCH_SPARSEMEM_DEFAULT
-	def_bool y
-
-config ARCH_SELECT_MEMORY_MODEL
-	def_bool y
-
 config IOREMAP_FIXED
        def_bool y
        depends on X2TLB
Signature · 1 line
2.53.0
#10 lore raw

PATCH 10/10 sh: drop include/asm/sparsemem.h

In reply to Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

Move MAX_PHYSMEM_BITS declaration to include/asm/mmu.h and drop now unneeded include/asm/sparsemem.h

---
 arch/sh/include/asm/mmu.h       |  2 ++
 arch/sh/include/asm/sparsemem.h | 12 ------------
 arch/sh/kernel/setup.c          |  1 -
 3 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 arch/sh/include/asm/sparsemem.h
arch/sh/include/asm/mmu.h +2 -0
index b9c9f91e6616..def7c1edd605 100644
@@ -2,6 +2,8 @@
 #ifndef __MMU_H
 #define __MMU_H
 
+#define MAX_PHYSMEM_BITS	32
+
 /*
  * Privileged Space Mapping Buffer (PMB) definitions
  */
arch/sh/include/asm/sparsemem.h deleted +0 -12
deleted file mode 100644
index 4703cbe23844..000000000000
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __ASM_SH_SPARSEMEM_H
-#define __ASM_SH_SPARSEMEM_H
-
-/*
- * SECTION_SIZE_BITS		2^N: how big each section will be
- * MAX_PHYSMEM_BITS		2^N: how much physical address space we have
- */
-#define SECTION_SIZE_BITS	26
-#define MAX_PHYSMEM_BITS	32
-
-#endif /* __ASM_SH_SPARSEMEM_H */
arch/sh/kernel/setup.c +0 -1
index 43d0f7b62b03..99f52d888aa3 100644
@@ -41,7 +41,6 @@
 #include <asm/smp.h>
 #include <asm/mmu_context.h>
 #include <asm/processor.h>
-#include <asm/sparsemem.h>
 #include <asm/platform_early.h>
 
 /*
Signature · 1 line
2.53.0
#11 lore raw
In reply to Mike Rapoport

Hi Mike,

Quoted 20 lines · Mike Rapoport

NUMA support for SuperH was introduced a long time ago by commit b241cb0c885e ("sh: Support for multiple nodes.")

"... for boards with many different memory blocks that are
otherwise unused (SH7722/SH7785 URAM and so forth)"

In reality, this added 128K of memory on sh7722 and sh7785 and 256K on shx3 at the expense of all the NUMA related code in the kernel.

For build of v7.0-rc7 with defconfig and the same configuration with CONFIG_NUMA disabled, bloat-o-meter reports difference of ~76k. Disabling CONFIG_SPARSMEM on top increases the difference to ~94k. And that's only overhead in code and static data that does not take into the account data structures allocated at run time.

And all this overhead has been there for nothing for almost 8 years because since commit ac21fc2dcb40 ("sh: switch to NO_BOOTMEM") those additional "nodes" could not be used by the core MM because the maximal pfn for ZONE_NORMAL was cut out at the end of the normal memory.

Quoted 11 lines

Mike Rapoport (Microsoft) (10):
sh: remove CONFIG_NUMA and realted configuration options
sh: mm: remove numa.c
sh: mm: drop allocate_pgdat()
sh: remove setup_bootmem_node() and plat_mem_setup()
sh: drop dead code guarded by #ifdef CONFIG_NUMA
sh: drop include/asm/mmzone.h
init/Kconfig: drop ARCH_WANT_NUMA_VARIABLE_LOCALITY
sh: init: remove call the memblock_set_node()
sh: remove SPARSEMEM related entries from Kconfig
sh: drop include/asm/sparsemem.h

Thanks a lot for the series. It will take me some time to review and I expect it to be taken for v7.2. FWIW, I actually own several boards using the SH-7785LCR CPU and I issues booting kernels newer than 6.5 on these so I'm wondering whether this broken feature might be to blame?

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#12 lore raw

Hi Adrian,

Quoted 35 lines · John Paul Adrian Glaubitz

Hi Mike,

Quoted 20 lines · Mike Rapoport

NUMA support for SuperH was introduced a long time ago by commit b241cb0c885e ("sh: Support for multiple nodes.")

"... for boards with many different memory blocks that are
otherwise unused (SH7722/SH7785 URAM and so forth)"

In reality, this added 128K of memory on sh7722 and sh7785 and 256K on shx3 at the expense of all the NUMA related code in the kernel.

For build of v7.0-rc7 with defconfig and the same configuration with CONFIG_NUMA disabled, bloat-o-meter reports difference of ~76k. Disabling CONFIG_SPARSMEM on top increases the difference to ~94k. And that's only overhead in code and static data that does not take into the account data structures allocated at run time.

And all this overhead has been there for nothing for almost 8 years because since commit ac21fc2dcb40 ("sh: switch to NO_BOOTMEM") those additional "nodes" could not be used by the core MM because the maximal pfn for ZONE_NORMAL was cut out at the end of the normal memory.

Quoted 11 lines

Mike Rapoport (Microsoft) (10):
sh: remove CONFIG_NUMA and realted configuration options
sh: mm: remove numa.c
sh: mm: drop allocate_pgdat()
sh: remove setup_bootmem_node() and plat_mem_setup()
sh: drop dead code guarded by #ifdef CONFIG_NUMA
sh: drop include/asm/mmzone.h
init/Kconfig: drop ARCH_WANT_NUMA_VARIABLE_LOCALITY
sh: init: remove call the memblock_set_node()
sh: remove SPARSEMEM related entries from Kconfig
sh: drop include/asm/sparsemem.h

Quoted 2 lines

Thanks a lot for the series. It will take me some time to review and I expect it to be taken for v7.2.

Yes, this for v7.2.

Quoted 3 lines

FWIW, I actually own several boards using the SH-7785LCR CPU and I issues booting kernels newer than 6.5 on these so I'm wondering whether this broken feature might be to blame?

If 6.5 boots successfully, I don't think this is related.

Quoted 1 line

Adrian

Signature · 2 lines
Sincerely yours,
Mike.
Reviewed-by on the v1 series
#13 lore raw
In reply to Mike Rapoport
Quoted 16 lines · Mike Rapoport

NUMA support for SuperH was introduced a long time ago by commit b241cb0c885e ("sh: Support for multiple nodes.")

"... for boards with many different memory blocks that are
otherwise unused (SH7722/SH7785 URAM and so forth)"

In reality, this added 128K of memory on sh7722 and sh7785 and 256K on shx3 at the expense of all the NUMA related code in the kernel.

For build of v7.0-rc7 with defconfig and the same configuration with CONFIG_NUMA disabled, bloat-o-meter reports difference of ~76k. Disabling CONFIG_SPARSMEM on top increases the difference to ~94k. And that's only overhead in code and static data that does not take into the account data structures allocated at run time.

Quoted 4 lines

And all this overhead has been there for nothing for almost 8 years because since commit ac21fc2dcb40 ("sh: switch to NO_BOOTMEM") those additional "nodes" could not be used by the core MM because the maximal pfn for ZONE_NORMAL was cut out at the end of the normal memory.

I had looked at it when you asked me about it last year, and I can confirm that agree with all your findings and the resulting patches.

Whole series

Two very minor points:

* It looks like you left the 'config SYS_SUPPORTS_NUMA' symbol in Kconfig, which no longer does anything, so this should probably be removed in patch 9 along with the lines that select it.

* It appears that after your series, RISC-V is the only remaining architecture that supports NUMA in 32-bit mode, which I think we should not allow as a configuration, given that this would run into untested code and no hardware exists for it. Apparently commit 4f0e8eef772e ("riscv: Add numa support for riscv64 platform") intended this to only be for 64-bit targets but did not add a Kconfig dependency for CONFIG_64BIT (or CONFIG_SMP, which was added later).

Arnd

#14 lore raw

(oops, missed that earlier)

Quoted 22 lines · Arnd Bergmann
Quoted 16 lines · Mike Rapoport

NUMA support for SuperH was introduced a long time ago by commit b241cb0c885e ("sh: Support for multiple nodes.")

"... for boards with many different memory blocks that are
otherwise unused (SH7722/SH7785 URAM and so forth)"

In reality, this added 128K of memory on sh7722 and sh7785 and 256K on shx3 at the expense of all the NUMA related code in the kernel.

For build of v7.0-rc7 with defconfig and the same configuration with CONFIG_NUMA disabled, bloat-o-meter reports difference of ~76k. Disabling CONFIG_SPARSMEM on top increases the difference to ~94k. And that's only overhead in code and static data that does not take into the account data structures allocated at run time.

Quoted 4 lines

And all this overhead has been there for nothing for almost 8 years because since commit ac21fc2dcb40 ("sh: switch to NO_BOOTMEM") those additional "nodes" could not be used by the core MM because the maximal pfn for ZONE_NORMAL was cut out at the end of the normal memory.

Quoted 6 lines

I had looked at it when you asked me about it last year, and I can confirm that agree with all your findings and the resulting patches.

Whole series

Thanks!

Quoted 5 lines

Two very minor points:

* It looks like you left the 'config SYS_SUPPORTS_NUMA' symbol in Kconfig, which no longer does anything, so this should probably be removed in patch 9 along with the lines that select it.

I think it better fits patch 1 that removes CONFIG_NUMA, patch 9 is about SPARSEMEM.

Quoted 8 lines

* It appears that after your series, RISC-V is the only remaining architecture that supports NUMA in 32-bit mode, which I think we should not allow as a configuration, given that this would run into untested code and no hardware exists for it. Apparently commit 4f0e8eef772e ("riscv: Add numa support for riscv64 platform") intended this to only be for 64-bit targets but did not add a Kconfig dependency for CONFIG_64BIT (or CONFIG_SMP, which was added later).

I can send a patch to RISC-V for it.

Quoted 1 line

Arnd

Signature · 2 lines
Sincerely yours,
Mike.