Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1003589iob; Thu, 12 May 2022 09:05:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDwBU2jYyCCjnBozc8EiBsG1KiAROEwTjsOcePacBtK8/hHwmlhORoteYsBsCxTJ50ziL4 X-Received: by 2002:a17:907:6d85:b0:6fa:80ea:7565 with SMTP id sb5-20020a1709076d8500b006fa80ea7565mr531908ejc.395.1652371512185; Thu, 12 May 2022 09:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652371512; cv=none; d=google.com; s=arc-20160816; b=qqYFTRQeH4KyN07Oh3YefB2pRmD62GyOszFkVVdfoqMZSPRz1Mne2TMVYt1OfwMKrV 6bc/0HyTKUmXkFR5NJxTfv6JwHagTa5rMg0uT+oSzMX/4kipVtPrI5bh4P9mjsd7TueQ OVmScNdrA5nvgm3j87wHTRWX2pCR30iL4gDcfjGemGP0QH4qxhljfJzYA+oeXjoDoPUY zL4Aw7+Vif9YVnYMLiFezTVRMeQP+4vYENEEPZ43kmSU8Gkj0RBgTXeOYInpOb9l21Kt HFcmTHjT9hc1ha2qsPEsC42EYNskdd1hHL2BYg/FS6K8D9Tj0ZnVE3/HNS/e84Lk+laU wLbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MZUxzSSA16jHPMfnNIZTNFIVQ87TLhFgxWJeE4kOIcw=; b=XXX8JvWQH5OcFc469DZ6wNXwptpb343r1Iwjs0X6XpFapeq1LXrfEUGo6VIg4D0G6T 8Nf1QcdvA6yi9/J+QUwJZH0mIpVWNXtOkN12O3tILUVvQK0jRE1Yb8izkv4OZTOfuEJl IVV4Jm3je0Agb3s0NO5l22g9eY7zoabr+bQW94sAYUJLWOJf4t1drn7+MY6yU/vTDZz/ 6qVve199DDtOukVbrHoedF6DY4gqR4K53FEb7jxvV4tJfRwT1aRXCAcRTzgG8NCV5MpZ +vmFVMzl4P39Zi0pZ8M9z1ajSEjXMT0F+q/68E8UFhiFp+nz/RMsC4L3cRszlnwuDowZ agKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=NVvHhWxD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k17-20020a50c091000000b004259921b23asi5997418edf.405.2022.05.12.09.04.45; Thu, 12 May 2022 09:05:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=NVvHhWxD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232103AbiELLYn (ORCPT + 99 others); Thu, 12 May 2022 07:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353318AbiELLYd (ORCPT ); Thu, 12 May 2022 07:24:33 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D34755F8C8 for ; Thu, 12 May 2022 04:24:02 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id n10so4855061pjh.5 for ; Thu, 12 May 2022 04:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MZUxzSSA16jHPMfnNIZTNFIVQ87TLhFgxWJeE4kOIcw=; b=NVvHhWxDmgEveY5XgTLMjhIN/WeC0dzORtcZU3yCriRugu10mhKnK39HtzfAbTtN2o iTVG1JQXh2n/X+jJAU4pj0uySBGDeX2s2D+lpkjOrWSfKfhn7Li5DghUPhuszF+nwR0F VT2gwv11WrI1YC/ZgMVbvCXz/JjHJkQBVijSWSGx+f01HGzThnuMDodZg1Zy34ZxB8Vb l/dz8CCbvhk1RsxOldgZRAxNnNZ9Y1JGkLSnSWPcwhvU8TWBNiL05dTLFK1VgEpig6In SkTeNFO2cYNJivVnR9WfdodW2GCkT4hEY/rBMOAeRJRIJlxkALKvur8dnFx7gAeqDsa5 XGCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MZUxzSSA16jHPMfnNIZTNFIVQ87TLhFgxWJeE4kOIcw=; b=bg30KZNK+iCQnAaloSXs20rMzdeaajxC8dp55WLm2ZWqLoZicS9/qVqUjaY9GCmiXs Yy/SSM7ZfkH0BAVysO4P5PZFhaOmLcY1gXyqxZJLtp+lFDnXf45gISudvqnv6/1FuzI7 yYDRgGk8tVsJ5wtJp8Dth6z6bGnOFVuVvNbCvfGdnx9ktkSR54efOcqGse7xdlUyzOvf t4or5T/ODyhYMbv+z0t8gaQS/jKwoilX6a9Hud62KRjee7rAtq2DpEJX5NP/43nZPx9u WGRyZnXCZJa3PD/j9HHm6gN9+IasHcgdyHUjtqY/ntCoRUnPhnNMDXTrGtew6eAfzusF wARQ== X-Gm-Message-State: AOAM533XgijAb3zVIX82Ls46PXYTnRvE3epjX2wclRbKb0KnkHZAQ/9C A+VqiKQZozKs01wvhnNkxobCoA== X-Received: by 2002:a17:90a:4803:b0:1dc:b4c9:1958 with SMTP id a3-20020a17090a480300b001dcb4c91958mr10259315pjh.61.1652354642336; Thu, 12 May 2022 04:24:02 -0700 (PDT) Received: from localhost ([139.177.225.250]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0050dc76281cbsm3506108pfi.165.2022.05.12.04.24.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 04:24:01 -0700 (PDT) Date: Thu, 12 May 2022 19:23:49 +0800 From: Muchun Song To: David Hildenbrand Cc: corbet@lwn.net, mike.kravetz@oracle.com, akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, osalvador@suse.de, masahiroy@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com Subject: Re: [PATCH v10 3/4] mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing Message-ID: References: <20220509062703.64249-1-songmuchun@bytedance.com> <20220509062703.64249-4-songmuchun@bytedance.com> <21aae898-d54d-cc4b-a11f-1bb7fddcfffa@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21aae898-d54d-cc4b-a11f-1bb7fddcfffa@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 12, 2022 at 09:41:22AM +0200, David Hildenbrand wrote: > On 09.05.22 08:27, 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 > > Reviewed-by: Mike Kravetz > > --- > > 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 308da668bbb1..43b8385073ad 100644 > > --- a/Documentation/admin-guide/kernel-parameters.txt > > +++ b/Documentation/admin-guide/kernel-parameters.txt > > @@ -1703,10 +1703,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) } > > Really? Can we make the syntax even harder to parse for human beings?! :) > > Not to mention that it's partially wrong? What about "oFf" ? That would > have to be [oO][Ff][Ff] > > Honestly, "on | off" is good enough. That "oN" and friends work is just > a "nice to have" IMHO. No need to over-complicate this description. Got it. How about also telling users "on/1 | off/0"? Because 0 and 1 are also widely used to disable/enable a knob. > > > > - 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; > > } > > > Apart from that > > Acked-by: David Hildenbrand > Thanks. > -- > Thanks, > > David / dhildenb > >