2022-05-16 18:05:01

by Muchun Song

[permalink] [raw]
Subject: [PATCH v12 2/7] 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 <[email protected]>
Reviewed-by: Mike Kravetz <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
---
mm/hugetlb_vmemmap.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

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;
}
--
2.11.0



2022-05-17 09:40:36

by Oscar Salvador

[permalink] [raw]
Subject: Re: [PATCH v12 2/7] mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing

On Mon, May 16, 2022 at 06:22:06PM +0800, Muchun Song wrote:
> 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 <[email protected]>
> Reviewed-by: Mike Kravetz <[email protected]>
> Acked-by: David Hildenbrand <[email protected]>

Reviewed-by: Oscar Salvador <[email protected]>


--
Oscar Salvador
SUSE Labs