Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3014203iob; Mon, 16 May 2022 11:05:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKpbSM1ceeDn/MKpHsFQ4AjyS34LvqvYhpFsMt3s70x/oLeaqkNgjEubA/gprxlwnpGASw X-Received: by 2002:a17:907:7f2a:b0:6f4:a358:c826 with SMTP id qf42-20020a1709077f2a00b006f4a358c826mr16254384ejc.404.1652724301470; Mon, 16 May 2022 11:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652724301; cv=none; d=google.com; s=arc-20160816; b=Ptb8cqWbL4qLBZuT/eM0bkTasxmgrGMrtWrBwcTEInuwTRJr4nr6vX6XJVgC9TKgop whx/IKH4Xlmjp+nVL9+RFy4+7IqNTYCaq+Q3/Dy0tZ/mwbKE0Tm+TjY67MQucod9/dEP RpLgyKnkWTPmXvNXOA5IjMniyEcT5474f8v2MF7VjpdUY4Rnsf5F/DUKEEcNbEwdM4WN lp0UKdboNHBOWf5imRI/PG7LpJG7D8Xrod3fvvgLp6B03uw7aS3RpRyFjHEj3jECKPzc RtzqKqzOzgo+3ARg2VOwu3q5un/2a98V9KHPDRNYVpKvQiWlN4scO6bxjBM676ez6BwE Ib+A== 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=D8MT2hpyVq6RWkeIwFsjJwgP64ytBP9yS8NMgw6YICA=; b=Bp9jMJmunbd3U4EwVNZHhdqUISI5dfHciBJSHTOk1cQ2vFmwjQYWT6HtCBV8jCA9sx 5xWYp8vV0hCyI1xk45LNr0zcLE40vzts4RSCBpi+SCw/wOpZPVeQAstx+xuWsPBcdttS NVzZiJaAWXgpzzwKElDvKMhFpIzbePj4ul1vRKqmQRo1hiio7Wj7mBhOvFP/WYMMnrn3 8WMa6KkaMRUjWEG4wPAnsW3SgpGgLRXGT2wfphoDnKPFAF6m/MLMHqTtqblLAWRHwqhr zpnM36w0DNkyBi0XQVdiAVA3o54yYQ9wF1YMkus9D7rzXQiGzXy01Y10BVqtkFWdfTK3 ynIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=DKzSkynx; 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 sc35-20020a1709078a2300b006f3cfd2c84esi60901ejc.298.2022.05.16.11.04.32; Mon, 16 May 2022 11:05:01 -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=DKzSkynx; 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 S242504AbiEPKXn (ORCPT + 99 others); Mon, 16 May 2022 06:23:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242613AbiEPKXT (ORCPT ); Mon, 16 May 2022 06:23:19 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4C5CE0F7 for ; Mon, 16 May 2022 03:23:14 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id ev18so3388724pjb.4 for ; Mon, 16 May 2022 03:23:14 -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=D8MT2hpyVq6RWkeIwFsjJwgP64ytBP9yS8NMgw6YICA=; b=DKzSkynxZeLrta+Y2p0gffzxOvDJHI6t71Uy+/CZImu1BPgayQiPvNudLg0SLSTZkt Iz3qrv0fn288Qp21h6fbFOz8USa18tIo14smiheLi0oCVsNIHFk+tJa2ZKSa0md5EZCA 0nNfAbv6x1RYJeT+AV3KT70HHMy+yge+s//u83DSm0wixBgz3c2xSlyD7pugDiOCHEWE XNfpWYPPjjLLFuH7Qlkq5rfxrOtMyd78/tMd1E9Iqr+NZsrcAn+Z67mFnouHnpcieUwi LQXcgkYH+L+SUToJfKGzYoULwqtHtBziNZcsFbRv1ALDNkyJmfUFRvcnaSzyINGw2UI4 G2yw== 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=D8MT2hpyVq6RWkeIwFsjJwgP64ytBP9yS8NMgw6YICA=; b=2MpiLdhJi/TaH3oIQzRYUDQ51YYhdgeE+7cE0dKwK8ndBGaeA+shhgMMPgcACPCFkH B0fTTVM7A3a13okQ03KwLUBKIf60W1YKaVKtWx9JAoFNyqPwJT1BM+7L2g45rAqP/qwt t8rMErhpJ31f8aFkoiXSXwVkBDbR4k8PtVBx2C2lw04ciRgUNMPD6YNWJF61im/7DsVt 9nSGGZOusFwA7Kij9ozOAnWOL18bnf1YobFkwOA1R7+kVSlm/ghUy5e+fMJkhc+V8kZx L0Wls8zXpxjFuHYwc+gwrBIxDVw1LmBA7GiFwIjlLnLn6pUZW+bXXVsOpHVRvsPOxIuX zV6g== X-Gm-Message-State: AOAM531K6hKdDT/wpqJvxt6vNQANGtrP65wirmg3RyNJA9P30wL9SXzF RlWvDTWkAUCiUZXK3Uo8E4vr1Q== X-Received: by 2002:a17:90b:4d11:b0:1dc:ec4f:a19c with SMTP id mw17-20020a17090b4d1100b001dcec4fa19cmr29767454pjb.117.1652696594183; Mon, 16 May 2022 03:23:14 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id i9-20020aa79089000000b0050dc76281e4sm6472731pfa.190.2022.05.16.03.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:23:13 -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 v12 2/7] mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing Date: Mon, 16 May 2022 18:22:06 +0800 Message-Id: <20220516102211.41557-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220516102211.41557-1-songmuchun@bytedance.com> References: <20220516102211.41557-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=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 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 Acked-by: David Hildenbrand --- mm/hugetlb_vmemmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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