Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp940759iob; Thu, 12 May 2022 07:53:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvbBodTS/r0v7TXAP/K9aAgFG/zgdTpygdd24jJ/XacwFUw2hJFYetcWzj3qjhTFhvSep+ X-Received: by 2002:a17:907:3f15:b0:6fc:30f0:6561 with SMTP id hq21-20020a1709073f1500b006fc30f06561mr211726ejc.691.1652367212345; Thu, 12 May 2022 07:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652367212; cv=none; d=google.com; s=arc-20160816; b=Zeu/SSJskoMC4mvgbMLR0KJY/U1tz4gnSLTpMdJNX3Eo39JnjRY8zgwZaOlXbXX1p8 jGDpP27FTK9i9/Cfi44FhSrRBbPwx6LrssAr2N3oy0yw2qKeHwFxqjHnZQC//0vAhDae 9+nRr2DxgOHth+gLvEujAguvqZb3MSfSQzch3LHzSx0qrtbWIHUU9nxCVxbja+e5YFxo 962bDf8k657nXdPyS3gmvfhVWroRC65vKFUE7bP4r1nrbK/U6baPZBYu4M9bj3r0OOPB k+J9Xar+tOGktErQ/BmqBO+bYJGn3OqIG0xYYnYaaBNH92hcBjDKTPTNj7q9ziIzF62N AxLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NyzkOphQ+s3WVfI9qZfbl6Rk93jtvh1L9Nek6U2DnhA=; b=0ehTSJUHKAnuuCLIRCInaAH2+BA8j/AmwiL8LBLs4ERRDlpQn3mPfQ7KPWH8bQQacz TEBVHZG/SDEWHRBpjFcbv8MaP2ZQar2Pn3ovE/eBDN8pwi23eiIiMostb67JZjWwV1ba oRDhrmvjoJ25tv7z4Je3jtKhpY28YV088A9E9hDT9rnpYgF9nvK0b+n2zffIN9IpYJfa htEjxgWxbez27qWqsofwsIXVbBEVnbO6aSkUociXlF6cv+xbN3NyBB01oW2Xll3LygF5 FTbI4ntggYf4ym8dXwpEo3IjihlyY2wAW7DeIYV5FmmWJDtEtQrsAcNHwVgwUkMB1OK7 5GqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=p+ZQF3x6; 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 gb6-20020a170907960600b006e88b6bf99dsi7154647ejc.80.2022.05.12.07.52.58; Thu, 12 May 2022 07:53:32 -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=p+ZQF3x6; 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 S240506AbiELEMg (ORCPT + 99 others); Thu, 12 May 2022 00:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346343AbiELEMa (ORCPT ); Thu, 12 May 2022 00:12:30 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6C281E6544 for ; Wed, 11 May 2022 21:12:26 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id i1so3747026plg.7 for ; Wed, 11 May 2022 21:12:26 -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=NyzkOphQ+s3WVfI9qZfbl6Rk93jtvh1L9Nek6U2DnhA=; b=p+ZQF3x6iL5RSb1SbGzvsDvcyOzZfgs8FP1VuBOzR3GQ2Bp2cHmaV0567sCajNEuUx YxPYubvCgJDElXCvfVkHCk2SwDdWBOJkDTprhtIn2l9fgF2zKsm5m/YvIZFBeNFBSk5U +f7WLIcOlXVmHcCtj00VV+jYYq/vWXbOFY1Q4BlrfOp61CKzZm7yHHnUVTkmVigBuJKs NUrdzNWcuxKACJ7kUGPYDFOu1sdGbL92heFH6oclrObrYbNezdyR7JHHgbZ8I0NkLgbG l4LgjRw6qyiDIBW7hyxyvhiJ9fiEMfsmxLaJSPqOZNSlzfEOvtTaQnDe7sBKnkPAsfCb qhrA== 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=NyzkOphQ+s3WVfI9qZfbl6Rk93jtvh1L9Nek6U2DnhA=; b=jmgh0lDSOmlaCptqbvye59hREQZhDcfX3BTKQKOqYKekPiyuPV0mGAtfiPt5/++XPN NB+qzhbrdii+eriGAmM2OniCsEWFGNBCM/+c+/3WUNcVAWP1akdK0oFynWT20wLX8uxu vaXlrpt8RQ0WsnI2pNEa4z7gbz+4goKRocIC56buwRlqn1nVa6wo4RTl2tWM+PY6dW0x 1qMDfRhNtcDIGbzkp5yvS5YK/56Q0oHqHSoIoCfrXgZKWC5UBzZPnOTOI38UoJA+Vb4j AyD1U8ZYyp01bSokzv5FCRJc4E4ghfzyGmWnWjnJQK0fqPiznndSJn/i7Mr+93je+YAJ q3nQ== X-Gm-Message-State: AOAM532llzAX0rHRU4Dt7UZ52uFy947XCph9wKo4w5LlZ+Vcy39rsnD2 asL509nXh9aud+kWSb/6qF4y+Q== X-Received: by 2002:a17:903:32c9:b0:15e:a1b8:c1ef with SMTP id i9-20020a17090332c900b0015ea1b8c1efmr28715136plr.173.1652328746333; Wed, 11 May 2022 21:12:26 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id q13-20020a170902edcd00b0015e8d4eb2dcsm2695161plk.294.2022.05.11.21.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 21:12:26 -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 v11 3/4] mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing Date: Thu, 12 May 2022 12:11:41 +0800 Message-Id: <20220512041142.39501-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220512041142.39501-1-songmuchun@bytedance.com> References: <20220512041142.39501-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=unavailable 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 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; } -- 2.11.0