On 10/6/21 9:39 AM, Randy Dunlap wrote: >>>> ../mm/migrate.c:3216:22: error: 'migrate_on_reclaim_callback' defined >>>> but not used [-Werror=unused-function] >>>> static int __meminit migrate_on_reclaim_callback(struct >>>> notifier_block >>>> *self, >>>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~ >>>> ../mm/migrate.c:3197:13: error: 'set_migration_target_nodes' defined >>>> but >>>> not used [-Werror=unused-function] >>>> static void set_migration_target_nodes(void) >>>> ^~~~~~~~~~~~~~~~~~~~~~~~~~ >>>> >>>> >>>> (example usage to get the randconfig files: >>>> KCONFIG_SEED=0xBFBEA13C make [ARCH=x86_64] randconfig >>>> ) Randy, thanks for the .config! That did the trick. Andrew, attached is a replacement patch for mm-migrate-add-cpu-hotplug-to-demotion-ifdef.patch I could do an incremental as well if that would be easier. But, the fix here required a bit of a change of tactics from the original and necessitated a rewrite of the changelog.
Subject: [PATCH] mm/migrate: separate CPU and memory hotplug notifiers Date: Wed, 6 Oct 2021 11:08:46 -0700 Message-ID: <20211006180846.3321352-1-dave.hansen@xxxxxxxxx> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924161255.E5FE8F7E@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> References: <20210924161255.E5FE8F7E@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> From: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> Once upon a time, the node demotion updates were driven solely by memory hotplug events. But now, there are handlers for both CPU and memory hotplug. However, the #ifdef around the code checks only memory hotplug. A system that has HOTPLUG_CPU=y but MEMORY_HOTPLUG=n would miss CPU hotplug events. Update the #ifdef around the common code. Add memory and CPU-specific option are off. Move some CPU-hotplug-specific functions to reside under their specific #ifdef. Link: https://lkml.kernel.org/r/20210924161255.E5FE8F7E@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx Fixes: 884a6e5d1f93 ("mm/migrate: update node demotion order on hotplug events") Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> Cc: "Huang, Ying" <ying.huang@xxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Wei Xu <weixugc@xxxxxxxxxx> Cc: Oscar Salvador <osalvador@xxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Greg Thelen <gthelen@xxxxxxxxxx> Cc: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx> Cc: Randy Dunlap <rdunlap@xxxxxxxxxxxxx> --- mm/migrate.c | 78 +++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index a6311e46f605..5282157575ba 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -3066,7 +3066,7 @@ void migrate_vma_finalize(struct migrate_vma *migrate) EXPORT_SYMBOL(migrate_vma_finalize); #endif /* CONFIG_DEVICE_PRIVATE */ -#if defined(CONFIG_MEMORY_HOTPLUG) +#if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_HOTPLUG_CPU) /* Disable reclaim-based migration. */ static void __disable_all_migrate_targets(void) { @@ -3198,35 +3198,7 @@ static void __set_migration_target_nodes(void) goto again; } -/* - * For callers that do not hold get_online_mems() already. - */ -static void set_migration_target_nodes(void) -{ - get_online_mems(); - __set_migration_target_nodes(); - put_online_mems(); -} - -/* - * React to hotplug events that might affect the migration targets - * like events that online or offline NUMA nodes. - * - * The ordering is also currently dependent on which nodes have - * CPUs. That means we need CPU on/offline notification too. - */ -static int migration_online_cpu(unsigned int cpu) -{ - set_migration_target_nodes(); - return 0; -} - -static int migration_offline_cpu(unsigned int cpu) -{ - set_migration_target_nodes(); - return 0; -} - +#if defined(CONFIG_MEMORY_HOTPLUG) /* * This leaves migrate-on-reclaim transiently disabled between * the MEM_GOING_OFFLINE and MEM_OFFLINE events. This runs @@ -3284,7 +3256,45 @@ static int __meminit migrate_on_reclaim_callback(struct notifier_block *self, return notifier_from_errno(0); } -static int __init migrate_on_reclaim_init(void) +static int __init migrate_on_reclaim_init_memhp(void) +{ + hotplug_memory_notifier(migrate_on_reclaim_callback, 100); + return 0; +} +late_initcall(migrate_on_reclaim_init_memhp); +#endif /* CONFIG_MEMORY_HOTPLUG */ + +#ifdef CONFIG_HOTPLUG_CPU +/* + * For callers that do not hold get_online_mems() already. + */ +static void set_migration_target_nodes(void) +{ + get_online_mems(); + __set_migration_target_nodes(); + put_online_mems(); +} + +/* + * React to hotplug events that might affect the migration targets + * like events that online or offline NUMA nodes. + * + * The ordering is also currently dependent on which nodes have + * CPUs. That means we need CPU on/offline notification too. + */ +static int migration_online_cpu(unsigned int cpu) +{ + set_migration_target_nodes(); + return 0; +} + +static int migration_offline_cpu(unsigned int cpu) +{ + set_migration_target_nodes(); + return 0; +} + +static int __init migrate_on_reclaim_init_cpuhp(void) { int ret; @@ -3299,8 +3309,8 @@ static int __init migrate_on_reclaim_init(void) */ WARN_ON(ret < 0); - hotplug_memory_notifier(migrate_on_reclaim_callback, 100); return 0; } -late_initcall(migrate_on_reclaim_init); -#endif /* CONFIG_MEMORY_HOTPLUG */ +late_initcall(migrate_on_reclaim_init_cpuhp); +#endif /* CONFIG_HOTPLUG_CPU */ +#endif /* CONFIG_MEMORY_HOTPLUG || CONFIG_HOTPLUG_CPU */ -- 2.25.1