From patchwork Tue Sep 13 07:13:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 12974465 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 2C2B6C6FA82 for ; Tue, 13 Sep 2022 06:40:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D2958D0001; Tue, 13 Sep 2022 02:40:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 882226B0074; Tue, 13 Sep 2022 02:40:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 770FC8D0001; Tue, 13 Sep 2022 02:40:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 65C876B0073 for ; Tue, 13 Sep 2022 02:40:41 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B02FE1A0EAF for ; Tue, 13 Sep 2022 06:40:34 +0000 (UTC) X-FDA: 79906113588.25.147B7AB Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf31.hostedemail.com (Postfix) with ESMTP id EA191200B4 for ; Tue, 13 Sep 2022 06:40:33 +0000 (UTC) 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 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663051234; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rpdQOqW7WS7CSivCm3PE1Vl3r5E52BzeMh3xFhKPyNM=; b=XEakjn0nWh0p51uZXZ2rW/MROLJWf0MOUF5heGhwVL1OrvRP0NlqXIu/Oo0FfSjElzRANU r2ZrCThqk70P6ap1dsVZX5kO63jkKPkv9sPJn7mD3tsYPjzNIPxp259r6C2BWBgYe6LrTi fgpcGj5spnlLEtiFD+0Qr3rxTCtH1nc= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf31.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663051234; a=rsa-sha256; cv=none; b=x3Bn+QJm1n5hRxqsS6SrmAF7P3At5chfzyBNW33R8/C47f2jZT6ZOe0DQB/S4tCkp7dXhX 8GsXX5Qy3hp8KxBaGwuTmgClMZEinh0ifKFN//WCrUgP+fkU0AvsjoU4FCimZaxHJVMWfO 2gTmwNqE1Y5Fruk3xldlnkXA8tYKqCY= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: EA191200B4 Authentication-Results: imf31.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf31.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com X-Stat-Signature: mft7959o7rkfo8hr8zmzpekhrepmuwy1 X-Rspam-User: X-HE-Tag: 1663051233-938559 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 which is more powerful to handle all kinds of parameters like 'Yy1Nn0' or [oO][NnFf] for "on" and "off". Signed-off-by: Liu Shixin Acked-by: Michal Hocko --- 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);