LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v1 0/6] mm/memory_hotplug: Kconfig and 32 bit cleanups
@ 2021-09-29 14:35 David Hildenbrand
  2021-09-29 14:35 ` [PATCH v1 1/6] mm/memory_hotplug: remove CONFIG_X86_64_ACPI_NUMA dependency from CONFIG_MEMORY_HOTPLUG David Hildenbrand
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: David Hildenbrand @ 2021-09-29 14:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Hildenbrand, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Oscar Salvador, Mike Rapoport, x86, linux-mm,
	linux-kselftest, linux-doc, linuxppc-dev, virtualization

Some cleanups around CONFIG_MEMORY_HOTPLUG, including removing 32 bit
leftovers of memory hotplug support.

Compile-tested on various architectures, quickly tested memory hotplug
on x86-64.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Alex Shi <alexs@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: x86@kernel.org
Cc: linux-mm@kvack.org
Cc: linux-kselftest@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: virtualization@lists.linux-foundation.org

David Hildenbrand (6):
  mm/memory_hotplug: remove CONFIG_X86_64_ACPI_NUMA dependency from
    CONFIG_MEMORY_HOTPLUG
  mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE
  mm/memory_hotplug: restrict CONFIG_MEMORY_HOTPLUG to 64 bit
  mm/memory_hotplug: remove HIGHMEM leftovers
  mm/memory_hotplug: remove stale function declarations
  x86: remove memory hotplug support on X86_32

 Documentation/core-api/memory-hotplug.rst     |  3 --
 .../zh_CN/core-api/memory-hotplug.rst         |  4 --
 arch/powerpc/include/asm/machdep.h            |  2 +-
 arch/powerpc/kernel/setup_64.c                |  2 +-
 arch/powerpc/platforms/powernv/setup.c        |  4 +-
 arch/powerpc/platforms/pseries/setup.c        |  2 +-
 arch/x86/Kconfig                              |  6 +--
 arch/x86/mm/init_32.c                         | 31 ---------------
 drivers/base/Makefile                         |  2 +-
 drivers/base/node.c                           |  9 ++---
 drivers/virtio/Kconfig                        |  2 +-
 include/linux/memory.h                        | 19 ++++------
 include/linux/memory_hotplug.h                |  3 --
 include/linux/node.h                          |  4 +-
 lib/Kconfig.debug                             |  2 +-
 mm/Kconfig                                    |  8 +---
 mm/memory_hotplug.c                           | 38 +------------------
 tools/testing/selftests/memory-hotplug/config |  1 -
 18 files changed, 28 insertions(+), 114 deletions(-)


base-commit: 5816b3e6577eaa676ceb00a848f0fd65fe2adc29
-- 
2.31.1


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

* [PATCH v1 1/6] mm/memory_hotplug: remove CONFIG_X86_64_ACPI_NUMA dependency from CONFIG_MEMORY_HOTPLUG
  2021-09-29 14:35 [PATCH v1 0/6] mm/memory_hotplug: Kconfig and 32 bit cleanups David Hildenbrand
@ 2021-09-29 14:35 ` David Hildenbrand
  2021-10-07  8:09   ` Oscar Salvador
  2021-09-29 14:35 ` [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE David Hildenbrand
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: David Hildenbrand @ 2021-09-29 14:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Hildenbrand, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Oscar Salvador, Mike Rapoport, x86, linux-mm,
	linux-kselftest, linux-doc, linuxppc-dev, virtualization

SPARSEMEM is the only possible memory model for x86-64, FLATMEM is not
possible:
	config ARCH_FLATMEM_ENABLE
		def_bool y
		depends on X86_32 && !NUMA

And X86_64_ACPI_NUMA (obviously) only supports x86-64:
	config X86_64_ACPI_NUMA
		def_bool y
		depends on X86_64 && NUMA && ACPI && PCI

Let's just remove the CONFIG_X86_64_ACPI_NUMA dependency, as it does no
longer make sense.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 mm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index d16ba9249bc5..b7fb3f0b485e 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -123,7 +123,7 @@ config ARCH_ENABLE_MEMORY_HOTPLUG
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
 	select MEMORY_ISOLATION
-	depends on SPARSEMEM || X86_64_ACPI_NUMA
+	depends on SPARSEMEM
 	depends on ARCH_ENABLE_MEMORY_HOTPLUG
 	depends on 64BIT || BROKEN
 	select NUMA_KEEP_MEMINFO if NUMA
-- 
2.31.1


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

* [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE
  2021-09-29 14:35 [PATCH v1 0/6] mm/memory_hotplug: Kconfig and 32 bit cleanups David Hildenbrand
  2021-09-29 14:35 ` [PATCH v1 1/6] mm/memory_hotplug: remove CONFIG_X86_64_ACPI_NUMA dependency from CONFIG_MEMORY_HOTPLUG David Hildenbrand
@ 2021-09-29 14:35 ` David Hildenbrand
  2021-10-05 13:43   ` Greg Kroah-Hartman
                     ` (2 more replies)
  2021-09-29 14:35 ` [PATCH v1 3/6] mm/memory_hotplug: restrict CONFIG_MEMORY_HOTPLUG to 64 bit David Hildenbrand
                   ` (3 subsequent siblings)
  5 siblings, 3 replies; 16+ messages in thread
From: David Hildenbrand @ 2021-09-29 14:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Hildenbrand, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Oscar Salvador, Mike Rapoport, x86, linux-mm,
	linux-kselftest, linux-doc, linuxppc-dev, virtualization

CONFIG_MEMORY_HOTPLUG depends on CONFIG_SPARSEMEM, so there is no need for
CONFIG_MEMORY_HOTPLUG_SPARSE anymore; adjust all instances to use
CONFIG_MEMORY_HOTPLUG and remove CONFIG_MEMORY_HOTPLUG_SPARSE.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 arch/powerpc/include/asm/machdep.h            |  2 +-
 arch/powerpc/kernel/setup_64.c                |  2 +-
 arch/powerpc/platforms/powernv/setup.c        |  4 ++--
 arch/powerpc/platforms/pseries/setup.c        |  2 +-
 drivers/base/Makefile                         |  2 +-
 drivers/base/node.c                           |  9 ++++-----
 drivers/virtio/Kconfig                        |  2 +-
 include/linux/memory.h                        | 18 +++++++-----------
 include/linux/node.h                          |  4 ++--
 lib/Kconfig.debug                             |  2 +-
 mm/Kconfig                                    |  4 ----
 mm/memory_hotplug.c                           |  2 --
 tools/testing/selftests/memory-hotplug/config |  1 -
 13 files changed, 21 insertions(+), 33 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 764f2732a821..d8a2ca007082 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -32,7 +32,7 @@ struct machdep_calls {
 	void		(*iommu_save)(void);
 	void		(*iommu_restore)(void);
 #endif
-#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+#ifdef CONFIG_MEMORY_HOTPLUG
 	unsigned long	(*memory_block_size)(void);
 #endif
 #endif /* CONFIG_PPC64 */
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index eaa79a0996d1..21f15d82f062 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -912,7 +912,7 @@ void __init setup_per_cpu_areas(void)
 }
 #endif
 
-#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+#ifdef CONFIG_MEMORY_HOTPLUG
 unsigned long memory_block_size_bytes(void)
 {
 	if (ppc_md.memory_block_size)
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index a8db3f153063..ad56a54ac9c5 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -440,7 +440,7 @@ static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
 }
 #endif /* CONFIG_KEXEC_CORE */
 
-#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+#ifdef CONFIG_MEMORY_HOTPLUG
 static unsigned long pnv_memory_block_size(void)
 {
 	/*
@@ -553,7 +553,7 @@ define_machine(powernv) {
 #ifdef CONFIG_KEXEC_CORE
 	.kexec_cpu_down		= pnv_kexec_cpu_down,
 #endif
-#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+#ifdef CONFIG_MEMORY_HOTPLUG
 	.memory_block_size	= pnv_memory_block_size,
 #endif
 };
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index f79126f16258..d29f6f1f7f37 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -1089,7 +1089,7 @@ define_machine(pseries) {
 	.machine_kexec          = pSeries_machine_kexec,
 	.kexec_cpu_down         = pseries_kexec_cpu_down,
 #endif
-#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+#ifdef CONFIG_MEMORY_HOTPLUG
 	.memory_block_size	= pseries_memory_block_size,
 #endif
 };
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index ef8e44a7d288..02f7f1358e86 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -13,7 +13,7 @@ obj-y			+= power/
 obj-$(CONFIG_ISA_BUS_API)	+= isa.o
 obj-y				+= firmware_loader/
 obj-$(CONFIG_NUMA)	+= node.o
-obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o
+obj-$(CONFIG_MEMORY_HOTPLUG) += memory.o
 ifeq ($(CONFIG_SYSFS),y)
 obj-$(CONFIG_MODULES)	+= module.o
 endif
diff --git a/drivers/base/node.c b/drivers/base/node.c
index c56d34f8158f..b5a4ba18f9f9 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -629,7 +629,7 @@ static void node_device_release(struct device *dev)
 {
 	struct node *node = to_node(dev);
 
-#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
+#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_HUGETLBFS)
 	/*
 	 * We schedule the work only when a memory section is
 	 * onlined/offlined on this node. When we come here,
@@ -782,7 +782,7 @@ int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
 	return 0;
 }
 
-#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+#ifdef CONFIG_MEMORY_HOTPLUG
 static int __ref get_nid_for_pfn(unsigned long pfn)
 {
 #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
@@ -958,10 +958,9 @@ static int node_memory_callback(struct notifier_block *self,
 	return NOTIFY_OK;
 }
 #endif	/* CONFIG_HUGETLBFS */
-#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
+#endif /* CONFIG_MEMORY_HOTPLUG */
 
-#if !defined(CONFIG_MEMORY_HOTPLUG_SPARSE) || \
-    !defined(CONFIG_HUGETLBFS)
+#if !defined(CONFIG_MEMORY_HOTPLUG) || !defined(CONFIG_HUGETLBFS)
 static inline int node_memory_callback(struct notifier_block *self,
 				unsigned long action, void *arg)
 {
diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index ce1b3f6ec325..3654def9915c 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -98,7 +98,7 @@ config VIRTIO_MEM
 	default m
 	depends on X86_64
 	depends on VIRTIO
-	depends on MEMORY_HOTPLUG_SPARSE
+	depends on MEMORY_HOTPLUG
 	depends on MEMORY_HOTREMOVE
 	depends on CONTIG_ALLOC
 	help
diff --git a/include/linux/memory.h b/include/linux/memory.h
index 7efc0a7c14c9..dd6e608c3e0b 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -110,7 +110,7 @@ struct mem_section;
 #define SLAB_CALLBACK_PRI       1
 #define IPC_CALLBACK_PRI        10
 
-#ifndef CONFIG_MEMORY_HOTPLUG_SPARSE
+#ifndef CONFIG_MEMORY_HOTPLUG
 static inline void memory_dev_init(void)
 {
 	return;
@@ -126,7 +126,11 @@ static inline int memory_notify(unsigned long val, void *v)
 {
 	return 0;
 }
-#else
+#define hotplug_memory_notifier(fn, pri)	({ 0; })
+/* These aren't inline functions due to a GCC bug. */
+#define register_hotmemory_notifier(nb)    ({ (void)(nb); 0; })
+#define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })
+#else /* CONFIG_MEMORY_HOTPLUG */
 extern int register_memory_notifier(struct notifier_block *nb);
 extern void unregister_memory_notifier(struct notifier_block *nb);
 int create_memory_block_devices(unsigned long start, unsigned long size,
@@ -149,9 +153,6 @@ struct memory_group *memory_group_find_by_id(int mgid);
 typedef int (*walk_memory_groups_func_t)(struct memory_group *, void *);
 int walk_dynamic_memory_groups(int nid, walk_memory_groups_func_t func,
 			       struct memory_group *excluded, void *arg);
-#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
-
-#ifdef CONFIG_MEMORY_HOTPLUG
 #define hotplug_memory_notifier(fn, pri) ({		\
 	static __meminitdata struct notifier_block fn##_mem_nb =\
 		{ .notifier_call = fn, .priority = pri };\
@@ -159,12 +160,7 @@ int walk_dynamic_memory_groups(int nid, walk_memory_groups_func_t func,
 })
 #define register_hotmemory_notifier(nb)		register_memory_notifier(nb)
 #define unregister_hotmemory_notifier(nb) 	unregister_memory_notifier(nb)
-#else
-#define hotplug_memory_notifier(fn, pri)	({ 0; })
-/* These aren't inline functions due to a GCC bug. */
-#define register_hotmemory_notifier(nb)    ({ (void)(nb); 0; })
-#define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })
-#endif
+#endif /* CONFIG_MEMORY_HOTPLUG */
 
 /*
  * Kernel text modification mutex, used for code patching. Users of this lock
diff --git a/include/linux/node.h b/include/linux/node.h
index 8e5a29897936..bb21fd631b16 100644
--- a/include/linux/node.h
+++ b/include/linux/node.h
@@ -85,7 +85,7 @@ struct node {
 	struct device	dev;
 	struct list_head access_list;
 
-#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
+#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_HUGETLBFS)
 	struct work_struct	node_work;
 #endif
 #ifdef CONFIG_HMEM_REPORTING
@@ -98,7 +98,7 @@ struct memory_block;
 extern struct node *node_devices[];
 typedef  void (*node_registration_func_t)(struct node *);
 
-#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
+#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_NUMA)
 void link_mem_sections(int nid, unsigned long start_pfn,
 		       unsigned long end_pfn,
 		       enum meminit_context context);
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2a9b6dcdac4f..669fee1d26b8 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -877,7 +877,7 @@ config DEBUG_MEMORY_INIT
 
 config MEMORY_NOTIFIER_ERROR_INJECT
 	tristate "Memory hotplug notifier error injection module"
-	depends on MEMORY_HOTPLUG_SPARSE && NOTIFIER_ERROR_INJECTION
+	depends on MEMORY_HOTPLUG && NOTIFIER_ERROR_INJECTION
 	help
 	  This option provides the ability to inject artificial errors to
 	  memory hotplug notifier chain callbacks.  It is controlled through
diff --git a/mm/Kconfig b/mm/Kconfig
index b7fb3f0b485e..ea8762cd8e1e 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -128,10 +128,6 @@ config MEMORY_HOTPLUG
 	depends on 64BIT || BROKEN
 	select NUMA_KEEP_MEMINFO if NUMA
 
-config MEMORY_HOTPLUG_SPARSE
-	def_bool y
-	depends on SPARSEMEM && MEMORY_HOTPLUG
-
 config MEMORY_HOTPLUG_DEFAULT_ONLINE
 	bool "Online the newly added memory blocks by default"
 	depends on MEMORY_HOTPLUG
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 9fd0be32a281..8d7b2b593a26 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -220,7 +220,6 @@ static void release_memory_resource(struct resource *res)
 	kfree(res);
 }
 
-#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
 static int check_pfn_span(unsigned long pfn, unsigned long nr_pages,
 		const char *reason)
 {
@@ -1163,7 +1162,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
 	mem_hotplug_done();
 	return ret;
 }
-#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
 
 static void reset_node_present_pages(pg_data_t *pgdat)
 {
diff --git a/tools/testing/selftests/memory-hotplug/config b/tools/testing/selftests/memory-hotplug/config
index a7e8cd5bb265..1eef042a31e1 100644
--- a/tools/testing/selftests/memory-hotplug/config
+++ b/tools/testing/selftests/memory-hotplug/config
@@ -1,5 +1,4 @@
 CONFIG_MEMORY_HOTPLUG=y
-CONFIG_MEMORY_HOTPLUG_SPARSE=y
 CONFIG_NOTIFIER_ERROR_INJECTION=y
 CONFIG_MEMORY_NOTIFIER_ERROR_INJECT=m
 CONFIG_MEMORY_HOTREMOVE=y
-- 
2.31.1


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

* [PATCH v1 3/6] mm/memory_hotplug: restrict CONFIG_MEMORY_HOTPLUG to 64 bit
  2021-09-29 14:35 [PATCH v1 0/6] mm/memory_hotplug: Kconfig and 32 bit cleanups David Hildenbrand
  2021-09-29 14:35 ` [PATCH v1 1/6] mm/memory_hotplug: remove CONFIG_X86_64_ACPI_NUMA dependency from CONFIG_MEMORY_HOTPLUG David Hildenbrand
  2021-09-29 14:35 ` [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE David Hildenbrand
@ 2021-09-29 14:35 ` David Hildenbrand
  2021-10-07  9:02   ` Oscar Salvador
  2021-09-29 14:35 ` [PATCH v1 4/6] mm/memory_hotplug: remove HIGHMEM leftovers David Hildenbrand
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: David Hildenbrand @ 2021-09-29 14:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Hildenbrand, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Oscar Salvador, Mike Rapoport, x86, linux-mm,
	linux-kselftest, linux-doc, linuxppc-dev, virtualization

32 bit support is broken in various ways: for example, we can online
memory that should actually go to ZONE_HIGHMEM to ZONE_MOVABLE or in
some cases even to one of the other kernel zones.

We marked it BROKEN in commit b59d02ed0869 ("mm/memory_hotplug: disable the
functionality for 32b") almost one year ago. According to that commit
it might be broken at least since 2017. Further, there is hardly a sane use
case nowadays.

Let's just depend completely on 64bit, dropping the "BROKEN" dependency to
make clear that we are not going to support it again. Next, we'll remove
some HIGHMEM leftovers from memory hotplug code to clean up.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 mm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index ea8762cd8e1e..88273dd5c6d6 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -125,7 +125,7 @@ config MEMORY_HOTPLUG
 	select MEMORY_ISOLATION
 	depends on SPARSEMEM
 	depends on ARCH_ENABLE_MEMORY_HOTPLUG
-	depends on 64BIT || BROKEN
+	depends on 64BIT
 	select NUMA_KEEP_MEMINFO if NUMA
 
 config MEMORY_HOTPLUG_DEFAULT_ONLINE
-- 
2.31.1


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

* [PATCH v1 4/6] mm/memory_hotplug: remove HIGHMEM leftovers
  2021-09-29 14:35 [PATCH v1 0/6] mm/memory_hotplug: Kconfig and 32 bit cleanups David Hildenbrand
                   ` (2 preceding siblings ...)
  2021-09-29 14:35 ` [PATCH v1 3/6] mm/memory_hotplug: restrict CONFIG_MEMORY_HOTPLUG to 64 bit David Hildenbrand
@ 2021-09-29 14:35 ` David Hildenbrand
  2021-10-07  9:13   ` Oscar Salvador
  2021-09-29 14:35 ` [PATCH v1 5/6] mm/memory_hotplug: remove stale function declarations David Hildenbrand
  2021-09-29 14:36 ` [PATCH v1 6/6] x86: remove memory hotplug support on X86_32 David Hildenbrand
  5 siblings, 1 reply; 16+ messages in thread
From: David Hildenbrand @ 2021-09-29 14:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Hildenbrand, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Oscar Salvador, Mike Rapoport, x86, linux-mm,
	linux-kselftest, linux-doc, linuxppc-dev, virtualization

We don't support CONFIG_MEMORY_HOTPLUG on 32 bit and consequently not
HIGHMEM. Let's remove any leftover code -- including the unused
"status_change_nid_high" field part of the memory notifier.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 Documentation/core-api/memory-hotplug.rst     |  3 --
 .../zh_CN/core-api/memory-hotplug.rst         |  4 ---
 include/linux/memory.h                        |  1 -
 mm/memory_hotplug.c                           | 36 ++-----------------
 4 files changed, 2 insertions(+), 42 deletions(-)

diff --git a/Documentation/core-api/memory-hotplug.rst b/Documentation/core-api/memory-hotplug.rst
index de7467e48067..682259ee633a 100644
--- a/Documentation/core-api/memory-hotplug.rst
+++ b/Documentation/core-api/memory-hotplug.rst
@@ -57,7 +57,6 @@ The third argument (arg) passes a pointer of struct memory_notify::
 		unsigned long start_pfn;
 		unsigned long nr_pages;
 		int status_change_nid_normal;
-		int status_change_nid_high;
 		int status_change_nid;
 	}
 
@@ -65,8 +64,6 @@ The third argument (arg) passes a pointer of struct memory_notify::
 - nr_pages is # of pages of online/offline memory.
 - status_change_nid_normal is set node id when N_NORMAL_MEMORY of nodemask
   is (will be) set/clear, if this is -1, then nodemask status is not changed.
-- status_change_nid_high is set node id when N_HIGH_MEMORY of nodemask
-  is (will be) set/clear, if this is -1, then nodemask status is not changed.
 - status_change_nid is set node id when N_MEMORY of nodemask is (will be)
   set/clear. It means a new(memoryless) node gets new memory by online and a
   node loses all memory. If this is -1, then nodemask status is not changed.
diff --git a/Documentation/translations/zh_CN/core-api/memory-hotplug.rst b/Documentation/translations/zh_CN/core-api/memory-hotplug.rst
index 161f4d2c18cc..9a204eb196f2 100644
--- a/Documentation/translations/zh_CN/core-api/memory-hotplug.rst
+++ b/Documentation/translations/zh_CN/core-api/memory-hotplug.rst
@@ -63,7 +63,6 @@ memory_notify结构体的指针::
 		unsigned long start_pfn;
 		unsigned long nr_pages;
 		int status_change_nid_normal;
-		int status_change_nid_high;
 		int status_change_nid;
 	}
 
@@ -74,9 +73,6 @@ memory_notify结构体的指针::
 - status_change_nid_normal是当nodemask的N_NORMAL_MEMORY被设置/清除时设置节
   点id,如果是-1,则nodemask状态不改变。
 
-- status_change_nid_high是当nodemask的N_HIGH_MEMORY被设置/清除时设置的节点
-  id,如果这个值为-1,那么nodemask状态不会改变。
-
 - status_change_nid是当nodemask的N_MEMORY被(将)设置/清除时设置的节点id。这
   意味着一个新的(没上线的)节点通过联机获得新的内存,而一个节点失去了所有的内
   存。如果这个值为-1,那么nodemask的状态就不会改变。
diff --git a/include/linux/memory.h b/include/linux/memory.h
index dd6e608c3e0b..c46ff374d48d 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -96,7 +96,6 @@ struct memory_notify {
 	unsigned long start_pfn;
 	unsigned long nr_pages;
 	int status_change_nid_normal;
-	int status_change_nid_high;
 	int status_change_nid;
 };
 
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 8d7b2b593a26..95c927c8bfb8 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -21,7 +21,6 @@
 #include <linux/memory.h>
 #include <linux/memremap.h>
 #include <linux/memory_hotplug.h>
-#include <linux/highmem.h>
 #include <linux/vmalloc.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
@@ -585,10 +584,6 @@ void generic_online_page(struct page *page, unsigned int order)
 	debug_pagealloc_map_pages(page, 1 << order);
 	__free_pages_core(page, order);
 	totalram_pages_add(1UL << order);
-#ifdef CONFIG_HIGHMEM
-	if (PageHighMem(page))
-		totalhigh_pages_add(1UL << order);
-#endif
 }
 EXPORT_SYMBOL_GPL(generic_online_page);
 
@@ -625,16 +620,11 @@ static void node_states_check_changes_online(unsigned long nr_pages,
 
 	arg->status_change_nid = NUMA_NO_NODE;
 	arg->status_change_nid_normal = NUMA_NO_NODE;
-	arg->status_change_nid_high = NUMA_NO_NODE;
 
 	if (!node_state(nid, N_MEMORY))
 		arg->status_change_nid = nid;
 	if (zone_idx(zone) <= ZONE_NORMAL && !node_state(nid, N_NORMAL_MEMORY))
 		arg->status_change_nid_normal = nid;
-#ifdef CONFIG_HIGHMEM
-	if (zone_idx(zone) <= ZONE_HIGHMEM && !node_state(nid, N_HIGH_MEMORY))
-		arg->status_change_nid_high = nid;
-#endif
 }
 
 static void node_states_set_node(int node, struct memory_notify *arg)
@@ -642,9 +632,6 @@ static void node_states_set_node(int node, struct memory_notify *arg)
 	if (arg->status_change_nid_normal >= 0)
 		node_set_state(node, N_NORMAL_MEMORY);
 
-	if (arg->status_change_nid_high >= 0)
-		node_set_state(node, N_HIGH_MEMORY);
-
 	if (arg->status_change_nid >= 0)
 		node_set_state(node, N_MEMORY);
 }
@@ -1801,7 +1788,6 @@ static void node_states_check_changes_offline(unsigned long nr_pages,
 
 	arg->status_change_nid = NUMA_NO_NODE;
 	arg->status_change_nid_normal = NUMA_NO_NODE;
-	arg->status_change_nid_high = NUMA_NO_NODE;
 
 	/*
 	 * Check whether node_states[N_NORMAL_MEMORY] will be changed.
@@ -1816,24 +1802,9 @@ static void node_states_check_changes_offline(unsigned long nr_pages,
 	if (zone_idx(zone) <= ZONE_NORMAL && nr_pages >= present_pages)
 		arg->status_change_nid_normal = zone_to_nid(zone);
 
-#ifdef CONFIG_HIGHMEM
-	/*
-	 * node_states[N_HIGH_MEMORY] contains nodes which
-	 * have normal memory or high memory.
-	 * Here we add the present_pages belonging to ZONE_HIGHMEM.
-	 * If the zone is within the range of [0..ZONE_HIGHMEM), and
-	 * we determine that the zones in that range become empty,
-	 * we need to clear the node for N_HIGH_MEMORY.
-	 */
-	present_pages += pgdat->node_zones[ZONE_HIGHMEM].present_pages;
-	if (zone_idx(zone) <= ZONE_HIGHMEM && nr_pages >= present_pages)
-		arg->status_change_nid_high = zone_to_nid(zone);
-#endif
-
 	/*
-	 * We have accounted the pages from [0..ZONE_NORMAL), and
-	 * in case of CONFIG_HIGHMEM the pages from ZONE_HIGHMEM
-	 * as well.
+	 * We have accounted the pages from [0..ZONE_NORMAL); ZONE_HIGHMEM
+	 * does not apply as we don't support 32bit.
 	 * Here we count the possible pages from ZONE_MOVABLE.
 	 * If after having accounted all the pages, we see that the nr_pages
 	 * to be offlined is over or equal to the accounted pages,
@@ -1851,9 +1822,6 @@ static void node_states_clear_node(int node, struct memory_notify *arg)
 	if (arg->status_change_nid_normal >= 0)
 		node_clear_state(node, N_NORMAL_MEMORY);
 
-	if (arg->status_change_nid_high >= 0)
-		node_clear_state(node, N_HIGH_MEMORY);
-
 	if (arg->status_change_nid >= 0)
 		node_clear_state(node, N_MEMORY);
 }
-- 
2.31.1


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

* [PATCH v1 5/6] mm/memory_hotplug: remove stale function declarations
  2021-09-29 14:35 [PATCH v1 0/6] mm/memory_hotplug: Kconfig and 32 bit cleanups David Hildenbrand
                   ` (3 preceding siblings ...)
  2021-09-29 14:35 ` [PATCH v1 4/6] mm/memory_hotplug: remove HIGHMEM leftovers David Hildenbrand
@ 2021-09-29 14:35 ` David Hildenbrand
  2021-10-07  9:14   ` Oscar Salvador
  2021-09-29 14:36 ` [PATCH v1 6/6] x86: remove memory hotplug support on X86_32 David Hildenbrand
  5 siblings, 1 reply; 16+ messages in thread
From: David Hildenbrand @ 2021-09-29 14:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Hildenbrand, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Oscar Salvador, Mike Rapoport, x86, linux-mm,
	linux-kselftest, linux-doc, linuxppc-dev, virtualization

These functions no longer exist.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 include/linux/memory_hotplug.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index e5a867c950b2..be48e003a518 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -98,9 +98,6 @@ static inline void zone_seqlock_init(struct zone *zone)
 {
 	seqlock_init(&zone->span_seqlock);
 }
-extern int zone_grow_free_lists(struct zone *zone, unsigned long new_nr_pages);
-extern int zone_grow_waitqueues(struct zone *zone, unsigned long nr_pages);
-extern int add_one_highpage(struct page *page, int pfn, int bad_ppro);
 extern void adjust_present_page_count(struct page *page,
 				      struct memory_group *group,
 				      long nr_pages);
-- 
2.31.1


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

* [PATCH v1 6/6] x86: remove memory hotplug support on X86_32
  2021-09-29 14:35 [PATCH v1 0/6] mm/memory_hotplug: Kconfig and 32 bit cleanups David Hildenbrand
                   ` (4 preceding siblings ...)
  2021-09-29 14:35 ` [PATCH v1 5/6] mm/memory_hotplug: remove stale function declarations David Hildenbrand
@ 2021-09-29 14:36 ` David Hildenbrand
  2021-10-07  9:15   ` Oscar Salvador
  5 siblings, 1 reply; 16+ messages in thread
From: David Hildenbrand @ 2021-09-29 14:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Hildenbrand, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Oscar Salvador, Mike Rapoport, x86, linux-mm,
	linux-kselftest, linux-doc, linuxppc-dev, virtualization

CONFIG_MEMORY_HOTPLUG was marked BROKEN over one year and we just
restricted it to 64 bit. Let's remove the unused x86 32bit implementation
and simplify the Kconfig.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 arch/x86/Kconfig      |  6 +++---
 arch/x86/mm/init_32.c | 31 -------------------------------
 2 files changed, 3 insertions(+), 34 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ab83c22d274e..85f4762429f1 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -62,7 +62,7 @@ config X86
 	select ARCH_32BIT_OFF_T			if X86_32
 	select ARCH_CLOCKSOURCE_INIT
 	select ARCH_ENABLE_HUGEPAGE_MIGRATION if X86_64 && HUGETLB_PAGE && MIGRATION
-	select ARCH_ENABLE_MEMORY_HOTPLUG if X86_64 || (X86_32 && HIGHMEM)
+	select ARCH_ENABLE_MEMORY_HOTPLUG if X86_64
 	select ARCH_ENABLE_MEMORY_HOTREMOVE if MEMORY_HOTPLUG
 	select ARCH_ENABLE_SPLIT_PMD_PTLOCK if (PGTABLE_LEVELS > 2) && (X86_64 || X86_PAE)
 	select ARCH_ENABLE_THP_MIGRATION if X86_64 && TRANSPARENT_HUGEPAGE
@@ -1615,7 +1615,7 @@ config ARCH_SELECT_MEMORY_MODEL
 
 config ARCH_MEMORY_PROBE
 	bool "Enable sysfs memory/probe interface"
-	depends on X86_64 && MEMORY_HOTPLUG
+	depends on MEMORY_HOTPLUG
 	help
 	  This option enables a sysfs memory/probe interface for testing.
 	  See Documentation/admin-guide/mm/memory-hotplug.rst for more information.
@@ -2395,7 +2395,7 @@ endmenu
 
 config ARCH_HAS_ADD_PAGES
 	def_bool y
-	depends on X86_64 && ARCH_ENABLE_MEMORY_HOTPLUG
+	depends on ARCH_ENABLE_MEMORY_HOTPLUG
 
 config ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE
 	def_bool y
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index bd90b8fe81e4..5cd7ea6d645c 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -779,37 +779,6 @@ void __init mem_init(void)
 	test_wp_bit();
 }
 
-#ifdef CONFIG_MEMORY_HOTPLUG
-int arch_add_memory(int nid, u64 start, u64 size,
-		    struct mhp_params *params)
-{
-	unsigned long start_pfn = start >> PAGE_SHIFT;
-	unsigned long nr_pages = size >> PAGE_SHIFT;
-	int ret;
-
-	/*
-	 * The page tables were already mapped at boot so if the caller
-	 * requests a different mapping type then we must change all the
-	 * pages with __set_memory_prot().
-	 */
-	if (params->pgprot.pgprot != PAGE_KERNEL.pgprot) {
-		ret = __set_memory_prot(start, nr_pages, params->pgprot);
-		if (ret)
-			return ret;
-	}
-
-	return __add_pages(nid, start_pfn, nr_pages, params);
-}
-
-void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
-{
-	unsigned long start_pfn = start >> PAGE_SHIFT;
-	unsigned long nr_pages = size >> PAGE_SHIFT;
-
-	__remove_pages(start_pfn, nr_pages, altmap);
-}
-#endif
-
 int kernel_set_to_readonly __read_mostly;
 
 static void mark_nxdata_nx(void)
-- 
2.31.1


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

* Re: [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE
  2021-09-29 14:35 ` [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE David Hildenbrand
@ 2021-10-05 13:43   ` Greg Kroah-Hartman
  2021-10-05 14:22   ` Shuah Khan
  2021-10-07  8:20   ` Oscar Salvador
  2 siblings, 0 replies; 16+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-05 13:43 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Rafael J. Wysocki,
	Michael S. Tsirkin, Jason Wang, Shuah Khan, Michal Hocko,
	Oscar Salvador, Mike Rapoport, x86, linux-mm, linux-kselftest,
	linux-doc, linuxppc-dev, virtualization

On Wed, Sep 29, 2021 at 04:35:56PM +0200, David Hildenbrand wrote:
> CONFIG_MEMORY_HOTPLUG depends on CONFIG_SPARSEMEM, so there is no need for
> CONFIG_MEMORY_HOTPLUG_SPARSE anymore; adjust all instances to use
> CONFIG_MEMORY_HOTPLUG and remove CONFIG_MEMORY_HOTPLUG_SPARSE.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE
  2021-09-29 14:35 ` [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE David Hildenbrand
  2021-10-05 13:43   ` Greg Kroah-Hartman
@ 2021-10-05 14:22   ` Shuah Khan
  2021-10-07  8:20   ` Oscar Salvador
  2 siblings, 0 replies; 16+ messages in thread
From: Shuah Khan @ 2021-10-05 14:22 UTC (permalink / raw)
  To: David Hildenbrand, linux-kernel
  Cc: Andrew Morton, Jonathan Corbet, Alex Shi, Michael Ellerman,
	Benjamin Herrenschmidt, Paul Mackerras, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, H. Peter Anvin, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Oscar Salvador, Mike Rapoport, x86, linux-mm,
	linux-kselftest, linux-doc, linuxppc-dev, virtualization,
	Shuah Khan

On 9/29/21 8:35 AM, David Hildenbrand wrote:
> CONFIG_MEMORY_HOTPLUG depends on CONFIG_SPARSEMEM, so there is no need for
> CONFIG_MEMORY_HOTPLUG_SPARSE anymore; adjust all instances to use
> CONFIG_MEMORY_HOTPLUG and remove CONFIG_MEMORY_HOTPLUG_SPARSE.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>   arch/powerpc/include/asm/machdep.h            |  2 +-
>   arch/powerpc/kernel/setup_64.c                |  2 +-
>   arch/powerpc/platforms/powernv/setup.c        |  4 ++--
>   arch/powerpc/platforms/pseries/setup.c        |  2 +-
>   drivers/base/Makefile                         |  2 +-
>   drivers/base/node.c                           |  9 ++++-----
>   drivers/virtio/Kconfig                        |  2 +-
>   include/linux/memory.h                        | 18 +++++++-----------
>   include/linux/node.h                          |  4 ++--
>   lib/Kconfig.debug                             |  2 +-
>   mm/Kconfig                                    |  4 ----
>   mm/memory_hotplug.c                           |  2 --
>   tools/testing/selftests/memory-hotplug/config |  1 -
>   13 files changed, 21 insertions(+), 33 deletions(-)
> 

>   {
> diff --git a/tools/testing/selftests/memory-hotplug/config b/tools/testing/selftests/memory-hotplug/config
> index a7e8cd5bb265..1eef042a31e1 100644
> --- a/tools/testing/selftests/memory-hotplug/config
> +++ b/tools/testing/selftests/memory-hotplug/config
> @@ -1,5 +1,4 @@
>   CONFIG_MEMORY_HOTPLUG=y
> -CONFIG_MEMORY_HOTPLUG_SPARSE=y
>   CONFIG_NOTIFIER_ERROR_INJECTION=y
>   CONFIG_MEMORY_NOTIFIER_ERROR_INJECT=m
>   CONFIG_MEMORY_HOTREMOVE=y
> 

For Kselftest change:

Acked-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah

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

* Re: [PATCH v1 1/6] mm/memory_hotplug: remove CONFIG_X86_64_ACPI_NUMA dependency from CONFIG_MEMORY_HOTPLUG
  2021-09-29 14:35 ` [PATCH v1 1/6] mm/memory_hotplug: remove CONFIG_X86_64_ACPI_NUMA dependency from CONFIG_MEMORY_HOTPLUG David Hildenbrand
@ 2021-10-07  8:09   ` Oscar Salvador
  0 siblings, 0 replies; 16+ messages in thread
From: Oscar Salvador @ 2021-10-07  8:09 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Mike Rapoport, x86, linux-mm, linux-kselftest,
	linux-doc, linuxppc-dev, virtualization

On Wed, Sep 29, 2021 at 04:35:55PM +0200, David Hildenbrand wrote:
> SPARSEMEM is the only possible memory model for x86-64, FLATMEM is not
> possible:
> 	config ARCH_FLATMEM_ENABLE
> 		def_bool y
> 		depends on X86_32 && !NUMA
> 
> And X86_64_ACPI_NUMA (obviously) only supports x86-64:
> 	config X86_64_ACPI_NUMA
> 		def_bool y
> 		depends on X86_64 && NUMA && ACPI && PCI
> 
> Let's just remove the CONFIG_X86_64_ACPI_NUMA dependency, as it does no
> longer make sense.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Reviewed-by: Oscar Salvador <osalvador@suse.de>

> ---
>  mm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/Kconfig b/mm/Kconfig
> index d16ba9249bc5..b7fb3f0b485e 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -123,7 +123,7 @@ config ARCH_ENABLE_MEMORY_HOTPLUG
>  config MEMORY_HOTPLUG
>  	bool "Allow for memory hot-add"
>  	select MEMORY_ISOLATION
> -	depends on SPARSEMEM || X86_64_ACPI_NUMA
> +	depends on SPARSEMEM
>  	depends on ARCH_ENABLE_MEMORY_HOTPLUG
>  	depends on 64BIT || BROKEN
>  	select NUMA_KEEP_MEMINFO if NUMA
> -- 
> 2.31.1
> 
> 

-- 
Oscar Salvador
SUSE Labs

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

* Re: [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE
  2021-09-29 14:35 ` [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE David Hildenbrand
  2021-10-05 13:43   ` Greg Kroah-Hartman
  2021-10-05 14:22   ` Shuah Khan
@ 2021-10-07  8:20   ` Oscar Salvador
  2 siblings, 0 replies; 16+ messages in thread
From: Oscar Salvador @ 2021-10-07  8:20 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Mike Rapoport, x86, linux-mm, linux-kselftest,
	linux-doc, linuxppc-dev, virtualization

On Wed, Sep 29, 2021 at 04:35:56PM +0200, David Hildenbrand wrote:
> CONFIG_MEMORY_HOTPLUG depends on CONFIG_SPARSEMEM, so there is no need for
> CONFIG_MEMORY_HOTPLUG_SPARSE anymore; adjust all instances to use
> CONFIG_MEMORY_HOTPLUG and remove CONFIG_MEMORY_HOTPLUG_SPARSE.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Acked-by: Oscar Salvador <osalvador@suse.de>

> ---
>  arch/powerpc/include/asm/machdep.h            |  2 +-
>  arch/powerpc/kernel/setup_64.c                |  2 +-
>  arch/powerpc/platforms/powernv/setup.c        |  4 ++--
>  arch/powerpc/platforms/pseries/setup.c        |  2 +-
>  drivers/base/Makefile                         |  2 +-
>  drivers/base/node.c                           |  9 ++++-----
>  drivers/virtio/Kconfig                        |  2 +-
>  include/linux/memory.h                        | 18 +++++++-----------
>  include/linux/node.h                          |  4 ++--
>  lib/Kconfig.debug                             |  2 +-
>  mm/Kconfig                                    |  4 ----
>  mm/memory_hotplug.c                           |  2 --
>  tools/testing/selftests/memory-hotplug/config |  1 -
>  13 files changed, 21 insertions(+), 33 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
> index 764f2732a821..d8a2ca007082 100644
> --- a/arch/powerpc/include/asm/machdep.h
> +++ b/arch/powerpc/include/asm/machdep.h
> @@ -32,7 +32,7 @@ struct machdep_calls {
>  	void		(*iommu_save)(void);
>  	void		(*iommu_restore)(void);
>  #endif
> -#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
> +#ifdef CONFIG_MEMORY_HOTPLUG
>  	unsigned long	(*memory_block_size)(void);
>  #endif
>  #endif /* CONFIG_PPC64 */
> diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
> index eaa79a0996d1..21f15d82f062 100644
> --- a/arch/powerpc/kernel/setup_64.c
> +++ b/arch/powerpc/kernel/setup_64.c
> @@ -912,7 +912,7 @@ void __init setup_per_cpu_areas(void)
>  }
>  #endif
>  
> -#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
> +#ifdef CONFIG_MEMORY_HOTPLUG
>  unsigned long memory_block_size_bytes(void)
>  {
>  	if (ppc_md.memory_block_size)
> diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
> index a8db3f153063..ad56a54ac9c5 100644
> --- a/arch/powerpc/platforms/powernv/setup.c
> +++ b/arch/powerpc/platforms/powernv/setup.c
> @@ -440,7 +440,7 @@ static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
>  }
>  #endif /* CONFIG_KEXEC_CORE */
>  
> -#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
> +#ifdef CONFIG_MEMORY_HOTPLUG
>  static unsigned long pnv_memory_block_size(void)
>  {
>  	/*
> @@ -553,7 +553,7 @@ define_machine(powernv) {
>  #ifdef CONFIG_KEXEC_CORE
>  	.kexec_cpu_down		= pnv_kexec_cpu_down,
>  #endif
> -#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
> +#ifdef CONFIG_MEMORY_HOTPLUG
>  	.memory_block_size	= pnv_memory_block_size,
>  #endif
>  };
> diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
> index f79126f16258..d29f6f1f7f37 100644
> --- a/arch/powerpc/platforms/pseries/setup.c
> +++ b/arch/powerpc/platforms/pseries/setup.c
> @@ -1089,7 +1089,7 @@ define_machine(pseries) {
>  	.machine_kexec          = pSeries_machine_kexec,
>  	.kexec_cpu_down         = pseries_kexec_cpu_down,
>  #endif
> -#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
> +#ifdef CONFIG_MEMORY_HOTPLUG
>  	.memory_block_size	= pseries_memory_block_size,
>  #endif
>  };
> diff --git a/drivers/base/Makefile b/drivers/base/Makefile
> index ef8e44a7d288..02f7f1358e86 100644
> --- a/drivers/base/Makefile
> +++ b/drivers/base/Makefile
> @@ -13,7 +13,7 @@ obj-y			+= power/
>  obj-$(CONFIG_ISA_BUS_API)	+= isa.o
>  obj-y				+= firmware_loader/
>  obj-$(CONFIG_NUMA)	+= node.o
> -obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o
> +obj-$(CONFIG_MEMORY_HOTPLUG) += memory.o
>  ifeq ($(CONFIG_SYSFS),y)
>  obj-$(CONFIG_MODULES)	+= module.o
>  endif
> diff --git a/drivers/base/node.c b/drivers/base/node.c
> index c56d34f8158f..b5a4ba18f9f9 100644
> --- a/drivers/base/node.c
> +++ b/drivers/base/node.c
> @@ -629,7 +629,7 @@ static void node_device_release(struct device *dev)
>  {
>  	struct node *node = to_node(dev);
>  
> -#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
> +#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_HUGETLBFS)
>  	/*
>  	 * We schedule the work only when a memory section is
>  	 * onlined/offlined on this node. When we come here,
> @@ -782,7 +782,7 @@ int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
> +#ifdef CONFIG_MEMORY_HOTPLUG
>  static int __ref get_nid_for_pfn(unsigned long pfn)
>  {
>  #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
> @@ -958,10 +958,9 @@ static int node_memory_callback(struct notifier_block *self,
>  	return NOTIFY_OK;
>  }
>  #endif	/* CONFIG_HUGETLBFS */
> -#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
> +#endif /* CONFIG_MEMORY_HOTPLUG */
>  
> -#if !defined(CONFIG_MEMORY_HOTPLUG_SPARSE) || \
> -    !defined(CONFIG_HUGETLBFS)
> +#if !defined(CONFIG_MEMORY_HOTPLUG) || !defined(CONFIG_HUGETLBFS)
>  static inline int node_memory_callback(struct notifier_block *self,
>  				unsigned long action, void *arg)
>  {
> diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
> index ce1b3f6ec325..3654def9915c 100644
> --- a/drivers/virtio/Kconfig
> +++ b/drivers/virtio/Kconfig
> @@ -98,7 +98,7 @@ config VIRTIO_MEM
>  	default m
>  	depends on X86_64
>  	depends on VIRTIO
> -	depends on MEMORY_HOTPLUG_SPARSE
> +	depends on MEMORY_HOTPLUG
>  	depends on MEMORY_HOTREMOVE
>  	depends on CONTIG_ALLOC
>  	help
> diff --git a/include/linux/memory.h b/include/linux/memory.h
> index 7efc0a7c14c9..dd6e608c3e0b 100644
> --- a/include/linux/memory.h
> +++ b/include/linux/memory.h
> @@ -110,7 +110,7 @@ struct mem_section;
>  #define SLAB_CALLBACK_PRI       1
>  #define IPC_CALLBACK_PRI        10
>  
> -#ifndef CONFIG_MEMORY_HOTPLUG_SPARSE
> +#ifndef CONFIG_MEMORY_HOTPLUG
>  static inline void memory_dev_init(void)
>  {
>  	return;
> @@ -126,7 +126,11 @@ static inline int memory_notify(unsigned long val, void *v)
>  {
>  	return 0;
>  }
> -#else
> +#define hotplug_memory_notifier(fn, pri)	({ 0; })
> +/* These aren't inline functions due to a GCC bug. */
> +#define register_hotmemory_notifier(nb)    ({ (void)(nb); 0; })
> +#define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })
> +#else /* CONFIG_MEMORY_HOTPLUG */
>  extern int register_memory_notifier(struct notifier_block *nb);
>  extern void unregister_memory_notifier(struct notifier_block *nb);
>  int create_memory_block_devices(unsigned long start, unsigned long size,
> @@ -149,9 +153,6 @@ struct memory_group *memory_group_find_by_id(int mgid);
>  typedef int (*walk_memory_groups_func_t)(struct memory_group *, void *);
>  int walk_dynamic_memory_groups(int nid, walk_memory_groups_func_t func,
>  			       struct memory_group *excluded, void *arg);
> -#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
> -
> -#ifdef CONFIG_MEMORY_HOTPLUG
>  #define hotplug_memory_notifier(fn, pri) ({		\
>  	static __meminitdata struct notifier_block fn##_mem_nb =\
>  		{ .notifier_call = fn, .priority = pri };\
> @@ -159,12 +160,7 @@ int walk_dynamic_memory_groups(int nid, walk_memory_groups_func_t func,
>  })
>  #define register_hotmemory_notifier(nb)		register_memory_notifier(nb)
>  #define unregister_hotmemory_notifier(nb) 	unregister_memory_notifier(nb)
> -#else
> -#define hotplug_memory_notifier(fn, pri)	({ 0; })
> -/* These aren't inline functions due to a GCC bug. */
> -#define register_hotmemory_notifier(nb)    ({ (void)(nb); 0; })
> -#define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })
> -#endif
> +#endif /* CONFIG_MEMORY_HOTPLUG */
>  
>  /*
>   * Kernel text modification mutex, used for code patching. Users of this lock
> diff --git a/include/linux/node.h b/include/linux/node.h
> index 8e5a29897936..bb21fd631b16 100644
> --- a/include/linux/node.h
> +++ b/include/linux/node.h
> @@ -85,7 +85,7 @@ struct node {
>  	struct device	dev;
>  	struct list_head access_list;
>  
> -#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
> +#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_HUGETLBFS)
>  	struct work_struct	node_work;
>  #endif
>  #ifdef CONFIG_HMEM_REPORTING
> @@ -98,7 +98,7 @@ struct memory_block;
>  extern struct node *node_devices[];
>  typedef  void (*node_registration_func_t)(struct node *);
>  
> -#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
> +#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_NUMA)
>  void link_mem_sections(int nid, unsigned long start_pfn,
>  		       unsigned long end_pfn,
>  		       enum meminit_context context);
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 2a9b6dcdac4f..669fee1d26b8 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -877,7 +877,7 @@ config DEBUG_MEMORY_INIT
>  
>  config MEMORY_NOTIFIER_ERROR_INJECT
>  	tristate "Memory hotplug notifier error injection module"
> -	depends on MEMORY_HOTPLUG_SPARSE && NOTIFIER_ERROR_INJECTION
> +	depends on MEMORY_HOTPLUG && NOTIFIER_ERROR_INJECTION
>  	help
>  	  This option provides the ability to inject artificial errors to
>  	  memory hotplug notifier chain callbacks.  It is controlled through
> diff --git a/mm/Kconfig b/mm/Kconfig
> index b7fb3f0b485e..ea8762cd8e1e 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -128,10 +128,6 @@ config MEMORY_HOTPLUG
>  	depends on 64BIT || BROKEN
>  	select NUMA_KEEP_MEMINFO if NUMA
>  
> -config MEMORY_HOTPLUG_SPARSE
> -	def_bool y
> -	depends on SPARSEMEM && MEMORY_HOTPLUG
> -
>  config MEMORY_HOTPLUG_DEFAULT_ONLINE
>  	bool "Online the newly added memory blocks by default"
>  	depends on MEMORY_HOTPLUG
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 9fd0be32a281..8d7b2b593a26 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -220,7 +220,6 @@ static void release_memory_resource(struct resource *res)
>  	kfree(res);
>  }
>  
> -#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
>  static int check_pfn_span(unsigned long pfn, unsigned long nr_pages,
>  		const char *reason)
>  {
> @@ -1163,7 +1162,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
>  	mem_hotplug_done();
>  	return ret;
>  }
> -#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
>  
>  static void reset_node_present_pages(pg_data_t *pgdat)
>  {
> diff --git a/tools/testing/selftests/memory-hotplug/config b/tools/testing/selftests/memory-hotplug/config
> index a7e8cd5bb265..1eef042a31e1 100644
> --- a/tools/testing/selftests/memory-hotplug/config
> +++ b/tools/testing/selftests/memory-hotplug/config
> @@ -1,5 +1,4 @@
>  CONFIG_MEMORY_HOTPLUG=y
> -CONFIG_MEMORY_HOTPLUG_SPARSE=y
>  CONFIG_NOTIFIER_ERROR_INJECTION=y
>  CONFIG_MEMORY_NOTIFIER_ERROR_INJECT=m
>  CONFIG_MEMORY_HOTREMOVE=y
> -- 
> 2.31.1
> 
> 

-- 
Oscar Salvador
SUSE Labs

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

* Re: [PATCH v1 3/6] mm/memory_hotplug: restrict CONFIG_MEMORY_HOTPLUG to 64 bit
  2021-09-29 14:35 ` [PATCH v1 3/6] mm/memory_hotplug: restrict CONFIG_MEMORY_HOTPLUG to 64 bit David Hildenbrand
@ 2021-10-07  9:02   ` Oscar Salvador
  0 siblings, 0 replies; 16+ messages in thread
From: Oscar Salvador @ 2021-10-07  9:02 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Mike Rapoport, x86, linux-mm, linux-kselftest,
	linux-doc, linuxppc-dev, virtualization

On Wed, Sep 29, 2021 at 04:35:57PM +0200, David Hildenbrand wrote:
> 32 bit support is broken in various ways: for example, we can online
> memory that should actually go to ZONE_HIGHMEM to ZONE_MOVABLE or in
> some cases even to one of the other kernel zones.
> 
> We marked it BROKEN in commit b59d02ed0869 ("mm/memory_hotplug: disable the
> functionality for 32b") almost one year ago. According to that commit
> it might be broken at least since 2017. Further, there is hardly a sane use
> case nowadays.
> 
> Let's just depend completely on 64bit, dropping the "BROKEN" dependency to
> make clear that we are not going to support it again. Next, we'll remove
> some HIGHMEM leftovers from memory hotplug code to clean up.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Reviewed-by: Oscar Salvador <osalvador@suse.de>

> ---
>  mm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/Kconfig b/mm/Kconfig
> index ea8762cd8e1e..88273dd5c6d6 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -125,7 +125,7 @@ config MEMORY_HOTPLUG
>  	select MEMORY_ISOLATION
>  	depends on SPARSEMEM
>  	depends on ARCH_ENABLE_MEMORY_HOTPLUG
> -	depends on 64BIT || BROKEN
> +	depends on 64BIT
>  	select NUMA_KEEP_MEMINFO if NUMA
>  
>  config MEMORY_HOTPLUG_DEFAULT_ONLINE
> -- 
> 2.31.1
> 
> 

-- 
Oscar Salvador
SUSE Labs

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

* Re: [PATCH v1 4/6] mm/memory_hotplug: remove HIGHMEM leftovers
  2021-09-29 14:35 ` [PATCH v1 4/6] mm/memory_hotplug: remove HIGHMEM leftovers David Hildenbrand
@ 2021-10-07  9:13   ` Oscar Salvador
  0 siblings, 0 replies; 16+ messages in thread
From: Oscar Salvador @ 2021-10-07  9:13 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Mike Rapoport, x86, linux-mm, linux-kselftest,
	linux-doc, linuxppc-dev, virtualization

On Wed, Sep 29, 2021 at 04:35:58PM +0200, David Hildenbrand wrote:
> We don't support CONFIG_MEMORY_HOTPLUG on 32 bit and consequently not
> HIGHMEM. Let's remove any leftover code -- including the unused
> "status_change_nid_high" field part of the memory notifier.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Reviewed-by: Oscar Salvador <osalvador@suse.de>

> ---
>  Documentation/core-api/memory-hotplug.rst     |  3 --
>  .../zh_CN/core-api/memory-hotplug.rst         |  4 ---
>  include/linux/memory.h                        |  1 -
>  mm/memory_hotplug.c                           | 36 ++-----------------
>  4 files changed, 2 insertions(+), 42 deletions(-)
> 
> diff --git a/Documentation/core-api/memory-hotplug.rst b/Documentation/core-api/memory-hotplug.rst
> index de7467e48067..682259ee633a 100644
> --- a/Documentation/core-api/memory-hotplug.rst
> +++ b/Documentation/core-api/memory-hotplug.rst
> @@ -57,7 +57,6 @@ The third argument (arg) passes a pointer of struct memory_notify::
>  		unsigned long start_pfn;
>  		unsigned long nr_pages;
>  		int status_change_nid_normal;
> -		int status_change_nid_high;
>  		int status_change_nid;
>  	}
>  
> @@ -65,8 +64,6 @@ The third argument (arg) passes a pointer of struct memory_notify::
>  - nr_pages is # of pages of online/offline memory.
>  - status_change_nid_normal is set node id when N_NORMAL_MEMORY of nodemask
>    is (will be) set/clear, if this is -1, then nodemask status is not changed.
> -- status_change_nid_high is set node id when N_HIGH_MEMORY of nodemask
> -  is (will be) set/clear, if this is -1, then nodemask status is not changed.
>  - status_change_nid is set node id when N_MEMORY of nodemask is (will be)
>    set/clear. It means a new(memoryless) node gets new memory by online and a
>    node loses all memory. If this is -1, then nodemask status is not changed.
> diff --git a/Documentation/translations/zh_CN/core-api/memory-hotplug.rst b/Documentation/translations/zh_CN/core-api/memory-hotplug.rst
> index 161f4d2c18cc..9a204eb196f2 100644
> --- a/Documentation/translations/zh_CN/core-api/memory-hotplug.rst
> +++ b/Documentation/translations/zh_CN/core-api/memory-hotplug.rst
> @@ -63,7 +63,6 @@ memory_notify结构体的指针::
>  		unsigned long start_pfn;
>  		unsigned long nr_pages;
>  		int status_change_nid_normal;
> -		int status_change_nid_high;
>  		int status_change_nid;
>  	}
>  
> @@ -74,9 +73,6 @@ memory_notify结构体的指针::
>  - status_change_nid_normal是当nodemask的N_NORMAL_MEMORY被设置/清除时设置节
>    点id,如果是-1,则nodemask状态不改变。
>  
> -- status_change_nid_high是当nodemask的N_HIGH_MEMORY被设置/清除时设置的节点
> -  id,如果这个值为-1,那么nodemask状态不会改变。
> -
>  - status_change_nid是当nodemask的N_MEMORY被(将)设置/清除时设置的节点id。这
>    意味着一个新的(没上线的)节点通过联机获得新的内存,而一个节点失去了所有的内
>    存。如果这个值为-1,那么nodemask的状态就不会改变。
> diff --git a/include/linux/memory.h b/include/linux/memory.h
> index dd6e608c3e0b..c46ff374d48d 100644
> --- a/include/linux/memory.h
> +++ b/include/linux/memory.h
> @@ -96,7 +96,6 @@ struct memory_notify {
>  	unsigned long start_pfn;
>  	unsigned long nr_pages;
>  	int status_change_nid_normal;
> -	int status_change_nid_high;
>  	int status_change_nid;
>  };
>  
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 8d7b2b593a26..95c927c8bfb8 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -21,7 +21,6 @@
>  #include <linux/memory.h>
>  #include <linux/memremap.h>
>  #include <linux/memory_hotplug.h>
> -#include <linux/highmem.h>
>  #include <linux/vmalloc.h>
>  #include <linux/ioport.h>
>  #include <linux/delay.h>
> @@ -585,10 +584,6 @@ void generic_online_page(struct page *page, unsigned int order)
>  	debug_pagealloc_map_pages(page, 1 << order);
>  	__free_pages_core(page, order);
>  	totalram_pages_add(1UL << order);
> -#ifdef CONFIG_HIGHMEM
> -	if (PageHighMem(page))
> -		totalhigh_pages_add(1UL << order);
> -#endif
>  }
>  EXPORT_SYMBOL_GPL(generic_online_page);
>  
> @@ -625,16 +620,11 @@ static void node_states_check_changes_online(unsigned long nr_pages,
>  
>  	arg->status_change_nid = NUMA_NO_NODE;
>  	arg->status_change_nid_normal = NUMA_NO_NODE;
> -	arg->status_change_nid_high = NUMA_NO_NODE;
>  
>  	if (!node_state(nid, N_MEMORY))
>  		arg->status_change_nid = nid;
>  	if (zone_idx(zone) <= ZONE_NORMAL && !node_state(nid, N_NORMAL_MEMORY))
>  		arg->status_change_nid_normal = nid;
> -#ifdef CONFIG_HIGHMEM
> -	if (zone_idx(zone) <= ZONE_HIGHMEM && !node_state(nid, N_HIGH_MEMORY))
> -		arg->status_change_nid_high = nid;
> -#endif
>  }
>  
>  static void node_states_set_node(int node, struct memory_notify *arg)
> @@ -642,9 +632,6 @@ static void node_states_set_node(int node, struct memory_notify *arg)
>  	if (arg->status_change_nid_normal >= 0)
>  		node_set_state(node, N_NORMAL_MEMORY);
>  
> -	if (arg->status_change_nid_high >= 0)
> -		node_set_state(node, N_HIGH_MEMORY);
> -
>  	if (arg->status_change_nid >= 0)
>  		node_set_state(node, N_MEMORY);
>  }
> @@ -1801,7 +1788,6 @@ static void node_states_check_changes_offline(unsigned long nr_pages,
>  
>  	arg->status_change_nid = NUMA_NO_NODE;
>  	arg->status_change_nid_normal = NUMA_NO_NODE;
> -	arg->status_change_nid_high = NUMA_NO_NODE;
>  
>  	/*
>  	 * Check whether node_states[N_NORMAL_MEMORY] will be changed.
> @@ -1816,24 +1802,9 @@ static void node_states_check_changes_offline(unsigned long nr_pages,
>  	if (zone_idx(zone) <= ZONE_NORMAL && nr_pages >= present_pages)
>  		arg->status_change_nid_normal = zone_to_nid(zone);
>  
> -#ifdef CONFIG_HIGHMEM
> -	/*
> -	 * node_states[N_HIGH_MEMORY] contains nodes which
> -	 * have normal memory or high memory.
> -	 * Here we add the present_pages belonging to ZONE_HIGHMEM.
> -	 * If the zone is within the range of [0..ZONE_HIGHMEM), and
> -	 * we determine that the zones in that range become empty,
> -	 * we need to clear the node for N_HIGH_MEMORY.
> -	 */
> -	present_pages += pgdat->node_zones[ZONE_HIGHMEM].present_pages;
> -	if (zone_idx(zone) <= ZONE_HIGHMEM && nr_pages >= present_pages)
> -		arg->status_change_nid_high = zone_to_nid(zone);
> -#endif
> -
>  	/*
> -	 * We have accounted the pages from [0..ZONE_NORMAL), and
> -	 * in case of CONFIG_HIGHMEM the pages from ZONE_HIGHMEM
> -	 * as well.
> +	 * We have accounted the pages from [0..ZONE_NORMAL); ZONE_HIGHMEM
> +	 * does not apply as we don't support 32bit.
>  	 * Here we count the possible pages from ZONE_MOVABLE.
>  	 * If after having accounted all the pages, we see that the nr_pages
>  	 * to be offlined is over or equal to the accounted pages,
> @@ -1851,9 +1822,6 @@ static void node_states_clear_node(int node, struct memory_notify *arg)
>  	if (arg->status_change_nid_normal >= 0)
>  		node_clear_state(node, N_NORMAL_MEMORY);
>  
> -	if (arg->status_change_nid_high >= 0)
> -		node_clear_state(node, N_HIGH_MEMORY);
> -
>  	if (arg->status_change_nid >= 0)
>  		node_clear_state(node, N_MEMORY);
>  }
> -- 
> 2.31.1
> 
> 

-- 
Oscar Salvador
SUSE Labs

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

* Re: [PATCH v1 5/6] mm/memory_hotplug: remove stale function declarations
  2021-09-29 14:35 ` [PATCH v1 5/6] mm/memory_hotplug: remove stale function declarations David Hildenbrand
@ 2021-10-07  9:14   ` Oscar Salvador
  0 siblings, 0 replies; 16+ messages in thread
From: Oscar Salvador @ 2021-10-07  9:14 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Mike Rapoport, x86, linux-mm, linux-kselftest,
	linux-doc, linuxppc-dev, virtualization

On Wed, Sep 29, 2021 at 04:35:59PM +0200, David Hildenbrand wrote:
> These functions no longer exist.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Reviewed-by: Oscar Salvador <osalvador@suse.de>

> ---
>  include/linux/memory_hotplug.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> index e5a867c950b2..be48e003a518 100644
> --- a/include/linux/memory_hotplug.h
> +++ b/include/linux/memory_hotplug.h
> @@ -98,9 +98,6 @@ static inline void zone_seqlock_init(struct zone *zone)
>  {
>  	seqlock_init(&zone->span_seqlock);
>  }
> -extern int zone_grow_free_lists(struct zone *zone, unsigned long new_nr_pages);
> -extern int zone_grow_waitqueues(struct zone *zone, unsigned long nr_pages);
> -extern int add_one_highpage(struct page *page, int pfn, int bad_ppro);
>  extern void adjust_present_page_count(struct page *page,
>  				      struct memory_group *group,
>  				      long nr_pages);
> -- 
> 2.31.1
> 
> 

-- 
Oscar Salvador
SUSE Labs

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

* Re: [PATCH v1 6/6] x86: remove memory hotplug support on X86_32
  2021-09-29 14:36 ` [PATCH v1 6/6] x86: remove memory hotplug support on X86_32 David Hildenbrand
@ 2021-10-07  9:15   ` Oscar Salvador
  2021-10-07  9:27     ` David Hildenbrand
  0 siblings, 1 reply; 16+ messages in thread
From: Oscar Salvador @ 2021-10-07  9:15 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-kernel, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Mike Rapoport, x86, linux-mm, linux-kselftest,
	linux-doc, linuxppc-dev, virtualization

On Wed, Sep 29, 2021 at 04:36:00PM +0200, David Hildenbrand wrote:
> CONFIG_MEMORY_HOTPLUG was marked BROKEN over one year and we just
> restricted it to 64 bit. Let's remove the unused x86 32bit implementation
> and simplify the Kconfig.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Reviewed-by: Oscar Salvador <osalvador@suse.de>

> ---
>  arch/x86/Kconfig      |  6 +++---
>  arch/x86/mm/init_32.c | 31 -------------------------------
>  2 files changed, 3 insertions(+), 34 deletions(-)
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index ab83c22d274e..85f4762429f1 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -62,7 +62,7 @@ config X86
>  	select ARCH_32BIT_OFF_T			if X86_32
>  	select ARCH_CLOCKSOURCE_INIT
>  	select ARCH_ENABLE_HUGEPAGE_MIGRATION if X86_64 && HUGETLB_PAGE && MIGRATION
> -	select ARCH_ENABLE_MEMORY_HOTPLUG if X86_64 || (X86_32 && HIGHMEM)
> +	select ARCH_ENABLE_MEMORY_HOTPLUG if X86_64
>  	select ARCH_ENABLE_MEMORY_HOTREMOVE if MEMORY_HOTPLUG
>  	select ARCH_ENABLE_SPLIT_PMD_PTLOCK if (PGTABLE_LEVELS > 2) && (X86_64 || X86_PAE)
>  	select ARCH_ENABLE_THP_MIGRATION if X86_64 && TRANSPARENT_HUGEPAGE
> @@ -1615,7 +1615,7 @@ config ARCH_SELECT_MEMORY_MODEL
>  
>  config ARCH_MEMORY_PROBE
>  	bool "Enable sysfs memory/probe interface"
> -	depends on X86_64 && MEMORY_HOTPLUG
> +	depends on MEMORY_HOTPLUG
>  	help
>  	  This option enables a sysfs memory/probe interface for testing.
>  	  See Documentation/admin-guide/mm/memory-hotplug.rst for more information.
> @@ -2395,7 +2395,7 @@ endmenu
>  
>  config ARCH_HAS_ADD_PAGES
>  	def_bool y
> -	depends on X86_64 && ARCH_ENABLE_MEMORY_HOTPLUG
> +	depends on ARCH_ENABLE_MEMORY_HOTPLUG
>  
>  config ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE
>  	def_bool y
> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> index bd90b8fe81e4..5cd7ea6d645c 100644
> --- a/arch/x86/mm/init_32.c
> +++ b/arch/x86/mm/init_32.c
> @@ -779,37 +779,6 @@ void __init mem_init(void)
>  	test_wp_bit();
>  }
>  
> -#ifdef CONFIG_MEMORY_HOTPLUG
> -int arch_add_memory(int nid, u64 start, u64 size,
> -		    struct mhp_params *params)
> -{
> -	unsigned long start_pfn = start >> PAGE_SHIFT;
> -	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	int ret;
> -
> -	/*
> -	 * The page tables were already mapped at boot so if the caller
> -	 * requests a different mapping type then we must change all the
> -	 * pages with __set_memory_prot().
> -	 */
> -	if (params->pgprot.pgprot != PAGE_KERNEL.pgprot) {
> -		ret = __set_memory_prot(start, nr_pages, params->pgprot);
> -		if (ret)
> -			return ret;
> -	}
> -
> -	return __add_pages(nid, start_pfn, nr_pages, params);
> -}
> -
> -void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
> -{
> -	unsigned long start_pfn = start >> PAGE_SHIFT;
> -	unsigned long nr_pages = size >> PAGE_SHIFT;
> -
> -	__remove_pages(start_pfn, nr_pages, altmap);
> -}
> -#endif
> -
>  int kernel_set_to_readonly __read_mostly;
>  
>  static void mark_nxdata_nx(void)
> -- 
> 2.31.1
> 
> 

-- 
Oscar Salvador
SUSE Labs

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

* Re: [PATCH v1 6/6] x86: remove memory hotplug support on X86_32
  2021-10-07  9:15   ` Oscar Salvador
@ 2021-10-07  9:27     ` David Hildenbrand
  0 siblings, 0 replies; 16+ messages in thread
From: David Hildenbrand @ 2021-10-07  9:27 UTC (permalink / raw)
  To: Oscar Salvador
  Cc: linux-kernel, Andrew Morton, Jonathan Corbet, Alex Shi,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michael S. Tsirkin, Jason Wang, Shuah Khan,
	Michal Hocko, Mike Rapoport, x86, linux-mm, linux-kselftest,
	linux-doc, linuxppc-dev, virtualization

On 07.10.21 11:15, Oscar Salvador wrote:
> On Wed, Sep 29, 2021 at 04:36:00PM +0200, David Hildenbrand wrote:
>> CONFIG_MEMORY_HOTPLUG was marked BROKEN over one year and we just
>> restricted it to 64 bit. Let's remove the unused x86 32bit implementation
>> and simplify the Kconfig.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
> 
> Reviewed-by: Oscar Salvador <osalvador@suse.de>

Thanks for the review Oscar!

-- 
Thanks,

David / dhildenb


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

end of thread, other threads:[~2021-10-07  9:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29 14:35 [PATCH v1 0/6] mm/memory_hotplug: Kconfig and 32 bit cleanups David Hildenbrand
2021-09-29 14:35 ` [PATCH v1 1/6] mm/memory_hotplug: remove CONFIG_X86_64_ACPI_NUMA dependency from CONFIG_MEMORY_HOTPLUG David Hildenbrand
2021-10-07  8:09   ` Oscar Salvador
2021-09-29 14:35 ` [PATCH v1 2/6] mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE David Hildenbrand
2021-10-05 13:43   ` Greg Kroah-Hartman
2021-10-05 14:22   ` Shuah Khan
2021-10-07  8:20   ` Oscar Salvador
2021-09-29 14:35 ` [PATCH v1 3/6] mm/memory_hotplug: restrict CONFIG_MEMORY_HOTPLUG to 64 bit David Hildenbrand
2021-10-07  9:02   ` Oscar Salvador
2021-09-29 14:35 ` [PATCH v1 4/6] mm/memory_hotplug: remove HIGHMEM leftovers David Hildenbrand
2021-10-07  9:13   ` Oscar Salvador
2021-09-29 14:35 ` [PATCH v1 5/6] mm/memory_hotplug: remove stale function declarations David Hildenbrand
2021-10-07  9:14   ` Oscar Salvador
2021-09-29 14:36 ` [PATCH v1 6/6] x86: remove memory hotplug support on X86_32 David Hildenbrand
2021-10-07  9:15   ` Oscar Salvador
2021-10-07  9:27     ` David Hildenbrand

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