Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: introduce CONFIG_NUMA_MIGRATION and simplify CONFIG_MIGRATION

CONFIG_MEMORY_HOTREMOVE, CONFIG_COMPACTION and CONFIG_CMA all select
CONFIG_MIGRATION, because they require it to work (users).

Only CONFIG_NUMA_BALANCING and CONFIG_BALLOON_MIGRATION depend on
CONFIG_MIGRATION. CONFIG_BALLOON_MIGRATION is not an actual user, but an
implementation of migration support, so the dependency is correct
(CONFIG_BALLOON_MIGRATION does not make any sense without
CONFIG_MIGRATION).

However, kconfig-language.rst clearly states "In general use select only
for non-visible symbols". So far CONFIG_MIGRATION is user-visible ...
and the dependencies rather confusing.

The whole reason why CONFIG_MIGRATION is user-visible is because of
CONFIG_NUMA: some users might want CONFIG_NUMA but not page migration
support.

Let's clean all that up by introducing a dedicated CONFIG_NUMA_MIGRATION
config option for that purpose only. Make CONFIG_NUMA_BALANCING that so
far depended on CONFIG_NUMA && CONFIG_MIGRATION to depend on
CONFIG_MIGRATION instead. CONFIG_NUMA_MIGRATION will depend on
CONFIG_NUMA && CONFIG_MMU.

CONFIG_NUMA_MIGRATION is user-visible and will default to "y". We use
that default so new configs will automatically enable it, just like it was
the case with CONFIG_MIGRATION. The downside is that some configs that
used to have CONFIG_MIGRATION=n might get it re-enabled by
CONFIG_NUMA_MIGRATION=y, which shouldn't be a problem.

CONFIG_MIGRATION is now a non-visible config option. Any code that select
CONFIG_MIGRATION (as before) must depend directly or indirectly on
CONFIG_MMU.

CONFIG_NUMA_MIGRATION is responsible for any NUMA migration code, which is
mempolicy migration code, memory-tiering code, and move_pages() code in
migrate.c. CONFIG_NUMA_BALANCING uses its functionality.

Note that this implies that with CONFIG_NUMA_MIGRATION=n, move_pages()
will not be available even though CONFIG_MIGRATION=y, which is an expected
change.

In migrate.c, we can remove the CONFIG_NUMA check as both
CONFIG_NUMA_MIGRATION and CONFIG_NUMA_BALANCING depend on it.

With this change, CONFIG_MIGRATION is an internal config, all users of
migration selects CONFIG_MIGRATION, and only CONFIG_BALLOON_MIGRATION
depends on it.

Link: https://lkml.kernel.org/r/20260319-config_migration-v1-2-42270124966f@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand (Arm) and committed by
Andrew Morton
6ebf98d7 078f80f9

+23 -24
+1 -1
include/linux/memory-tiers.h
··· 52 52 struct memory_dev_type *mt_find_alloc_memory_type(int adist, 53 53 struct list_head *memory_types); 54 54 void mt_put_memory_types(struct list_head *memory_types); 55 - #ifdef CONFIG_MIGRATION 55 + #ifdef CONFIG_NUMA_MIGRATION 56 56 int next_demotion_node(int node, const nodemask_t *allowed_mask); 57 57 void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets); 58 58 bool node_is_toptier(int node);
+1 -1
init/Kconfig
··· 997 997 bool "Memory placement aware NUMA scheduler" 998 998 depends on ARCH_SUPPORTS_NUMA_BALANCING 999 999 depends on !ARCH_WANT_NUMA_VARIABLE_LOCALITY 1000 - depends on SMP && NUMA && MIGRATION && !PREEMPT_RT 1000 + depends on SMP && NUMA_MIGRATION && !PREEMPT_RT 1001 1001 help 1002 1002 This option adds support for automatic NUMA aware memory/task placement. 1003 1003 The mechanism is quite primitive and is based on migrating memory when
+12 -12
mm/Kconfig
··· 627 627 those pages to another entity, such as a hypervisor, so that the 628 628 memory can be freed within the host for other uses. 629 629 630 - # 631 - # support for page migration 632 - # 633 - config MIGRATION 634 - bool "Page migration" 630 + config NUMA_MIGRATION 631 + bool "NUMA page migration" 635 632 default y 636 - depends on (NUMA || MEMORY_HOTREMOVE || COMPACTION || CMA) && MMU 633 + depends on NUMA && MMU 634 + select MIGRATION 637 635 help 638 - Allows the migration of the physical location of pages of processes 639 - while the virtual addresses are not changed. This is useful in 640 - two situations. The first is on NUMA systems to put pages nearer 641 - to the processors accessing. The second is when allocating huge 642 - pages as migration can relocate pages to satisfy a huge page 643 - allocation instead of reclaiming. 636 + Support the migration of pages to other NUMA nodes, available to 637 + user space through interfaces like migrate_pages(), move_pages(), 638 + and mbind(). Selecting this option also enables support for page 639 + demotion for memory tiering. 640 + 641 + config MIGRATION 642 + bool 643 + depends on MMU 644 644 645 645 config DEVICE_MIGRATION 646 646 def_bool MIGRATION && ZONE_DEVICE
+6 -6
mm/memory-tiers.c
··· 69 69 } 70 70 #endif 71 71 72 - #ifdef CONFIG_MIGRATION 72 + #ifdef CONFIG_NUMA_MIGRATION 73 73 static int top_tier_adistance; 74 74 /* 75 75 * node_demotion[] examples: ··· 129 129 * 130 130 */ 131 131 static struct demotion_nodes *node_demotion __read_mostly; 132 - #endif /* CONFIG_MIGRATION */ 132 + #endif /* CONFIG_NUMA_MIGRATION */ 133 133 134 134 static BLOCKING_NOTIFIER_HEAD(mt_adistance_algorithms); 135 135 ··· 273 273 lockdep_is_held(&memory_tier_lock)); 274 274 } 275 275 276 - #ifdef CONFIG_MIGRATION 276 + #ifdef CONFIG_NUMA_MIGRATION 277 277 bool node_is_toptier(int node) 278 278 { 279 279 bool toptier; ··· 519 519 520 520 #else 521 521 static inline void establish_demotion_targets(void) {} 522 - #endif /* CONFIG_MIGRATION */ 522 + #endif /* CONFIG_NUMA_MIGRATION */ 523 523 524 524 static inline void __init_node_memory_type(int node, struct memory_dev_type *memtype) 525 525 { ··· 911 911 if (ret) 912 912 panic("%s() failed to register memory tier subsystem\n", __func__); 913 913 914 - #ifdef CONFIG_MIGRATION 914 + #ifdef CONFIG_NUMA_MIGRATION 915 915 node_demotion = kzalloc_objs(struct demotion_nodes, nr_node_ids); 916 916 WARN_ON(!node_demotion); 917 917 #endif ··· 938 938 939 939 bool numa_demotion_enabled = false; 940 940 941 - #ifdef CONFIG_MIGRATION 941 + #ifdef CONFIG_NUMA_MIGRATION 942 942 #ifdef CONFIG_SYSFS 943 943 static ssize_t demotion_enabled_show(struct kobject *kobj, 944 944 struct kobj_attribute *attr, char *buf)
+1 -1
mm/mempolicy.c
··· 1239 1239 return err; 1240 1240 } 1241 1241 1242 - #ifdef CONFIG_MIGRATION 1242 + #ifdef CONFIG_NUMA_MIGRATION 1243 1243 static bool migrate_folio_add(struct folio *folio, struct list_head *foliolist, 1244 1244 unsigned long flags) 1245 1245 {
+2 -3
mm/migrate.c
··· 2222 2222 return __folio_alloc(gfp_mask, order, nid, mtc->nmask); 2223 2223 } 2224 2224 2225 - #ifdef CONFIG_NUMA 2226 - 2225 + #ifdef CONFIG_NUMA_MIGRATION 2227 2226 static int store_status(int __user *status, int start, int value, int nr) 2228 2227 { 2229 2228 while (nr-- > 0) { ··· 2621 2622 { 2622 2623 return kernel_move_pages(pid, nr_pages, pages, nodes, status, flags); 2623 2624 } 2625 + #endif /* CONFIG_NUMA_MIGRATION */ 2624 2626 2625 2627 #ifdef CONFIG_NUMA_BALANCING 2626 2628 /* ··· 2764 2764 return nr_remaining ? -EAGAIN : 0; 2765 2765 } 2766 2766 #endif /* CONFIG_NUMA_BALANCING */ 2767 - #endif /* CONFIG_NUMA */