From: Muchun Song <songmuchun@bytedance.com>
To: mike.kravetz@oracle.com, akpm@linux-foundation.org,
osalvador@suse.de, mhocko@suse.com, song.bao.hua@hisilicon.com,
david@redhat.com, chenhuang5@huawei.com, bodeddub@amazon.com,
corbet@lwn.net
Cc: duanxiongchun@bytedance.com, fam.zheng@bytedance.com,
zhengqi.arch@bytedance.com, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Muchun Song <songmuchun@bytedance.com>
Subject: [PATCH 5/5] mm: hugetlb: introduce CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON
Date: Wed, 9 Jun 2021 20:13:10 +0800 [thread overview]
Message-ID: <20210609121310.62229-6-songmuchun@bytedance.com> (raw)
In-Reply-To: <20210609121310.62229-1-songmuchun@bytedance.com>
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.
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
Documentation/admin-guide/kernel-parameters.txt | 3 +++
fs/Kconfig | 10 ++++++++++
mm/hugetlb_vmemmap.c | 6 ++++--
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index a01aadafee38..8eee439d943c 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1604,6 +1604,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.
diff --git a/fs/Kconfig b/fs/Kconfig
index f40b5b98f7ba..e78bc5daf7b0 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -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
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 01f3652fa359..b5f4f29e042a 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -186,7 +186,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)
{
@@ -201,7 +201,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;
--
2.11.0
next prev parent reply other threads:[~2021-06-09 12:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 12:13 [PATCH 0/5] Split huge PMD mapping of vmemmap pages Muchun Song
2021-06-09 12:13 ` [PATCH 1/5] mm: hugetlb: introduce helpers to preallocate/free page tables Muchun Song
2021-06-10 21:49 ` Mike Kravetz
2021-06-09 12:13 ` [PATCH 2/5] mm: hugetlb: introduce helpers to preallocate page tables from bootmem allocator Muchun Song
2021-06-10 22:13 ` Mike Kravetz
2021-06-09 12:13 ` [PATCH 3/5] mm: sparsemem: split the huge PMD mapping of vmemmap pages Muchun Song
2021-06-10 22:35 ` Mike Kravetz
2021-06-11 7:52 ` [External] " Muchun Song
2021-06-11 12:35 ` Muchun Song
2021-06-09 12:13 ` [PATCH 4/5] mm: sparsemem: use huge PMD mapping for " Muchun Song
2021-06-10 22:49 ` Mike Kravetz
2021-06-09 12:13 ` Muchun Song [this message]
2021-06-10 21:32 ` [PATCH 0/5] Split huge PMD mapping of " Mike Kravetz
2021-06-11 3:23 ` [External] " Muchun Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210609121310.62229-6-songmuchun@bytedance.com \
--to=songmuchun@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=bodeddub@amazon.com \
--cc=chenhuang5@huawei.com \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=duanxiongchun@bytedance.com \
--cc=fam.zheng@bytedance.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mike.kravetz@oracle.com \
--cc=osalvador@suse.de \
--cc=song.bao.hua@hisilicon.com \
--cc=zhengqi.arch@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.