2022-09-19 08:35:47

by Liu Shixin

[permalink] [raw]
Subject: [PATCH 0/9] mm: Use hotplug_memory_notifier() instead of register_hotmemory_notifier()

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

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

Liu Shixin (9):
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: replace IPC_CALLBACK_PRI with MM_BATCH_CALLBACK_PRI
memory: clean up hotplug memory callback priority

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/mm_init.c | 8 +-------
mm/mmap.c | 6 +-----
mm/page_ext.c | 2 +-
mm/slub.c | 7 +------
11 files changed, 16 insertions(+), 48 deletions(-)

--
2.25.1


2022-09-19 08:46:00

by Liu Shixin

[permalink] [raw]
Subject: [PATCH 8/9] memory: replace IPC_CALLBACK_PRI with MM_BATCH_CALLBACK_PRI

Since there is nothing to do with ipc, it is strange to use IPC_CALLBACK_PRI
here. Replace IPC_CALLBACK_PRI with MM_BATCH_CALLBACK_PRI for easy reading.

Signed-off-by: Liu Shixin <[email protected]>
---
include/linux/memory.h | 4 ++--
mm/mm_init.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/memory.h b/include/linux/memory.h
index 98d2a2ebcc10..e5f71d3d9af8 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -112,8 +112,8 @@ 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 SLAB_CALLBACK_PRI 1
+#define MM_BATCH_CALLBACK_PRI 10

#ifndef CONFIG_MEMORY_HOTPLUG
static inline void memory_dev_init(void)
diff --git a/mm/mm_init.c b/mm/mm_init.c
index ec6989fcf762..30381cae9688 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_BATCH_CALLBACK_PRI);
return 0;
}

--
2.25.1

2022-09-19 08:46:20

by Liu Shixin

[permalink] [raw]
Subject: [PATCH 1/9] cgroup/cpuset: use hotplug_memory_notifier() directly

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 <[email protected]>
---
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