Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4930647rdb; Tue, 12 Dec 2023 13:32:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQoMr2EpvC6wES2tjayqMa7YKct0ep1a/pHXO6f57pq5pcIlauPinph2Qj1njRwlUX795N X-Received: by 2002:a05:6a20:daa0:b0:190:37f5:f7da with SMTP id iy32-20020a056a20daa000b0019037f5f7damr3791256pzb.59.1702416767935; 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=G9ykrsGloacmg+buAvid8oY7eo3ZTYZiPvm2RpCyGXXQcdPtUhtgabYJFJK45jh1f3 vLTt6aA8VNZvVgX6c6fWID6AG64rmUuAPqtwKJUn5Oe/z+k3Ls2eGsi0n1sbPdJMEV/q EiE2IJC394VDjkwsHqUXc3MFBMlwKYlvp0xUKblSrsaRJ7xJ1pMem/S7kaFL8fSq6/PR AaIt9r4H0cLHNAArnKu/wl6p4wbzOOl58KTtdwDps/6TRS/MsD4sQspWM0uZjuAwyzaY 3g62jJyxk03sexbypXmO+qVy1tMTBTrOt9FP56P5e+NoTQ9rBJE6XzfdBWYGjVUw6Gql 4FUw== 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=STJ8s+1ZgorKbcpwDfrOVd1KChXP1BeRsHF4DNQJ/gw=; fh=fHa/STNSUqaGbHc3m6YYrg5Xqrpxn3DpRBaZSmLer6I=; b=TLzfwPWxWJZ7unhqLo17MPw00T7rogGOYifUX12G9hlEGxoToad4GgN5eDF7EpRpgN 9FkwSj4V12D7nFVFmJag0zi+OZYOymPZVjktEgWvzL8ZFAZM1c0VK4rNDmYPVg4O25Cw fSbCCxx14a1QGieXTIIlX8CnCRcA39s0cXhGvljz6a+C5zOtM6treVrgrkl1TCmN3Tz0 zFPNGTnUZWERBk1ut7rPlCfc5xJNeBaWjtSLgxq+iMuvpBK7/A6IBhwFfQQb1Tpkoa+2 FgjqsOzlzY4Piu0Ks9c5FeIeBf2YSceii1yx6DIhbD2wIpUE7e9yhsfEdGMn8BokCci1 OpTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hSMeK58c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id f10-20020a17090274ca00b001d078e31ca8si8303241plt.293.2023.12.12.13.32.47 (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 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hSMeK58c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9B2808060C86; Tue, 12 Dec 2023 13:32:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233131AbjLLVcY (ORCPT + 99 others); Tue, 12 Dec 2023 16:32:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbjLLVcW (ORCPT ); Tue, 12 Dec 2023 16:32:22 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42FD0A7 for ; Tue, 12 Dec 2023 13:32:28 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a1f33c13ff2so530520766b.3 for ; Tue, 12 Dec 2023 13:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702416747; x=1703021547; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=STJ8s+1ZgorKbcpwDfrOVd1KChXP1BeRsHF4DNQJ/gw=; b=hSMeK58c792RnmYoJ8J2F1F9xGI3KyC+D4HUfiUyNaCRh/lgkMyvpNNTc/Qls6Soni lgxPubAcVOoUijFpSyhto6Rr6bNxBwx826swYgSlJfhGIfwOq1yOPN4AHmCVrS0LoXln hI225BSygKIp7ITrmAAT5zIkfz/lHRA76duyP3cSHBfnsy8AXoX8eGTogEEfijUZ5rmK OJyOUC+/O0OKLpjG9y34epF4XnlX8yytLeciTUBGADI3kGePSTWdeEJZr2W+qIkJFj+d vA9y2GjnfuYDEr8sSqofxqgXlN25km2FaiYffPgjTc/HG9yqFJMye6+co4oT9p7Tbo1j 8dxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702416747; x=1703021547; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=STJ8s+1ZgorKbcpwDfrOVd1KChXP1BeRsHF4DNQJ/gw=; b=Oa1sRSYh4HwWhmD6TKKdVf2DDCFfxJCrZkVYArZeqHOQM0mP//i5vV/6ljuigaF0bV l0m3gQz5DnlHcdMC69K/0/7dFtsyNUFR8xonnDFCRdYsuFM04qzNqvvLcz7ZeDHPwfyq fpss46fnAocut8FL6nrpnxFyuvjpUWORmO+ppaEhFuPxEAIBIXdj8CmMPbdhO4WyTVCn eByMFn6DOwZRhVdstdyiyK4M1bwNfuKfDZ2L0/UnW86OMLMqCux+0KHVdRZXZnDAecJl pXfRubgIA+rdn1nCyHdcKNbEsqFaxmaJChV1cTHlpXSrEMnS4jaPCdX0rSCcG23brYIU 8zcA== X-Gm-Message-State: AOJu0YxFNRoWZ4WoZcbFprLd2DPoUcTvHWa4GBOfLh/vVwOpSaFlc3dy SVRk3BMTO/TiiV4kweZIpXN+bUqTrEb4KssD0zHffQ== X-Received: by 2002:a17:906:f112:b0:9e5:2c35:50e9 with SMTP id gv18-20020a170906f11200b009e52c3550e9mr2896390ejb.77.1702416746431; Tue, 12 Dec 2023 13:32:26 -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: Yosry Ahmed Date: Tue, 12 Dec 2023 13:31:46 -0800 Message-ID: Subject: Re: [PATCH V3 1/1] mm: add swapiness= arg to memory.reclaim To: Dan Schatzberg Cc: 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 , Chris Li , 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=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 13:32:43 -0800 (PST) On Tue, Dec 12, 2023 at 1:27=E2=80=AFPM Dan Schatzberg wrote: > > On Mon, Dec 11, 2023 at 11:41:24AM -0800, Yosry Ahmed wrote: > > On Mon, Dec 11, 2023 at 6:04=E2=80=AFAM Dan Schatzberg wrote: > > > > contains* the* > > > > I think this statement was only important because no keys were > > supported, so I think we can remove it completely and rely on > > documenting the supported keys below like other interfaces, see my > > next comment. > > > > > + to reclaim. > > > > > > Example:: > > > > > > @@ -1304,6 +1304,17 @@ PAGE_SIZE multiple when read back. > > > This means that the networking layer will not adapt based on > > > reclaim induced by memory.reclaim. > > > > > > + This file also allows the user to specify the swappiness valu= e > > > + to be used for the reclaim. For example: > > > + > > > + echo "1G swappiness=3D60" > memory.reclaim > > > + > > > + The above instructs the kernel to perform the reclaim with > > > + a swappiness value of 60. Note that this has the same semanti= cs > > > + as the vm.swappiness sysctl - it sets the relative IO cost of > > > + reclaiming anon vs file memory but does not allow for reclaim= ing > > > + specific amounts of anon or file memory. > > > + > > > > Can we instead follow the same format used by other nested-keyed files > > (e.g. io.max)? This usually involves a table of supported keys and > > such. > > Thanks, both are good suggestions. Will address these. > > > > + 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? Yes. The 0 and 200 values are already hardcoded in multiple places, and we are adding more places now and more hardcoded values (i.e. -1).