On Wed, Jul 17, 2019 at 10:42 PM Leonardo Bras <leonardo@xxxxxxxxxxxxx> wrote: > > Adds an option on kernel config to make hot-added memory online in > ZONE_MOVABLE by default. > > This would be great in systems with MEMORY_HOTPLUG_DEFAULT_ONLINE=y by > allowing to choose which zone it will be auto-onlined This is a desired feature. From reading the code it looks to me that auto-selection of online method type should be done in memory_subsys_online(). When it is called from device online, mem->online_type should be -1: if (mem->online_type < 0) mem->online_type = MMOP_ONLINE_KEEP; Change it to: if (mem->online_type < 0) mem->online_type = MMOP_DEFAULT_ONLINE_TYPE; And in "linux/memory_hotplug.h" #ifdef CONFIG_MEMORY_HOTPLUG_MOVABLE #define MMOP_DEFAULT_ONLINE_TYPE MMOP_ONLINE_MOVABLE #else #define MMOP_DEFAULT_ONLINE_TYPE MMOP_ONLINE_KEEP #endif Could be expanded to support MMOP_ONLINE_KERNEL as well. Pasha > > Signed-off-by: Leonardo Bras <leonardo@xxxxxxxxxxxxx> > --- > drivers/base/memory.c | 3 +++ > mm/Kconfig | 14 ++++++++++++++ > 2 files changed, 17 insertions(+) > > diff --git a/drivers/base/memory.c b/drivers/base/memory.c > index f180427e48f4..378b585785c1 100644 > --- a/drivers/base/memory.c > +++ b/drivers/base/memory.c > @@ -670,6 +670,9 @@ static int init_memory_block(struct memory_block **memory, > mem->state = state; > start_pfn = section_nr_to_pfn(mem->start_section_nr); > mem->phys_device = arch_get_memory_phys_device(start_pfn); > +#ifdef CONFIG_MEMORY_HOTPLUG_MOVABLE > + mem->online_type = MMOP_ONLINE_MOVABLE; > +#endif > > ret = register_memory(mem); > > diff --git a/mm/Kconfig b/mm/Kconfig > index f0c76ba47695..74e793720f43 100644 > --- a/mm/Kconfig > +++ b/mm/Kconfig > @@ -180,6 +180,20 @@ config MEMORY_HOTREMOVE > depends on MEMORY_HOTPLUG && ARCH_ENABLE_MEMORY_HOTREMOVE > depends on MIGRATION > > +config MEMORY_HOTPLUG_MOVABLE > + bool "Enhance the likelihood of hot-remove" > + depends on MEMORY_HOTREMOVE > + help > + This option sets the hot-added memory zone to MOVABLE which > + drastically reduces the chance of a hot-remove to fail due to > + unmovable memory segments. Kernel memory can't be allocated in > + this zone. > + > + Say Y here if you want to have better chance to hot-remove memory > + that have been previously hot-added. > + Say N here if you want to make all hot-added memory available to > + kernel space. > + > # Heavily threaded applications may benefit from splitting the mm-wide > # page_table_lock, so that faults on different parts of the user address > # space can be handled with less contention: split it at this NR_CPUS. > -- > 2.20.1 > On Wed, Jul 17, 2019 at 10:42 PM Leonardo Bras <leonardo@xxxxxxxxxxxxx> wrote: > > Adds an option on kernel config to make hot-added memory online in > ZONE_MOVABLE by default. > > This would be great in systems with MEMORY_HOTPLUG_DEFAULT_ONLINE=y by > allowing to choose which zone it will be auto-onlined > > Signed-off-by: Leonardo Bras <leonardo@xxxxxxxxxxxxx> > --- > drivers/base/memory.c | 3 +++ > mm/Kconfig | 14 ++++++++++++++ > 2 files changed, 17 insertions(+) > > diff --git a/drivers/base/memory.c b/drivers/base/memory.c > index f180427e48f4..378b585785c1 100644 > --- a/drivers/base/memory.c > +++ b/drivers/base/memory.c > @@ -670,6 +670,9 @@ static int init_memory_block(struct memory_block **memory, > mem->state = state; > start_pfn = section_nr_to_pfn(mem->start_section_nr); > mem->phys_device = arch_get_memory_phys_device(start_pfn); > +#ifdef CONFIG_MEMORY_HOTPLUG_MOVABLE > + mem->online_type = MMOP_ONLINE_MOVABLE; > +#endif > > ret = register_memory(mem); > > diff --git a/mm/Kconfig b/mm/Kconfig > index f0c76ba47695..74e793720f43 100644 > --- a/mm/Kconfig > +++ b/mm/Kconfig > @@ -180,6 +180,20 @@ config MEMORY_HOTREMOVE > depends on MEMORY_HOTPLUG && ARCH_ENABLE_MEMORY_HOTREMOVE > depends on MIGRATION > > +config MEMORY_HOTPLUG_MOVABLE > + bool "Enhance the likelihood of hot-remove" > + depends on MEMORY_HOTREMOVE > + help > + This option sets the hot-added memory zone to MOVABLE which > + drastically reduces the chance of a hot-remove to fail due to > + unmovable memory segments. Kernel memory can't be allocated in > + this zone. > + > + Say Y here if you want to have better chance to hot-remove memory > + that have been previously hot-added. > + Say N here if you want to make all hot-added memory available to > + kernel space. > + > # Heavily threaded applications may benefit from splitting the mm-wide > # page_table_lock, so that faults on different parts of the user address > # space can be handled with less contention: split it at this NR_CPUS. > -- > 2.20.1 >