From mboxrd@z Thu Jan 1 00:00:00 1970 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 D5A36ECAAD3 for ; Fri, 9 Sep 2022 21:53:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E87258D0002; Fri, 9 Sep 2022 17:53:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E35698D0001; Fri, 9 Sep 2022 17:53:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D23C18D0002; Fri, 9 Sep 2022 17:53:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BF2B28D0001 for ; Fri, 9 Sep 2022 17:53:13 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 99435A0523 for ; Fri, 9 Sep 2022 21:53:13 +0000 (UTC) X-FDA: 79893898266.11.AAD8D01 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf24.hostedemail.com (Postfix) with ESMTP id 0FD3C1800AA for ; Fri, 9 Sep 2022 21:53:12 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2C091B82658; Fri, 9 Sep 2022 21:53:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58F78C433D6; Fri, 9 Sep 2022 21:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1662760389; bh=0JcE0DLdNzQm3AF+ZqlE39XNCX4d5bRLfNDfq0UT/g4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=MBWJF+Ae7WdYf68cBxuz+A7rZmgFkpzsf5z3e0zEWKuLYcSLhPtI2YV1SGKHOY3oC Luy2cPNFoakNi7qC+zQaeo5I81q7yZDg3ogVrDFGH9CAIvXo278uOnjET+AEwkAjdl j/pOtTVmax8W40oStXD8ZsmUhesodTnlrMEBtlAM= Date: Fri, 9 Sep 2022 14:53:08 -0700 From: Andrew Morton To: Liu Shixin Cc: Jonathan Corbet , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , , , , , Kefeng Wang Subject: Re: [PATCH v2] mm/memcontrol: use kstrtobool for swapaccount param parsing Message-Id: <20220909145308.f2f61d6992f00ef6977f833b@linux-foundation.org> In-Reply-To: <20220909084647.3598299-1-liushixin2@huawei.com> References: <20220909084647.3598299-1-liushixin2@huawei.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662760393; a=rsa-sha256; cv=none; b=hIUIFxUOT7uV9rFHf65fIo+DLZSHhKkM4siU42GFPBTyqEnQJm0zsAmRe4BdvTGqqA+pbU 9fywiddFg5Ki2bnH5oR4HhIE23j5drlupYoLH5Wrwzt+QznXerLobSjwVHwodrrSivzhuj oT1omk30MtFIaYAEOqAJCHVeawVb1/0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=MBWJF+Ae; dmarc=none; spf=pass (imf24.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662760393; 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:dkim-signature; bh=uXV8mT9zE4GhxuVpDrjmJSWWoaUz3zmDHXS7C4WCstc=; b=2p/mT+nMQXPj3n+sCWWv3o88F13NVXWeKnGJ9d1CMnRrAxuoChG5NcZljMClSXRsJ44O71 educbsQRIIrk2QA1li/Qf0YdJ6Kwbzgx7OKKbaVyllmr1D/pnBoXklcyHEYg3wJ/cX3gz2 uuK68vzDCaY/dnYU3d8dSIAnCgXAG0o= Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=MBWJF+Ae; dmarc=none; spf=pass (imf24.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspam-User: X-Rspamd-Queue-Id: 0FD3C1800AA X-Rspamd-Server: rspam11 X-Stat-Signature: ab1agh9b8zc7dhxudbi59sm13rd5i8m4 X-HE-Tag: 1662760392-652258 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: On Fri, 9 Sep 2022 16:46:47 +0800 Liu Shixin wrote: > Use kstrtobool which is more powerful to handle all kinds of parameters > like 'Yy1Nn0' or [oO][NnFf] for "on" and "off". > > ... > > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -6037,10 +6037,11 @@ > Execution Facility on pSeries. > > swapaccount= [KNL] > - Format: [0|1] > + Format: { [oO][Nn]/Y/y/1 | [oO][Ff]/N/n/0 } > Enable accounting of swap in memory resource > - controller if no parameter or 1 is given or disable > - it if 0 is given (See Documentation/admin-guide/cgroup-v1/memory.rst) > + controller if no parameter or [oO][Nn]/Y/y/1 is given > + or disable it if [oO][Ff]/N/n/0 is given > + (See Documentation/admin-guide/cgroup-v1/memory.rst) > > swiotlb= [ARM,IA-64,PPC,MIPS,X86] > Format: { [,] | force | noforce } mhocko suggested dropping this change as well. > 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); And I agree. See, the risk with this patch is that someone will develop userspace code which relies upon the new behaviour. Then when someone tries to use that code on an older kernel, whoops, it doesn't work. In other words, we're encouraging development of non-backward-compatible userspace code. Leaving the documentation as it was (just "0|1") will help to prevent that situation.