[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220413144748.84106-4-songmuchun@bytedance.com>
Date: Wed, 13 Apr 2022 22:47:47 +0800
From: Muchun Song <songmuchun@...edance.com>
To: corbet@....net, mike.kravetz@...cle.com, akpm@...ux-foundation.org,
mcgrof@...nel.org, keescook@...omium.org, yzaikin@...gle.com,
osalvador@...e.de, david@...hat.com, masahiroy@...nel.org
Cc: linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, duanxiongchun@...edance.com, smuchun@...il.com,
Muchun Song <songmuchun@...edance.com>
Subject: [PATCH v8 3/4] mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing
Use kstrtobool rather than open coding "on" and "off" parsing in
mm/hugetlb_vmemmap.c, which is more powerful to handle all kinds
of parameters like 'Yy1Nn0' or [oO][NnFf] for "on" and "off".
Signed-off-by: Muchun Song <songmuchun@...edance.com>
---
Documentation/admin-guide/kernel-parameters.txt | 6 +++---
mm/hugetlb_vmemmap.c | 10 +++++-----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index f3cf9f21f6eb..6ea428023d51 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1669,10 +1669,10 @@
enabled.
Allows heavy hugetlb users to free up some more
memory (7 * PAGE_SIZE for each 2MB hugetlb page).
- Format: { on | off (default) }
+ Format: { [oO][Nn]/Y/y/1 | [oO][Ff]/N/n/0 (default) }
- on: enable the feature
- off: disable the feature
+ [oO][Nn]/Y/y/1: enable the feature
+ [oO][Ff]/N/n/0: disable the feature
Built with CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON=y,
the default is on.
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index be73782cc1cf..4b6a5cf16f11 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -195,15 +195,15 @@ EXPORT_SYMBOL(hugetlb_optimize_vmemmap_key);
static int __init hugetlb_vmemmap_early_param(char *buf)
{
- if (!buf)
+ bool enable;
+
+ if (kstrtobool(buf, &enable))
return -EINVAL;
- if (!strcmp(buf, "on"))
+ if (enable)
static_branch_enable(&hugetlb_optimize_vmemmap_key);
- else if (!strcmp(buf, "off"))
- static_branch_disable(&hugetlb_optimize_vmemmap_key);
else
- return -EINVAL;
+ static_branch_disable(&hugetlb_optimize_vmemmap_key);
return 0;
}
--
2.11.0
Powered by blists - more mailing lists