]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
memory: move hotplug memory notifier priority to same file for easy sorting
authorLiu Shixin <liushixin2@huawei.com>
Fri, 23 Sep 2022 03:33:47 +0000 (11:33 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 9 Nov 2022 01:37:17 +0000 (17:37 -0800)
The priority of hotplug memory callback is defined in a different file.
And there are some callers using numbers directly.  Collect them together
into include/linux/memory.h for easy reading.  This allows us to sort
their priorities more intuitively without additional comments.

Link: https://lkml.kernel.org/r/20220923033347.3935160-9-liushixin2@huawei.com
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Waiman Long <longman@redhat.com>
Cc: zefan li <lizefan.x@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/acpi/numa/hmat.c
fs/proc/kcore.c
include/linux/memory-tiers.h
include/linux/memory.h
kernel/cgroup/cpuset.c
mm/kasan/shadow.c
mm/ksm.c
mm/memory-tiers.c
mm/mm_init.c
mm/mmap.c
mm/page_ext.c

index 0ecefb6047348612482d184be688195dbda5900c..139e3b41653e50d68eb0a115a71cff09807f58b4 100644 (file)
@@ -849,7 +849,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();
index 7692a360972d31cc5841086dc2165737255dad92..98f3289556e4a1776e107720847333b8ec893936 100644 (file)
@@ -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;
 }
index 965009aa01d72b73c66d046a0ff4816e376e852b..fc9647b1b4f96a9392727cfdb3d95c11b31441cd 100644 (file)
@@ -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 {
index 98d2a2ebcc10b7a569d2351b4059f8a902aed4e7..463662ef761423984925f1a185259dc7735d47c2 100644 (file)
@@ -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)
index 0c6db6a4f4274a4a2a1a47ea59fdd06eeefe61be..3ea2e836e93eba39541f0f2ea1c3831119d94284 100644 (file)
@@ -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);
index 0e3648b603a6fc190dc75ea1bfb842b0c6ba3b86..2fba1f51f042eaf49ee7fd8b5f4af37211a27bb2 100644 (file)
@@ -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;
 }
index c19fcca9bc03dcd9511486000c6cadb11d724c29..7ba97f86d8316496086077f1ebe1f70f492b14e2 100644 (file)
--- 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;
 
index fa8c9d07f9ce97ec552d5f6c14e9d9ce4cde100e..939e200c283bbb313056b9c8479a20bfd04f6154 100644 (file)
@@ -664,7 +664,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);
index 44aadc162d1f0425c4719e43f3bacf8d7b7ac88c..c1883362e71d2eb59d1dbe96c3ee81a3710ec2f6 100644 (file)
@@ -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;
 }
 
index 3f47fd57d16540f7e8a0c000d5e76f9e26601a64..c697771d406b71c246d89af285d336bf3b930610 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3751,7 +3751,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;
index affe80243b6d66bdc4a7fb75f575177c7e839c36..b2ff5c9129f47c09690e2fb98ee05b06b95d181c 100644 (file)
@@ -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;