From patchwork Fri Apr 29 12:18:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12831933 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 D1AD9C433FE for ; Fri, 29 Apr 2022 12:18:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67DA96B0075; Fri, 29 Apr 2022 08:18:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 606526B0078; Fri, 29 Apr 2022 08:18:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A6E46B007B; Fri, 29 Apr 2022 08:18:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 3B39A6B0075 for ; Fri, 29 Apr 2022 08:18:50 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 154C17B3 for ; Fri, 29 Apr 2022 12:18:50 +0000 (UTC) X-FDA: 79409820420.08.38329F9 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf10.hostedemail.com (Postfix) with ESMTP id CA4DDC006A for ; Fri, 29 Apr 2022 12:18:38 +0000 (UTC) Received: by mail-pl1-f179.google.com with SMTP id c23so7029268plo.0 for ; Fri, 29 Apr 2022 05:18:49 -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=TjSe9ss2+05m7bNnHnq06g/24z1s/6oiiRPfk3T645g=; b=V4zTolFkDRy+bEhCxQOBfvMydHiQ3SDhwpCdYR9LSjJYAgp4qwzEPoZTrrY1r+QnIR 5poY1Y5Q+CRau1IQNkm6BtRRdKx4KIxTNJmSyi/EcQhsHxzmoF94quYhEKljm34++Aio R92KIYGjemhsxaueyDuUq8u71R/hQL5lkSg0TB+CDKAFOkjRTE5M2grrgQgULjQcC/2F nH13a8tMufrBC96PWlBzBLLxuOJMRSco17kYWrm683IVcJs8VLct/BumiZWjOkn83+yz 5e49ckj0+KdIpb8CYtz1LTPXUd0rqFdymS2P1gDYe5ErW1f5PUyG68iP4l028mIezWJS 9Wjw== 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=TjSe9ss2+05m7bNnHnq06g/24z1s/6oiiRPfk3T645g=; b=tOOxCYMtpnj2FqN/UM3svgXUto9OUklGJyCHMmASiZFtS06QDjKhk5DqM5pzZAliJb 9VTvhUZ/X7eytbbaKi5+3SNoWqdvpHmB0VuUo8g46hV8ujmks1BpUqkPq21Mr6r6qhJ9 /CySGcYD8mhKDXZRLUI1VCd6JdTbVFdMWF/zLP2ear7RGClOOntCK2dhh8EOBP8+NRs0 j9gIg1v18Pf2HSaznTnGTp72YE9n0ZxPJcQiy6+1I9k0pkaAwJ9N4rH9EnAV62T7lMr6 ily5vx6WJzIZDoAvCf9JNu/ASx7YisamszRXtEdoJ7laR0EbIRYn1cCAesU0OH9uG33k 1FyA== X-Gm-Message-State: AOAM530T2pmeWGRviukV4itn0+VnW/KjJAz4R5es9dSRViOUt80Wp3HA fOvDrbYAh1Mwi1ZXGWi88hYopQ== X-Google-Smtp-Source: ABdhPJx1iBA5oFoann5/gl9fGdgcEAPAYUM965dVZhzsaPjPjJkZI/6OtjdgqxpK9Cr3f72bhF+Rfw== X-Received: by 2002:a17:903:2352:b0:15e:5aad:af5c with SMTP id c18-20020a170903235200b0015e5aadaf5cmr9612588plh.116.1651234728764; Fri, 29 Apr 2022 05:18:48 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id k11-20020a056a00168b00b004f7e1555538sm3101421pfc.190.2022.04.29.05.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 05:18:48 -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 v9 3/4] mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing Date: Fri, 29 Apr 2022 20:18:15 +0800 Message-Id: <20220429121816.37541-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220429121816.37541-1-songmuchun@bytedance.com> References: <20220429121816.37541-1-songmuchun@bytedance.com> MIME-Version: 1.0 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=V4zTolFk; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CA4DDC006A X-Rspam-User: X-Stat-Signature: fagizeu8wrw6ot9y43tfnjr6okkcqyb1 X-HE-Tag: 1651234718-332869 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 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) } - 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; }