Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2492897rwn; Fri, 9 Sep 2022 14:54:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR4z46cZtoEdqpNtL51hw8WiGqJe69oHbGb2v57ZeYUcfkfS/V94hmUqqSOyuGMbygwfESO2 X-Received: by 2002:a17:90b:1d0e:b0:202:809c:2d70 with SMTP id on14-20020a17090b1d0e00b00202809c2d70mr7200868pjb.14.1662760483077; Fri, 09 Sep 2022 14:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662760483; cv=none; d=google.com; s=arc-20160816; b=uJLm8Rb0kofHlf4uvSE96e762u3yuNFJwGLH2Rl5/mH9SHb2NghprzELHEg8oiLuWW ppcGgbAK6N3sl0Z5Z+IgGE4Qey8RCrucMAiAxXcVlAULqKuTTEJrvoN0/FW9m7/w/1GI 5wraPwaNeTp+x7kXwvxuy3fZy8VOtwzbV5xijPG4vSoKh6PoC++h16Mdc26MRUZmAom7 6+cuHhKEb1Y0/vON4BdWBvY5/PE+lrATBS09aBqvlZ7fJKddbwGS1VhjQxLdfTjD5Zu1 v8LERP1bfXSnluQSut40WlIu6of7UF/SvN2jLuKTp+QWNkj6ZXJ+zlp85vn0NEauxjEz bdvw== 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:subject:cc:to:from:date :dkim-signature; bh=uXV8mT9zE4GhxuVpDrjmJSWWoaUz3zmDHXS7C4WCstc=; b=jjlKbgI1u+GFQwj7HBdVfonSJiF3nPXB4vgcnxngz/PqZbJtVf1nbWDyrJfHLcURrs DtOWEikYZ3hEcK3vB3EqvTfBxdLbU3htD9M7Ri4A57bEo2c0ayYSjSkfieD0+wGiBqiW vwNylfJ4v7YOhDkJQri3IoVgVaDbl+oyFw0lT5ZR0Hauopl4SCOIBvrvTYnTQgbsVBC4 z4SkR4F0T0HXMKHAP+71HtktHJ3Ufnq3TnH3g7UzJWZVP/Wq3LlyLKcAz2zYhTJIiUwM kT+Df5mmRmnixWHx3s5OSp1hAkoEVJNZY7VzXi2PrrwhMkJOP7IECQBNGxlML39Y++Dd bZ+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=MBWJF+Ae; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170902d50500b00176deb65d6csi1773212plg.414.2022.09.09.14.54.32; Fri, 09 Sep 2022 14:54:43 -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=@linux-foundation.org header.s=korg header.b=MBWJF+Ae; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbiIIVxN (ORCPT + 99 others); Fri, 9 Sep 2022 17:53:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbiIIVxL (ORCPT ); Fri, 9 Sep 2022 17:53:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0AB870E57; Fri, 9 Sep 2022 14:53:10 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 6A3CC61FF5; Fri, 9 Sep 2022 21:53:10 +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 X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, 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 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.