[RFC,v3,4/4] mm,memory_hotplug: Add mhp_memmap_on_memory boot option
diff mbox series

Message ID 20201201115158.22638-5-osalvador@suse.de
State New, archived
Headers show
Series
  • Allocate memmap from hotadded memory (per device)
Related show

Commit Message

Oscar Salvador Dec. 1, 2020, 11:51 a.m. UTC
Self stored memmap leads to a sparse memory situation which is unsuitable
for workloads that requires large contiguous memory chunks.

Make this an opt-in which needs to be explicitly enabled.

Signed-off-by: Oscar Salvador <osalvador@suse.de>
---
 mm/memory_hotplug.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

David Hildenbrand Dec. 2, 2020, 9:42 a.m. UTC | #1
On 01.12.20 12:51, Oscar Salvador wrote:
> Self stored memmap leads to a sparse memory situation which is unsuitable
> for workloads that requires large contiguous memory chunks.
> 
> Make this an opt-in which needs to be explicitly enabled.
> 
> Signed-off-by: Oscar Salvador <osalvador@suse.de>
> ---
>  mm/memory_hotplug.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 4b4708512f82..858d6161e915 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -42,6 +42,8 @@
>  #include "internal.h"
>  #include "shuffle.h"
>  
> +static bool memmap_on_memory_enabled __read_mostly = false;
> +
>  /*
>   * online_page_callback contains pointer to current page onlining function.
>   * Initially it is generic_online_page(). If it is required it could be
> @@ -1034,7 +1036,7 @@ bool __weak arch_support_memmap_on_memory(void)
>  
>  bool mhp_supports_memmap_on_memory(unsigned long size)
>  {
> -	if (!arch_support_memmap_on_memory() ||
> +	if (!memmap_on_memory_enabled || !arch_support_memmap_on_memory() ||
>  	    !IS_ENABLED(CONFIG_SPARSEMEM_VMEMMAP) ||
>  	    size > memory_block_size_bytes())
>  		return false;
> @@ -1422,6 +1424,13 @@ static int __init cmdline_parse_movable_node(char *p)
>  }
>  early_param("movable_node", cmdline_parse_movable_node);
>  
> +static int __init cmdline_parse_memmap_on_memory(char *p)
> +{
> +	memmap_on_memory_enabled = true;
> +	return 0;
> +}
> +early_param("mhp_memmap_on_memory", cmdline_parse_memmap_on_memory);
> +
>  /* check which state of node_states will be changed when offline memory */
>  static void node_states_check_changes_offline(unsigned long nr_pages,
>  		struct zone *zone, struct memory_notify *arg)
> 

I have another memhp tunable in the works. I suggest doing it like
page_shuffling and using, module parameters instead. Makes this
a bit nicer IMHO.


diff --git a/mm/Makefile b/mm/Makefile
index 069f216e109e..ba7714b5eaa1 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -58,9 +58,13 @@ obj-y                        := filemap.o mempool.o oom_kill.o fadvise.o \
 page-alloc-y := page_alloc.o
 page-alloc-$(CONFIG_SHUFFLE_PAGE_ALLOCATOR) += shuffle.o
 
+# Give "memory_hotplug" its own module-parameter namespace
+memory-hotplug-$(CONFIG_MEMORY_HOTPLUG) := memory_hotplug.o
+
 obj-y += page-alloc.o
 obj-y += init-mm.o
 obj-y += memblock.o
+obj-y += $(memory-hotplug-y)
 
 ifdef CONFIG_MMU
        obj-$(CONFIG_ADVISE_SYSCALLS)   += madvise.o
@@ -82,7 +86,6 @@ obj-$(CONFIG_SLAB) += slab.o
 obj-$(CONFIG_SLUB) += slub.o
 obj-$(CONFIG_KASAN)    += kasan/
 obj-$(CONFIG_FAILSLAB) += failslab.o
-obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
 obj-$(CONFIG_MEMTEST)          += memtest.o
 obj-$(CONFIG_MIGRATION) += migrate.o
 obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += huge_memory.o khugepaged.o


The you can just use module_param/MODULE_PARM_DESC and set the parameter via

"memory_hotplug.memmap_on_memory"
Oscar Salvador Dec. 9, 2020, 10:02 a.m. UTC | #2
On Wed, Dec 02, 2020 at 10:42:18AM +0100, David Hildenbrand wrote:
> I have another memhp tunable in the works. I suggest doing it like
> page_shuffling and using, module parameters instead. Makes this
> a bit nicer IMHO.

Does that have any impact?

> diff --git a/mm/Makefile b/mm/Makefile
> index 069f216e109e..ba7714b5eaa1 100644
> --- a/mm/Makefile
> +++ b/mm/Makefile
> @@ -58,9 +58,13 @@ obj-y                        := filemap.o mempool.o oom_kill.o fadvise.o \
>  page-alloc-y := page_alloc.o
>  page-alloc-$(CONFIG_SHUFFLE_PAGE_ALLOCATOR) += shuffle.o
>  
> +# Give "memory_hotplug" its own module-parameter namespace
> +memory-hotplug-$(CONFIG_MEMORY_HOTPLUG) := memory_hotplug.o
> +
>  obj-y += page-alloc.o
>  obj-y += init-mm.o
>  obj-y += memblock.o
> +obj-y += $(memory-hotplug-y)
>  
>  ifdef CONFIG_MMU
>         obj-$(CONFIG_ADVISE_SYSCALLS)   += madvise.o
> @@ -82,7 +86,6 @@ obj-$(CONFIG_SLAB) += slab.o
>  obj-$(CONFIG_SLUB) += slub.o
>  obj-$(CONFIG_KASAN)    += kasan/
>  obj-$(CONFIG_FAILSLAB) += failslab.o
> -obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
>  obj-$(CONFIG_MEMTEST)          += memtest.o
>  obj-$(CONFIG_MIGRATION) += migrate.o
>  obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += huge_memory.o khugepaged.o
> 
> 
> The you can just use module_param/MODULE_PARM_DESC and set the parameter via
> 
> "memory_hotplug.memmap_on_memory"

I have to confess that I was not aware of this trick, but looks cleaner
overall.

Thanks
David Hildenbrand Dec. 9, 2020, 10:04 a.m. UTC | #3
On 09.12.20 11:02, Oscar Salvador wrote:
> On Wed, Dec 02, 2020 at 10:42:18AM +0100, David Hildenbrand wrote:
>> I have another memhp tunable in the works. I suggest doing it like
>> page_shuffling and using, module parameters instead. Makes this
>> a bit nicer IMHO.
> 
> Does that have any impact?

Not that I am aware of for our use case. You can inspect parameters via

/sys/modules/memory_hotplug/parameters/

then, and even change them (if allowed for a specific module parameters)

> 
>> diff --git a/mm/Makefile b/mm/Makefile
>> index 069f216e109e..ba7714b5eaa1 100644
>> --- a/mm/Makefile
>> +++ b/mm/Makefile
>> @@ -58,9 +58,13 @@ obj-y                        := filemap.o mempool.o oom_kill.o fadvise.o \
>>  page-alloc-y := page_alloc.o
>>  page-alloc-$(CONFIG_SHUFFLE_PAGE_ALLOCATOR) += shuffle.o
>>  
>> +# Give "memory_hotplug" its own module-parameter namespace
>> +memory-hotplug-$(CONFIG_MEMORY_HOTPLUG) := memory_hotplug.o
>> +
>>  obj-y += page-alloc.o
>>  obj-y += init-mm.o
>>  obj-y += memblock.o
>> +obj-y += $(memory-hotplug-y)
>>  
>>  ifdef CONFIG_MMU
>>         obj-$(CONFIG_ADVISE_SYSCALLS)   += madvise.o
>> @@ -82,7 +86,6 @@ obj-$(CONFIG_SLAB) += slab.o
>>  obj-$(CONFIG_SLUB) += slub.o
>>  obj-$(CONFIG_KASAN)    += kasan/
>>  obj-$(CONFIG_FAILSLAB) += failslab.o
>> -obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
>>  obj-$(CONFIG_MEMTEST)          += memtest.o
>>  obj-$(CONFIG_MIGRATION) += migrate.o
>>  obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += huge_memory.o khugepaged.o
>>
>>
>> The you can just use module_param/MODULE_PARM_DESC and set the parameter via
>>
>> "memory_hotplug.memmap_on_memory"
> 
> I have to confess that I was not aware of this trick, but looks cleaner
> overall.

Me neither before I spotted the page_alloc page_shuffling usage :)

Patch
diff mbox series

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 4b4708512f82..858d6161e915 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -42,6 +42,8 @@ 
 #include "internal.h"
 #include "shuffle.h"
 
+static bool memmap_on_memory_enabled __read_mostly = false;
+
 /*
  * online_page_callback contains pointer to current page onlining function.
  * Initially it is generic_online_page(). If it is required it could be
@@ -1034,7 +1036,7 @@  bool __weak arch_support_memmap_on_memory(void)
 
 bool mhp_supports_memmap_on_memory(unsigned long size)
 {
-	if (!arch_support_memmap_on_memory() ||
+	if (!memmap_on_memory_enabled || !arch_support_memmap_on_memory() ||
 	    !IS_ENABLED(CONFIG_SPARSEMEM_VMEMMAP) ||
 	    size > memory_block_size_bytes())
 		return false;
@@ -1422,6 +1424,13 @@  static int __init cmdline_parse_movable_node(char *p)
 }
 early_param("movable_node", cmdline_parse_movable_node);
 
+static int __init cmdline_parse_memmap_on_memory(char *p)
+{
+	memmap_on_memory_enabled = true;
+	return 0;
+}
+early_param("mhp_memmap_on_memory", cmdline_parse_memmap_on_memory);
+
 /* check which state of node_states will be changed when offline memory */
 static void node_states_check_changes_offline(unsigned long nr_pages,
 		struct zone *zone, struct memory_notify *arg)