From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DF93C433EF for ; Thu, 12 May 2022 07:41:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 628C78D0001; Thu, 12 May 2022 03:41:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D63A6B0075; Thu, 12 May 2022 03:41:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 476748D0001; Thu, 12 May 2022 03:41:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3827A6B0074 for ; Thu, 12 May 2022 03:41:28 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 08C711202C2 for ; Thu, 12 May 2022 07:41:28 +0000 (UTC) X-FDA: 79456295856.19.6504678 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 39776400B5 for ; Thu, 12 May 2022 07:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652341286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UB9mU9YOUuvmjC8HW/bQVlMThaY/Mp776ejEpkktyQo=; b=i65773aabni4OObF0q/Kx9dkwtSI32dX8QCqpCEqbvjMV28iADNSF2T6eSe70eqnhavAuS 00V6dGuEyt3ihIpCu1d3FwSjTwWrvXKC+hxwY12j/Cxy4G0wrx3IaJCLV7vFJl6xnwz15e JEIcTPNhG1jzSFD3Ob1Im9l5Ooimiys= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-dxwv8lU4NzuByzPdv1BheA-1; Thu, 12 May 2022 03:41:25 -0400 X-MC-Unique: dxwv8lU4NzuByzPdv1BheA-1 Received: by mail-wr1-f70.google.com with SMTP id j21-20020adfa555000000b0020adb9ac14fso1728324wrb.13 for ; Thu, 12 May 2022 00:41:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=UB9mU9YOUuvmjC8HW/bQVlMThaY/Mp776ejEpkktyQo=; b=2MAzN/TjJIV42pAJMDu6YRLl6Isyz2rrHlvk39tr40iSylCqu+qkVxWag31xrs1M2w pQIVHR9q4FU3/d/7K2/KqNoYf6kflpnCqJV8aaWOxVYTpdeqHpSThCVGaZOASCU1eNGh PaN4t8H0r9PNyeRcPWx5cDt7RceicAcfTEW06IiVPARG2WxZS/AX6saWFKYrhyfcTAZG fk1p/H2MKB2qltPS051tfZgrlaCBVeQYayOIoqIEYAeA9R/6+TkolhuX0o4Md2HVzQGu k3OGXgCe2bo1mUVRIq9fGKXi2CFgz5M/CjKSQ8gT/9yamYa6tGND5IU4Rl+FBwirpN2O dv/A== X-Gm-Message-State: AOAM531Ty/yBv8W6UMXFxKQuVLN83eg4niAAn8WIiKNZuS8BFvKd4Me2 pcTsU2LQlMcrlUw/oAQgSxmzlM2AeRZAG+6KTsFed5koMQ4AHNYBiUyBbVN/3fd6GR0NcBv/TVZ Xmfp2AaxtVss= X-Received: by 2002:adf:cc82:0:b0:20a:cf3b:4624 with SMTP id p2-20020adfcc82000000b0020acf3b4624mr25667664wrj.573.1652341284517; Thu, 12 May 2022 00:41:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBjlod8MeuObO/DAktAps0EDmVeiibZR+PFFNEWdAxgv5/5LuDiW4y70u4NNJMfK7KQAGFgA== X-Received: by 2002:adf:cc82:0:b0:20a:cf3b:4624 with SMTP id p2-20020adfcc82000000b0020acf3b4624mr25667655wrj.573.1652341284263; Thu, 12 May 2022 00:41:24 -0700 (PDT) Received: from ?IPV6:2003:cb:c701:d200:ee5d:1275:f171:136d? (p200300cbc701d200ee5d1275f171136d.dip0.t-ipconnect.de. [2003:cb:c701:d200:ee5d:1275:f171:136d]) by smtp.gmail.com with ESMTPSA id y12-20020adff6cc000000b0020c5253d920sm3989255wrp.108.2022.05.12.00.41.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 May 2022 00:41:23 -0700 (PDT) Message-ID: <21aae898-d54d-cc4b-a11f-1bb7fddcfffa@redhat.com> Date: Thu, 12 May 2022 09:41:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v10 3/4] mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing To: Muchun Song , 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 Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com References: <20220509062703.64249-1-songmuchun@bytedance.com> <20220509062703.64249-4-songmuchun@bytedance.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220509062703.64249-4-songmuchun@bytedance.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 39776400B5 X-Stat-Signature: yyrgacemy7goxn3x4mn6s6hp4tpq5mzr X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i65773aa; spf=none (imf01.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam09 X-HE-Tag: 1652341275-941053 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. > > - 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, David / dhildenb