Skip to content

Commit e3a9d9f

Browse files
osalvadorvilardagatorvalds
authored andcommitted
mm,memory_hotplug: add kernel boot option to enable memmap_on_memory
Self stored memmap leads to a sparse memory situation which is unsuitable for workloads that requires large contiguous memory chunks, so make this an opt-in which needs to be explicitly enabled. To control this, let memory_hotplug have its own memory space, as suggested by David, so we can add memory_hotplug.memmap_on_memory parameter. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Oscar Salvador <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4a3e5de commit e3a9d9f

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,6 +2801,23 @@
28012801
seconds. Use this parameter to check at some
28022802
other rate. 0 disables periodic checking.
28032803

2804+
memory_hotplug.memmap_on_memory
2805+
[KNL,X86,ARM] Boolean flag to enable this feature.
2806+
Format: {on | off (default)}
2807+
When enabled, runtime hotplugged memory will
2808+
allocate its internal metadata (struct pages)
2809+
from the hotadded memory which will allow to
2810+
hotadd a lot of memory without requiring
2811+
additional memory to do so.
2812+
This feature is disabled by default because it
2813+
has some implication on large (e.g. GB)
2814+
allocations in some configurations (e.g. small
2815+
memory blocks).
2816+
The state of the flag can be read in
2817+
/sys/module/memory_hotplug/parameters/memmap_on_memory.
2818+
Note that even when enabled, there are a few cases where
2819+
the feature is not effective.
2820+
28042821
memtest= [KNL,X86,ARM,PPC] Enable memtest
28052822
Format: <integer>
28062823
default : 0 <disable>

mm/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \
5858
page-alloc-y := page_alloc.o
5959
page-alloc-$(CONFIG_SHUFFLE_PAGE_ALLOCATOR) += shuffle.o
6060

61+
# Give 'memory_hotplug' its own module-parameter namespace
62+
memory-hotplug-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
63+
6164
obj-y += page-alloc.o
6265
obj-y += init-mm.o
6366
obj-y += memblock.o
67+
obj-y += $(memory-hotplug-y)
6468

6569
ifdef CONFIG_MMU
6670
obj-$(CONFIG_ADVISE_SYSCALLS) += madvise.o
@@ -83,7 +87,6 @@ obj-$(CONFIG_SLUB) += slub.o
8387
obj-$(CONFIG_KASAN) += kasan/
8488
obj-$(CONFIG_KFENCE) += kfence/
8589
obj-$(CONFIG_FAILSLAB) += failslab.o
86-
obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
8790
obj-$(CONFIG_MEMTEST) += memtest.o
8891
obj-$(CONFIG_MIGRATION) += migrate.o
8992
obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += huge_memory.o khugepaged.o

mm/memory_hotplug.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@
4242
#include "internal.h"
4343
#include "shuffle.h"
4444

45-
static bool memmap_on_memory;
45+
46+
/*
47+
* memory_hotplug.memmap_on_memory parameter
48+
*/
49+
static bool memmap_on_memory __ro_after_init;
50+
#ifdef CONFIG_MHP_MEMMAP_ON_MEMORY
51+
module_param(memmap_on_memory, bool, 0444);
52+
MODULE_PARM_DESC(memmap_on_memory, "Enable memmap on memory for memory hotplug");
53+
#endif
4654

4755
/*
4856
* online_page_callback contains pointer to current page onlining function.

0 commit comments

Comments
 (0)