Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6201404rwn; Mon, 12 Sep 2022 23:56:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4yYdcdzxm20+NFagxlKW4JsAIOZ7STucY9P1k7k3CQTwHzABw9iAbqDSXJqVf+zTgPUEkI X-Received: by 2002:a17:902:d18c:b0:178:292b:a89f with SMTP id m12-20020a170902d18c00b00178292ba89fmr11517611plb.85.1663052187700; Mon, 12 Sep 2022 23:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663052187; cv=none; d=google.com; s=arc-20160816; b=iypZ/VYpf1KUGETsQYVaOt1h0whW+uJc7gxDuqdh4ZjZIGlrinId21NTB5S/bx1jMe 4uAmCr2XxwQEGpoeNAME7HiilMXWrzOKnaTcT8PKzx1yZ4y9+YctLfh8hUPJ5a47QC7x XfevN1vKJHI1fImg8jQENBgb/UlXQU3o9zLf75od/SWk84yws8WixHBa/VUpodiT7Zt4 QOk3+8DnFMTy20ZvQkAPeySBcg7wlmjiLV+XhTzZF78XU8WXyQhq7MKrcrJ6y4UrvR2I TaDcb7eOcJGkioRxDd7AirdFBgH+sUTQGIFLJg9g2L9lQE7Lt/ZzMekngvdISROd558l ODGg== 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; bh=rpdQOqW7WS7CSivCm3PE1Vl3r5E52BzeMh3xFhKPyNM=; b=ik1xx36944WJyNuQgfU9QjwkCYVun2zoKUzbHlYuiKe6etzmKhcMtDnfeDH/wQPgTh wh14Y/hC9UqQH6uPNgo7Y3RfhwbppzvZueRfiD+RwmtU77gGYP7jdkb3nTeNx1H0idI8 jBrKrvkGJwpndNHl8zAa00M53nmzzX+Fhx/Tin/hMiyuvw6aPIMs1nsLutf2H8Fdi1+Q T1135uwnCXk3VImnpHcD+s+5Mv127B9T5hOBMW+kA6/N8cyEPnQsmTuHEubU2CvwK4vI 7oQnTpqk189ekZ9S781reePQOX/81VKQXXKekC362AMhIq47HYr8nhSquy0S2bINYbV0 2xmw== ARC-Authentication-Results: i=1; mx.google.com; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x23-20020a170902821700b0016d5cfc6fd8si11090946pln.32.2022.09.12.23.56.16; Mon, 12 Sep 2022 23:56:27 -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; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230442AbiIMGkl (ORCPT + 99 others); Tue, 13 Sep 2022 02:40:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230374AbiIMGke (ORCPT ); Tue, 13 Sep 2022 02:40:34 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAD6852818; Mon, 12 Sep 2022 23:40:32 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MRYd70VbLzNm90; Tue, 13 Sep 2022 14:35:55 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 13 Sep 2022 14:40:29 +0800 Received: from huawei.com (10.175.113.32) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 13 Sep 2022 14:40:29 +0800 From: Liu Shixin To: Andrew Morton CC: Jonathan Corbet , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , , , , , Liu Shixin , "Kefeng Wang" Subject: [PATCH v3] mm/memcontrol: use kstrtobool for swapaccount param parsing Date: Tue, 13 Sep 2022 15:13:58 +0800 Message-ID: <20220913071358.1812206-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220909145308.f2f61d6992f00ef6977f833b@linux-foundation.org> References: <20220909145308.f2f61d6992f00ef6977f833b@linux-foundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 which is more powerful to handle all kinds of parameters like 'Yy1Nn0' or [oO][NnFf] for "on" and "off". Signed-off-by: Liu Shixin --- mm/memcontrol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 0a1a8a846870..5511c0c120d9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7434,10 +7434,10 @@ bool mem_cgroup_swap_full(struct folio *folio) static int __init setup_swap_account(char *s) { - if (!strcmp(s, "1")) - cgroup_memory_noswap = false; - else if (!strcmp(s, "0")) - cgroup_memory_noswap = true; + bool res; + + if (!kstrtobool(s, &res)) + cgroup_memory_noswap = !res; return 1; } __setup("swapaccount=", setup_swap_account); -- 2.25.1