All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier()
@ 2022-09-22 14:18 Liu Shixin
  2022-09-22 14:18 ` [PATCH v3 1/8] cgroup/cpuset: use hotplug_memory_notifier() directly Liu Shixin
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-22 14:18 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

Patch f02c69680088 introduced register_hotmemory_notifier() to avoid a
compile problem with gcc-4.4.4:

    When CONFIG_MEMORY_HOTPLUG=n, we don't want the memory-hotplug notifier
    handlers to be included in the .o files, for space reasons.
    
    The existing hotplug_memory_notifier() tries to handle this but testing
    with gcc-4.4.4 shows that it doesn't work - the hotplug functions are
    still present in the .o files.

Since patch 316346243be6 has already updated the minimum gcc version to 5.1.
The previous problem mentioned in patch f02c69680088 is not existed. So we
can now revert to use hotplug_memory_notifier() directly rather than
register_hotmemory_notifier().

In the last patch, we move all hotplug memory notifier priority to same
file for easy sorting.

Patch [1-6] replace register_hotmemory_notifier() with hotplug_memory_notifier()
for every caller.
Patch [7] remove unused register_hotmemory_notifier().
Patch [9] move all priority of hotplug memory callback into include/linux/memory.h
for easy sorting.

v2->v3: fold last two patches, change MM_BATCH_CALLBACK_PRI to
MM_COMPUTE_BATCH_PRI and rewrite the commit log.
v1->v2: fix compile error of patch [4,5].

Liu Shixin (8):
  cgroup/cpuset: use hotplug_memory_notifier() directly
  fs/proc/kcore.c: use hotplug_memory_notifier() directly
  mm/slub.c: use hotplug_memory_notifier() directly
  mm/mmap: use hotplug_memory_notifier() directly
  mm/mm_init.c: use hotplug_memory_notifier() directly
  ACPI: HMAT: use hotplug_memory_notifier() directly
  memory: remove unused register_hotmemory_notifier()
  memory: move hotplug memory notifier priority to same file for easy
    sorting

 drivers/acpi/numa/hmat.c     |  7 +------
 fs/proc/kcore.c              |  7 +------
 include/linux/memory-tiers.h |  1 -
 include/linux/memory.h       | 15 +++++++--------
 kernel/cgroup/cpuset.c       |  7 +------
 mm/kasan/shadow.c            |  2 +-
 mm/ksm.c                     |  2 +-
 mm/memory-tiers.c            |  2 +-
 mm/mm_init.c                 |  8 +-------
 mm/mmap.c                    |  6 +-----
 mm/page_ext.c                |  2 +-
 mm/slub.c                    |  7 +------
 12 files changed, 17 insertions(+), 49 deletions(-)

-- 
2.25.1


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

* [PATCH v3 1/8] cgroup/cpuset: use hotplug_memory_notifier() directly
  2022-09-22 14:18 [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier() Liu Shixin
@ 2022-09-22 14:18 ` Liu Shixin
  2022-09-22 17:56   ` David Hildenbrand
  2022-09-22 14:18 ` [PATCH v3 2/8] fs/proc/kcore.c: " Liu Shixin
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Liu Shixin @ 2022-09-22 14:18 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

Since patch 316346243be6 has already updated the minimum gcc version to 5.1.
The previous problem mentioned in patch f02c69680088 is not existed. So we
can now revert to use hotplug_memory_notifier() directly rather than
register_hotmemory_notifier().

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 kernel/cgroup/cpuset.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index b474289c15b8..0c6db6a4f427 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -3630,11 +3630,6 @@ static int cpuset_track_online_nodes(struct notifier_block *self,
 	return NOTIFY_OK;
 }
 
-static struct notifier_block cpuset_track_online_nodes_nb = {
-	.notifier_call = cpuset_track_online_nodes,
-	.priority = 10,		/* ??! */
-};
-
 /**
  * cpuset_init_smp - initialize cpus_allowed
  *
@@ -3652,7 +3647,7 @@ void __init cpuset_init_smp(void)
 	cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask);
 	top_cpuset.effective_mems = node_states[N_MEMORY];
 
-	register_hotmemory_notifier(&cpuset_track_online_nodes_nb);
+	hotplug_memory_notifier(cpuset_track_online_nodes, 10);
 
 	cpuset_migrate_mm_wq = alloc_ordered_workqueue("cpuset_migrate_mm", 0);
 	BUG_ON(!cpuset_migrate_mm_wq);
-- 
2.25.1


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

* [PATCH v3 2/8] fs/proc/kcore.c: use hotplug_memory_notifier() directly
  2022-09-22 14:18 [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier() Liu Shixin
  2022-09-22 14:18 ` [PATCH v3 1/8] cgroup/cpuset: use hotplug_memory_notifier() directly Liu Shixin
@ 2022-09-22 14:18 ` Liu Shixin
  2022-09-22 14:18 ` [PATCH v3 3/8] mm/slub.c: " Liu Shixin
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-22 14:18 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

Since patch 316346243be6 has already updated the minimum gcc version to 5.1.
The previous problem mentioned in patch f02c69680088 is not existed. So we
can now revert to use hotplug_memory_notifier() directly rather than
register_hotmemory_notifier().

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 fs/proc/kcore.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index dff921f7ca33..7692a360972d 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -18,7 +18,6 @@
 #include <linux/capability.h>
 #include <linux/elf.h>
 #include <linux/elfcore.h>
-#include <linux/notifier.h>
 #include <linux/vmalloc.h>
 #include <linux/highmem.h>
 #include <linux/printk.h>
@@ -638,10 +637,6 @@ static int __meminit kcore_callback(struct notifier_block *self,
 	return NOTIFY_OK;
 }
 
-static struct notifier_block kcore_callback_nb __meminitdata = {
-	.notifier_call = kcore_callback,
-	.priority = 0,
-};
 
 static struct kcore_list kcore_vmalloc;
 
@@ -694,7 +689,7 @@ static int __init proc_kcore_init(void)
 	add_modules_range();
 	/* Store direct-map area from physical memory map */
 	kcore_update_ram();
-	register_hotmemory_notifier(&kcore_callback_nb);
+	hotplug_memory_notifier(kcore_callback, 0);
 
 	return 0;
 }
-- 
2.25.1


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

* [PATCH v3 3/8] mm/slub.c: use hotplug_memory_notifier() directly
  2022-09-22 14:18 [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier() Liu Shixin
  2022-09-22 14:18 ` [PATCH v3 1/8] cgroup/cpuset: use hotplug_memory_notifier() directly Liu Shixin
  2022-09-22 14:18 ` [PATCH v3 2/8] fs/proc/kcore.c: " Liu Shixin
@ 2022-09-22 14:18 ` Liu Shixin
  2022-09-22 14:19 ` [PATCH v3 4/8] mm/mmap: " Liu Shixin
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-22 14:18 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

Since patch 316346243be6 has already updated the minimum gcc version to 5.1.
The previous problem mentioned in patch f02c69680088 is not existed. So we
can now revert to use hotplug_memory_notifier() directly rather than
register_hotmemory_notifier().

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 mm/slub.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 234bf0e44262..9a0853e01fd7 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4698,11 +4698,6 @@ static int slab_memory_callback(struct notifier_block *self,
 	return ret;
 }
 
-static struct notifier_block slab_memory_callback_nb = {
-	.notifier_call = slab_memory_callback,
-	.priority = SLAB_CALLBACK_PRI,
-};
-
 /********************************************************************
  *			Basic setup of slabs
  *******************************************************************/
@@ -4768,7 +4763,7 @@ void __init kmem_cache_init(void)
 	create_boot_cache(kmem_cache_node, "kmem_cache_node",
 		sizeof(struct kmem_cache_node), SLAB_HWCACHE_ALIGN, 0, 0);
 
-	register_hotmemory_notifier(&slab_memory_callback_nb);
+	hotplug_memory_notifier(slab_memory_callback, SLAB_CALLBACK_PRI);
 
 	/* Able to allocate the per node structures */
 	slab_state = PARTIAL;
-- 
2.25.1


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

* [PATCH v3 4/8] mm/mmap: use hotplug_memory_notifier() directly
  2022-09-22 14:18 [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier() Liu Shixin
                   ` (2 preceding siblings ...)
  2022-09-22 14:18 ` [PATCH v3 3/8] mm/slub.c: " Liu Shixin
@ 2022-09-22 14:19 ` Liu Shixin
  2022-09-22 14:19 ` [PATCH v3 5/8] mm/mm_init.c: " Liu Shixin
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-22 14:19 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

Since patch 316346243be6 has already updated the minimum gcc version to 5.1.
The previous problem mentioned in patch f02c69680088 is not existed. So we
can now revert to use hotplug_memory_notifier() directly rather than
register_hotmemory_notifier().

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 mm/mmap.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 6445fd386f04..5a217378a62a 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3745,13 +3745,9 @@ static int reserve_mem_notifier(struct notifier_block *nb,
 	return NOTIFY_OK;
 }
 
-static struct notifier_block reserve_mem_nb = {
-	.notifier_call = reserve_mem_notifier,
-};
-
 static int __meminit init_reserve_notifier(void)
 {
-	if (register_hotmemory_notifier(&reserve_mem_nb))
+	if (hotplug_memory_notifier(reserve_mem_notifier, 0))
 		pr_err("Failed registering memory add/remove notifier for admin reserve\n");
 
 	return 0;
-- 
2.25.1


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

* [PATCH v3 5/8] mm/mm_init.c: use hotplug_memory_notifier() directly
  2022-09-22 14:18 [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier() Liu Shixin
                   ` (3 preceding siblings ...)
  2022-09-22 14:19 ` [PATCH v3 4/8] mm/mmap: " Liu Shixin
@ 2022-09-22 14:19 ` Liu Shixin
  2022-09-22 14:19 ` [PATCH v3 6/8] ACPI: HMAT: " Liu Shixin
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-22 14:19 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

Since patch 316346243be6 has already updated the minimum gcc version to 5.1.
The previous problem mentioned in patch f02c69680088 is not existed. So we
can now revert to use hotplug_memory_notifier() directly rather than
register_hotmemory_notifier().

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 mm/mm_init.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 0d7b2bd2454a..44aadc162d1f 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -178,16 +178,10 @@ static int __meminit mm_compute_batch_notifier(struct notifier_block *self,
 	return NOTIFY_OK;
 }
 
-static struct notifier_block compute_batch_nb __meminitdata = {
-	.notifier_call = mm_compute_batch_notifier,
-	.priority = IPC_CALLBACK_PRI, /* use lowest priority */
-};
-
 static int __init mm_compute_batch_init(void)
 {
 	mm_compute_batch(sysctl_overcommit_memory);
-	register_hotmemory_notifier(&compute_batch_nb);
-
+	hotplug_memory_notifier(mm_compute_batch_notifier, IPC_CALLBACK_PRI);
 	return 0;
 }
 
-- 
2.25.1


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

* [PATCH v3 6/8] ACPI: HMAT: use hotplug_memory_notifier() directly
  2022-09-22 14:18 [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier() Liu Shixin
                   ` (4 preceding siblings ...)
  2022-09-22 14:19 ` [PATCH v3 5/8] mm/mm_init.c: " Liu Shixin
@ 2022-09-22 14:19 ` Liu Shixin
  2022-09-22 14:19 ` [PATCH v3 7/8] memory: remove unused register_hotmemory_notifier() Liu Shixin
  2022-09-22 14:19 ` [PATCH v3 8/8] memory: move hotplug memory notifier priority to same file for easy sorting Liu Shixin
  7 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-22 14:19 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

Since patch 316346243be6 has already updated the minimum gcc version to 5.1.
The previous problem mentioned in patch f02c69680088 is not existed. So we
can now revert to use hotplug_memory_notifier() directly rather than
register_hotmemory_notifier().

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 drivers/acpi/numa/hmat.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c
index c3d783aca196..84dffb3dc30e 100644
--- a/drivers/acpi/numa/hmat.c
+++ b/drivers/acpi/numa/hmat.c
@@ -768,11 +768,6 @@ static int hmat_callback(struct notifier_block *self,
 	return NOTIFY_OK;
 }
 
-static struct notifier_block hmat_callback_nb = {
-	.notifier_call = hmat_callback,
-	.priority = 2,
-};
-
 static __init void hmat_free_structures(void)
 {
 	struct memory_target *target, *tnext;
@@ -855,7 +850,7 @@ static __init int hmat_init(void)
 	hmat_register_targets();
 
 	/* Keep the table and structures if the notifier may use them */
-	if (!register_hotmemory_notifier(&hmat_callback_nb))
+	if (!hotplug_memory_notifier(hmat_callback, 2))
 		return 0;
 out_put:
 	hmat_free_structures();
-- 
2.25.1


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

* [PATCH v3 7/8] memory: remove unused register_hotmemory_notifier()
  2022-09-22 14:18 [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier() Liu Shixin
                   ` (5 preceding siblings ...)
  2022-09-22 14:19 ` [PATCH v3 6/8] ACPI: HMAT: " Liu Shixin
@ 2022-09-22 14:19 ` Liu Shixin
  2022-09-22 14:19 ` [PATCH v3 8/8] memory: move hotplug memory notifier priority to same file for easy sorting Liu Shixin
  7 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-22 14:19 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

Remove unused register_hotmemory_notifier().

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 include/linux/memory.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/linux/memory.h b/include/linux/memory.h
index aa619464a1df..98d2a2ebcc10 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -19,7 +19,6 @@
 #include <linux/node.h>
 #include <linux/compiler.h>
 #include <linux/mutex.h>
-#include <linux/notifier.h>
 
 #define MIN_MEMORY_BLOCK_SIZE     (1UL << SECTION_SIZE_BITS)
 
@@ -136,9 +135,6 @@ static inline int hotplug_memory_notifier(notifier_fn_t fn, int pri)
 {
 	return 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);
@@ -166,8 +162,6 @@ int walk_dynamic_memory_groups(int nid, walk_memory_groups_func_t func,
 		{ .notifier_call = fn, .priority = pri };\
 	register_memory_notifier(&fn##_mem_nb);			\
 })
-#define register_hotmemory_notifier(nb)		register_memory_notifier(nb)
-#define unregister_hotmemory_notifier(nb) 	unregister_memory_notifier(nb)
 
 #ifdef CONFIG_NUMA
 void memory_block_add_nid(struct memory_block *mem, int nid,
-- 
2.25.1


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

* [PATCH v3 8/8] memory: move hotplug memory notifier priority to same file for easy sorting
  2022-09-22 14:18 [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier() Liu Shixin
                   ` (6 preceding siblings ...)
  2022-09-22 14:19 ` [PATCH v3 7/8] memory: remove unused register_hotmemory_notifier() Liu Shixin
@ 2022-09-22 14:19 ` Liu Shixin
  7 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-22 14:19 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

The priority of hotplug memory callback is defined in different file.
And there are some caller using number directly. Collect them together
into include/linux/memory.h for easy reading. This allows us to sort
their priorities more intuitively without additional comments.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 drivers/acpi/numa/hmat.c     | 2 +-
 fs/proc/kcore.c              | 2 +-
 include/linux/memory-tiers.h | 1 -
 include/linux/memory.h       | 9 +++++++--
 kernel/cgroup/cpuset.c       | 2 +-
 mm/kasan/shadow.c            | 2 +-
 mm/ksm.c                     | 2 +-
 mm/memory-tiers.c            | 2 +-
 mm/mm_init.c                 | 2 +-
 mm/mmap.c                    | 2 +-
 mm/page_ext.c                | 2 +-
 11 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c
index 84dffb3dc30e..47c7fae8b6de 100644
--- a/drivers/acpi/numa/hmat.c
+++ b/drivers/acpi/numa/hmat.c
@@ -850,7 +850,7 @@ static __init int hmat_init(void)
 	hmat_register_targets();
 
 	/* Keep the table and structures if the notifier may use them */
-	if (!hotplug_memory_notifier(hmat_callback, 2))
+	if (!hotplug_memory_notifier(hmat_callback, HMAT_CALLBACK_PRI))
 		return 0;
 out_put:
 	hmat_free_structures();
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 7692a360972d..98f3289556e4 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -689,7 +689,7 @@ static int __init proc_kcore_init(void)
 	add_modules_range();
 	/* Store direct-map area from physical memory map */
 	kcore_update_ram();
-	hotplug_memory_notifier(kcore_callback, 0);
+	hotplug_memory_notifier(kcore_callback, DEFAULT_CALLBACK_PRI);
 
 	return 0;
 }
diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h
index 965009aa01d7..fc9647b1b4f9 100644
--- a/include/linux/memory-tiers.h
+++ b/include/linux/memory-tiers.h
@@ -18,7 +18,6 @@
  * the same memory tier.
  */
 #define MEMTIER_ADISTANCE_DRAM	((4 * MEMTIER_CHUNK_SIZE) + (MEMTIER_CHUNK_SIZE >> 1))
-#define MEMTIER_HOTPLUG_PRIO	100
 
 struct memory_tier;
 struct memory_dev_type {
diff --git a/include/linux/memory.h b/include/linux/memory.h
index 98d2a2ebcc10..463662ef7614 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -112,8 +112,13 @@ struct mem_section;
  * Priorities for the hotplug memory callback routines (stored in decreasing
  * order in the callback chain)
  */
-#define SLAB_CALLBACK_PRI       1
-#define IPC_CALLBACK_PRI        10
+#define DEFAULT_CALLBACK_PRI	0
+#define SLAB_CALLBACK_PRI	1
+#define HMAT_CALLBACK_PRI	2
+#define MM_COMPUTE_BATCH_PRI	10
+#define CPUSET_CALLBACK_PRI	10
+#define MEMTIER_HOTPLUG_PRI	100
+#define KSM_CALLBACK_PRI	100
 
 #ifndef CONFIG_MEMORY_HOTPLUG
 static inline void memory_dev_init(void)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 0c6db6a4f427..3ea2e836e93e 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -3647,7 +3647,7 @@ void __init cpuset_init_smp(void)
 	cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask);
 	top_cpuset.effective_mems = node_states[N_MEMORY];
 
-	hotplug_memory_notifier(cpuset_track_online_nodes, 10);
+	hotplug_memory_notifier(cpuset_track_online_nodes, CPUSET_CALLBACK_PRI);
 
 	cpuset_migrate_mm_wq = alloc_ordered_workqueue("cpuset_migrate_mm", 0);
 	BUG_ON(!cpuset_migrate_mm_wq);
diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c
index 0e3648b603a6..2fba1f51f042 100644
--- a/mm/kasan/shadow.c
+++ b/mm/kasan/shadow.c
@@ -244,7 +244,7 @@ static int __meminit kasan_mem_notifier(struct notifier_block *nb,
 
 static int __init kasan_memhotplug_init(void)
 {
-	hotplug_memory_notifier(kasan_mem_notifier, 0);
+	hotplug_memory_notifier(kasan_mem_notifier, DEFAULT_CALLBACK_PRI);
 
 	return 0;
 }
diff --git a/mm/ksm.c b/mm/ksm.c
index c19fcca9bc03..7ba97f86d831 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -3211,7 +3211,7 @@ static int __init ksm_init(void)
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
 	/* There is no significance to this priority 100 */
-	hotplug_memory_notifier(ksm_memory_callback, 100);
+	hotplug_memory_notifier(ksm_memory_callback, KSM_CALLBACK_PRI);
 #endif
 	return 0;
 
diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c
index 33673ed9b3dc..212c4a81fe47 100644
--- a/mm/memory-tiers.c
+++ b/mm/memory-tiers.c
@@ -709,7 +709,7 @@ static int __init memory_tier_init(void)
 	establish_demotion_targets();
 	mutex_unlock(&memory_tier_lock);
 
-	hotplug_memory_notifier(memtier_hotplug_callback, MEMTIER_HOTPLUG_PRIO);
+	hotplug_memory_notifier(memtier_hotplug_callback, MEMTIER_HOTPLUG_PRI);
 	return 0;
 }
 subsys_initcall(memory_tier_init);
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 44aadc162d1f..c1883362e71d 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -181,7 +181,7 @@ static int __meminit mm_compute_batch_notifier(struct notifier_block *self,
 static int __init mm_compute_batch_init(void)
 {
 	mm_compute_batch(sysctl_overcommit_memory);
-	hotplug_memory_notifier(mm_compute_batch_notifier, IPC_CALLBACK_PRI);
+	hotplug_memory_notifier(mm_compute_batch_notifier, MM_COMPUTE_BATCH_PRI);
 	return 0;
 }
 
diff --git a/mm/mmap.c b/mm/mmap.c
index 5a217378a62a..0fde397963f8 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3747,7 +3747,7 @@ static int reserve_mem_notifier(struct notifier_block *nb,
 
 static int __meminit init_reserve_notifier(void)
 {
-	if (hotplug_memory_notifier(reserve_mem_notifier, 0))
+	if (hotplug_memory_notifier(reserve_mem_notifier, DEFAULT_CALLBACK_PRI))
 		pr_err("Failed registering memory add/remove notifier for admin reserve\n");
 
 	return 0;
diff --git a/mm/page_ext.c b/mm/page_ext.c
index affe80243b6d..b2ff5c9129f4 100644
--- a/mm/page_ext.c
+++ b/mm/page_ext.c
@@ -513,7 +513,7 @@ void __init page_ext_init(void)
 			cond_resched();
 		}
 	}
-	hotplug_memory_notifier(page_ext_callback, 0);
+	hotplug_memory_notifier(page_ext_callback, DEFAULT_CALLBACK_PRI);
 	pr_info("allocated %ld bytes of page_ext\n", total_usage);
 	invoke_init_callbacks();
 	return;
-- 
2.25.1


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

* Re: [PATCH v3 1/8] cgroup/cpuset: use hotplug_memory_notifier() directly
  2022-09-22 14:18 ` [PATCH v3 1/8] cgroup/cpuset: use hotplug_memory_notifier() directly Liu Shixin
@ 2022-09-22 17:56   ` David Hildenbrand
  2022-09-23  1:56     ` Liu Shixin
  0 siblings, 1 reply; 11+ messages in thread
From: David Hildenbrand @ 2022-09-22 17:56 UTC (permalink / raw)
  To: Liu Shixin, Andrew Morton, Waiman Long, Zefan Li, Christoph Lameter
  Cc: linux-mm, linux-kernel, Kefeng Wang

On 22.09.22 16:18, Liu Shixin wrote:
> Since patch 316346243be6 has already updated the minimum gcc version to 5.1.
> The previous problem mentioned in patch f02c69680088 is not existed. So we
> can now revert to use hotplug_memory_notifier() directly rather than
> register_hotmemory_notifier().
> 
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
>   kernel/cgroup/cpuset.c | 7 +------
>   1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index b474289c15b8..0c6db6a4f427 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -3630,11 +3630,6 @@ static int cpuset_track_online_nodes(struct notifier_block *self,
>   	return NOTIFY_OK;
>   }
>   
> -static struct notifier_block cpuset_track_online_nodes_nb = {
> -	.notifier_call = cpuset_track_online_nodes,
> -	.priority = 10,		/* ??! */
> -};
> -
>   /**
>    * cpuset_init_smp - initialize cpus_allowed
>    *
> @@ -3652,7 +3647,7 @@ void __init cpuset_init_smp(void)
>   	cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask);
>   	top_cpuset.effective_mems = node_states[N_MEMORY];
>   
> -	register_hotmemory_notifier(&cpuset_track_online_nodes_nb);
> +	hotplug_memory_notifier(cpuset_track_online_nodes, 10);
>   
>   	cpuset_migrate_mm_wq = alloc_ordered_workqueue("cpuset_migrate_mm", 0);
>   	BUG_ON(!cpuset_migrate_mm_wq);


Please don't drop Reviewed-by or Acked-by tags. Otherwise reviewers have 
no clue which patch they already reviewed -- and they always have little 
time ;)

-- 
Thanks,

David / dhildenb


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

* Re: [PATCH v3 1/8] cgroup/cpuset: use hotplug_memory_notifier() directly
  2022-09-22 17:56   ` David Hildenbrand
@ 2022-09-23  1:56     ` Liu Shixin
  0 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-23  1:56 UTC (permalink / raw)
  To: David Hildenbrand, Andrew Morton, Waiman Long, Zefan Li,
	Christoph Lameter
  Cc: linux-mm, linux-kernel, Kefeng Wang



On 2022/9/23 1:56, David Hildenbrand wrote:
> On 22.09.22 16:18, Liu Shixin wrote:
>> Since patch 316346243be6 has already updated the minimum gcc version to 5.1.
>> The previous problem mentioned in patch f02c69680088 is not existed. So we
>> can now revert to use hotplug_memory_notifier() directly rather than
>> register_hotmemory_notifier().
>>
>> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
>> ---
>>   kernel/cgroup/cpuset.c | 7 +------
>>   1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index b474289c15b8..0c6db6a4f427 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -3630,11 +3630,6 @@ static int cpuset_track_online_nodes(struct notifier_block *self,
>>       return NOTIFY_OK;
>>   }
>>   -static struct notifier_block cpuset_track_online_nodes_nb = {
>> -    .notifier_call = cpuset_track_online_nodes,
>> -    .priority = 10,        /* ??! */
>> -};
>> -
>>   /**
>>    * cpuset_init_smp - initialize cpus_allowed
>>    *
>> @@ -3652,7 +3647,7 @@ void __init cpuset_init_smp(void)
>>       cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask);
>>       top_cpuset.effective_mems = node_states[N_MEMORY];
>>   -    register_hotmemory_notifier(&cpuset_track_online_nodes_nb);
>> +    hotplug_memory_notifier(cpuset_track_online_nodes, 10);
>>         cpuset_migrate_mm_wq = alloc_ordered_workqueue("cpuset_migrate_mm", 0);
>>       BUG_ON(!cpuset_migrate_mm_wq);
>
>
> Please don't drop Reviewed-by or Acked-by tags. Otherwise reviewers have no clue which patch they already reviewed -- and they always have little time ;)
>
Thanks for your reminder, I'll keep it in mind.


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

end of thread, other threads:[~2022-09-23  1:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 14:18 [PATCH v3 0/8] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier() Liu Shixin
2022-09-22 14:18 ` [PATCH v3 1/8] cgroup/cpuset: use hotplug_memory_notifier() directly Liu Shixin
2022-09-22 17:56   ` David Hildenbrand
2022-09-23  1:56     ` Liu Shixin
2022-09-22 14:18 ` [PATCH v3 2/8] fs/proc/kcore.c: " Liu Shixin
2022-09-22 14:18 ` [PATCH v3 3/8] mm/slub.c: " Liu Shixin
2022-09-22 14:19 ` [PATCH v3 4/8] mm/mmap: " Liu Shixin
2022-09-22 14:19 ` [PATCH v3 5/8] mm/mm_init.c: " Liu Shixin
2022-09-22 14:19 ` [PATCH v3 6/8] ACPI: HMAT: " Liu Shixin
2022-09-22 14:19 ` [PATCH v3 7/8] memory: remove unused register_hotmemory_notifier() Liu Shixin
2022-09-22 14:19 ` [PATCH v3 8/8] memory: move hotplug memory notifier priority to same file for easy sorting Liu Shixin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.