Skip to content

Commit

Permalink
mm: hugetlb: introduce CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON
Browse files Browse the repository at this point in the history
When using HUGETLB_PAGE_FREE_VMEMMAP, the freeing unused vmemmap pages
associated with each HugeTLB page is default off.  Now the vmemmap is PMD
mapped.  So there is no side effect when this feature is enabled with no
HugeTLB pages in the system.  Someone may want to enable this feature in
the compiler time instead of using boot command line.  So add a config to
make it default on when someone do not want to enable it via command line.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Muchun Song <[email protected]>
Cc: Chen Huang <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Mike Kravetz <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: Xiongchun Duan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Muchun Song authored and torvalds committed Jul 1, 2021
1 parent 2d7a217 commit e6d41f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Documentation/admin-guide/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,9 @@
on: enable the feature
off: disable the feature

Built with CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON=y,
the default is on.

This is not compatible with memory_hotplug.memmap_on_memory.
If both parameters are enabled, hugetlb_free_vmemmap takes
precedence over memory_hotplug.memmap_on_memory.
Expand Down
10 changes: 10 additions & 0 deletions fs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ config HUGETLB_PAGE_FREE_VMEMMAP
depends on X86_64
depends on SPARSEMEM_VMEMMAP

config HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON
bool "Default freeing vmemmap pages of HugeTLB to on"
default n
depends on HUGETLB_PAGE_FREE_VMEMMAP
help
When using HUGETLB_PAGE_FREE_VMEMMAP, the freeing unused vmemmap
pages associated with each HugeTLB page is default off. Say Y here
to enable freeing vmemmap pages of HugeTLB by default. It can then
be disabled on the command line via hugetlb_free_vmemmap=off.

config MEMFD_CREATE
def_bool TMPFS || HUGETLBFS

Expand Down
6 changes: 4 additions & 2 deletions mm/hugetlb_vmemmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
#define RESERVE_VMEMMAP_NR 2U
#define RESERVE_VMEMMAP_SIZE (RESERVE_VMEMMAP_NR << PAGE_SHIFT)

bool hugetlb_free_vmemmap_enabled;
bool hugetlb_free_vmemmap_enabled = IS_ENABLED(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON);

static int __init early_hugetlb_free_vmemmap_param(char *buf)
{
Expand All @@ -197,7 +197,9 @@ static int __init early_hugetlb_free_vmemmap_param(char *buf)

if (!strcmp(buf, "on"))
hugetlb_free_vmemmap_enabled = true;
else if (strcmp(buf, "off"))
else if (!strcmp(buf, "off"))
hugetlb_free_vmemmap_enabled = false;
else
return -EINVAL;

return 0;
Expand Down

0 comments on commit e6d41f1

Please sign in to comment.