aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuchun Song <[email protected]>2022-05-13 16:48:56 -0700
committerAndrew Morton <[email protected]>2022-05-13 16:48:56 -0700
commit9c54c522bb76cbef480722bd44059e2ba8304bd2 (patch)
treed1a731e63a4fd6c06f86e33bb57608a335e6d106
parent6e02c46b4d970f24eb51197d451b00f08a8a4186 (diff)
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". Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Muchun Song <[email protected]> Reviewed-by: Mike Kravetz <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Iurii Zaikin <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Kees Cook <[email protected]> Cc: Luis Chamberlain <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Xiongchun Duan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt6
-rw-r--r--mm/hugetlb_vmemmap.c10
2 files changed, 8 insertions, 8 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index d9b577db6e19..7e079b6994fe 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1664,10 +1664,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 6254bb2d4ae5..cc4ec752ec16 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -28,15 +28,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;
}