Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4930649rdb; Tue, 12 Dec 2023 13:32:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjaDDdoDQURCQwRDDYkCbvE6mduR+0UKe2bPhscLDveTmzvDtnJeN2Ovy2ykboUvzZ52if X-Received: by 2002:a17:902:c944:b0:1d0:6ffd:9e20 with SMTP id i4-20020a170902c94400b001d06ffd9e20mr8577993pla.114.1702416767888; Tue, 12 Dec 2023 13:32:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702416767; cv=none; d=google.com; s=arc-20160816; b=0zkXn1OhY1Q8j78X3t/PW8KDJSi0RGeAuf4GkFh/8g92Oo1SYR2djL7ZmeMW2ar3YE 7XQLQxjqMmpbQ1w7A+sT7jAost3zt0S3cbQPnDgxMDhXOYXk9nEl8KphomP2pgfauZRO BwTOkZioD3GUCkCw9OaIPsOLY6Ux8i4/JunVJWxoiEsU/AbdSaK8Ex1S9DCD+Z7J5nEP T5wkqYLBAIN4DWpMruucu8rSvRfJtV3sOurZGtH9kEWICMGVtYh/ff05yKiTgaCqYOQl tW7LMaKnh3jsjOfYIhpT96OKN8AKFgh79k70OmDz9K8pOoqhpLeyQvV/BvWCdihcppzP wG4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=4L2LJb/M15SMHnS/E79/939MX48WMYq9e+QYyCDB9nI=; fh=r1iopxsbBSW+3jPykNRyW7VvuWvOIQ2QzkyZWjoYS20=; b=D8a3ngEpAKB9qvXMsLBh4COjGBFTaOYUp4zjR/ZGihCxTvWYLF78e0FK5HWlu42nlP 13ixIRxZJhuhXfRl02tacDSsBRoGXsItKFNIzd3IepD0cknM9o5prm6HEYWvDbm79JAx SFHmoniJOcbfkyLq91tiL8Ce2QO+00rLmVKN9br2Vlggv8h9FZDV1fJQhabXdtqIvXjG 7orDqDaav0mLbDInFTL7BgyMqmMS5L0NR7zxHhImgBwgg7dDmj9hIVMp7jHiaBHmShjD lfm7d6JCA06UGs/qacBaSJq2WbdSXUtc9eJrKOCiptsPZHjN4SUZNAE1oVAaVVR81YZI YIaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iurCXjmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i8-20020a1709026ac800b001cfdf2e382bsi8376597plt.209.2023.12.12.13.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 13:32:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iurCXjmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C566E804392F; Tue, 12 Dec 2023 13:32:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233127AbjLLVcf (ORCPT + 99 others); Tue, 12 Dec 2023 16:32:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbjLLVcd (ORCPT ); Tue, 12 Dec 2023 16:32:33 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEA19A7 for ; Tue, 12 Dec 2023 13:32:39 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8018EC433B9 for ; Tue, 12 Dec 2023 21:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702416759; bh=mfEW7Jo7qwzsMBHWmcox+E4i/5RV7VxXJqvDtAte4Y4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iurCXjmMTiNWcT6JXNwQ2WjwtRQu0gEcGPsFUjV39XCd8Mq/xT0qR0gFDZmPn2kx4 p69HydF5iz89VyCEhjoGRL/3ttSjdVJl2GEE7zoGGN5BWHD0LDKTgyJ+rsSiACKgY4 9pFPkOscKtqapzzG9GqUuqJwPy1Di2rjZszdd4ao4X8JI9HT9JsChTUG+iLTMhcI+i 7ZmbSejEBVcGEDQ0P81NFJCTmdb2T9q4iantr9pLcyoc6xusyeLCAa72iHAuZCaiyZ l/VBjc36HCU+sDESkHfm6XA3QSeSi/NJuicozbREArV2NmLrTyloTAAeIfOrtXHELT JbmJJ8j3OEukQ== Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-28abda2fc0bso1152245a91.1 for ; Tue, 12 Dec 2023 13:32:39 -0800 (PST) X-Gm-Message-State: AOJu0YwV5mMi626Tt/c7DpLN2n1+HsNz19m7VSrRQy4KjJAhgqpCcaL1 ptOPHyLRWAq64JdVkcMmmLYSVFQM5ipL99nCEow4xg== X-Received: by 2002:a17:90b:fcd:b0:28a:beae:454a with SMTP id gd13-20020a17090b0fcd00b0028abeae454amr1348327pjb.25.1702416758683; Tue, 12 Dec 2023 13:32:38 -0800 (PST) MIME-Version: 1.0 References: <20231211140419.1298178-1-schatzberg.dan@gmail.com> <20231211140419.1298178-2-schatzberg.dan@gmail.com> In-Reply-To: From: Chris Li Date: Tue, 12 Dec 2023 13:32:27 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V3 1/1] mm: add swapiness= arg to memory.reclaim To: Dan Schatzberg Cc: Yosry Ahmed , Johannes Weiner , Roman Gushchin , Huan Yang , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Tejun Heo , Zefan Li , Jonathan Corbet , Michal Hocko , Shakeel Butt , Muchun Song , Andrew Morton , David Hildenbrand , Matthew Wilcox , Kefeng Wang , "Vishal Moola (Oracle)" , Yue Zhao , Hugh Dickins Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Dec 2023 13:32:45 -0800 (PST) Hi Dan, On Tue, Dec 12, 2023 at 1:27=E2=80=AFPM Dan Schatzberg wrote: > > > > + while ((start =3D strsep(&buf, " ")) !=3D NULL) { > > > + if (!strlen(start)) > > > + continue; > > > + switch (match_token(start, if_tokens, args)) { > > > + case MEMORY_RECLAIM_SWAPPINESS: > > > + if (match_int(&args[0], &swappiness)) > > > + return -EINVAL; > > > + if (swappiness < 0 || swappiness > 200) > > > > I am not a fan of extending the hardcoded 0 and 200 values, and now > > the new -1 value. Maybe it's time to create constants for the min and > > max swappiness values instead of hardcoding them everywhere? This can > > be a separate preparatory patch. Then, -1 (or any invalid value) can > > also be added as a constant with a useful name, instead of passing -1 > > to all other callers. > > > > This should make the code a little bit more readable and easier to exte= nd. > > I'm not sure I understand the concern. This check just validates that > the swappiness value inputted is between 0 and 200 (inclusive) > otherwise the interface returns -EINVAL. Are you just concerned that > these constants are not named explicitly so they can be reused > elsewhere in the code? > I think the concern is why 200? Why not 400 or 600? The user might write bigger values and expect the reclaim to work with those values. If there is some hard coded limit enforced somewhere else so writing more than 200 does not make sense. It would be nice to have those other places reference this limit as well. Thus give 200 a name and use it in other places of the code as well. Chris