Skip to content

Commit 4e9b08a

Browse files
osalvadorvilardagajaywang-amazon
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]> (cherry picked from commit e3a9d9f)
1 parent 2c8a412 commit 4e9b08a

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
@@ -2862,6 +2862,23 @@
28622862
seconds. Use this parameter to check at some
28632863
other rate. 0 disables periodic checking.
28642864

2865+
memory_hotplug.memmap_on_memory
2866+
[KNL,X86,ARM] Boolean flag to enable this feature.
2867+
Format: {on | off (default)}
2868+
When enabled, runtime hotplugged memory will
2869+
allocate its internal metadata (struct pages)
2870+
from the hotadded memory which will allow to
2871+
hotadd a lot of memory without requiring
2872+
additional memory to do so.
2873+
This feature is disabled by default because it
2874+
has some implication on large (e.g. GB)
2875+
allocations in some configurations (e.g. small
2876+
memory blocks).
2877+
The state of the flag can be read in
2878+
/sys/module/memory_hotplug/parameters/memmap_on_memory.
2879+
Note that even when enabled, there are a few cases where
2880+
the feature is not effective.
2881+
28652882
memtest= [KNL,X86,ARM,PPC] Enable memtest
28662883
Format: <integer>
28672884
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
@@ -82,7 +86,6 @@ obj-$(CONFIG_SLAB) += slab.o
8286
obj-$(CONFIG_SLUB) += slub.o
8387
obj-$(CONFIG_KASAN) += kasan/
8488
obj-$(CONFIG_FAILSLAB) += failslab.o
85-
obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
8689
obj-$(CONFIG_MEMTEST) += memtest.o
8790
obj-$(CONFIG_MIGRATION) += migrate.o
8891
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)