From patchwork Wed Apr 13 14:47:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12812098 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 63A1DC433F5 for ; Wed, 13 Apr 2022 14:48:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E749D6B0078; Wed, 13 Apr 2022 10:48:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E22676B007B; Wed, 13 Apr 2022 10:48:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9CF06B007D; Wed, 13 Apr 2022 10:48:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id BC0D56B0078 for ; Wed, 13 Apr 2022 10:48:47 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8D2EA21A8A for ; Wed, 13 Apr 2022 14:48:47 +0000 (UTC) X-FDA: 79352137494.17.94E2AAD Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf31.hostedemail.com (Postfix) with ESMTP id 22FA220006 for ; Wed, 13 Apr 2022 14:48:46 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id c12so2167974plr.6 for ; Wed, 13 Apr 2022 07:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EfqzshiMxPgqo91bqRrogKECfyK/4BP/Cl7KQelj6Dg=; b=yKhiAYWaSOYJQwBNVwtujizWquYP4rI6ZlWZ1+KiSkaey8GNgzlk7/TSAQbLtl65q4 k0IUUazxHJMIdN3CJ/ARThnVKC1EdJUA8kR16DeUTkejbuH5jXQ10dSsciIzfDeeLad6 imdw0nic9VVQdddcq7k1pvPAP8ytBSdWAePW1rmKZUqnsDOzJEo4cz1i1L7ChnejwQAK 4fTQuEz4UgoboV1lUUtJkndrq7ssp/8DvFy/umR9lzeiffegqFV/wyLDDpcX0x9Ev5kD xoxy59LZX+TOoDoT4sQz1CK2pXdhVzNMZcuxupQZWhrkMX8aZOvAbGXxQGg4AxXyExKu oMUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EfqzshiMxPgqo91bqRrogKECfyK/4BP/Cl7KQelj6Dg=; b=3h938HKbD/5OKdNylDNxEq69FNeqH7//D5OyapD/TtMPA+ELIKXCLSXXnXx5RpQOfT dYnU/d3PLsgZBrCosUS4xoKYEeSD7ykWRjWXk7UU0+TesQtpZzQXiGF15am1fie3FuwK 2QiSDs6ApKUAbD7st+eRIWA3GEZGNVqf257VHx+yz8b15q8DoBzJHLtZldQQmcbd8xeV hwu58kTb+zf9UG1tpGshKFkOEOx8EXWFXSyuGBGo+f5n1fc5iqxhLS8E275R/UqPiTGK NP5CuEVFINi6UYr+3kQm6OlXIth97GEO5yonzaJSHZSOP6RIdRVewxDVuIFQCY22pwpt vVTw== X-Gm-Message-State: AOAM530aQpEOsF6bJjcXaDtFNhybFvUr/kKQIZqUTJfHPusTGjZ6akus DlLQ5FRRHCnShMpulRD6Txr/IA== X-Google-Smtp-Source: ABdhPJw9+0J/Pv1eSXmSk5scRsk+PgJb9qJVP7Gb0TeMWiDl/M3OE9EtQ9tF40Ia+6ctpIzKdiHd1Q== X-Received: by 2002:a17:90b:3b8c:b0:1c6:ed78:67e2 with SMTP id pc12-20020a17090b3b8c00b001c6ed7867e2mr11221387pjb.163.1649861326236; Wed, 13 Apr 2022 07:48:46 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id p27-20020a056a000a1b00b004f3f63e3cf2sm47817257pfh.58.2022.04.13.07.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 07:48:45 -0700 (PDT) From: Muchun Song To: corbet@lwn.net, mike.kravetz@oracle.com, akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, osalvador@suse.de, david@redhat.com, masahiroy@kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com, Muchun Song Subject: [PATCH v8 3/4] mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing Date: Wed, 13 Apr 2022 22:47:47 +0800 Message-Id: <20220413144748.84106-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220413144748.84106-1-songmuchun@bytedance.com> References: <20220413144748.84106-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 418bde63egc97immwcezue6ndkaowehd Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=yKhiAYWa; spf=pass (imf31.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 22FA220006 X-HE-Tag: 1649861326-589251 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: 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 --- 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; }