Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4928273rdb; Tue, 12 Dec 2023 13:27:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtAZ4JBKTa4N5d7+qsW1AQtdXExK77dHVaooLZclOtDO6XaoaMY/Uk9GEL5MS/g4+zHE+R X-Received: by 2002:a05:6a20:2452:b0:18b:e692:8f01 with SMTP id t18-20020a056a20245200b0018be6928f01mr3571827pzc.5.1702416452813; Tue, 12 Dec 2023 13:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702416452; cv=none; d=google.com; s=arc-20160816; b=JA8d8JsM6xoxSuck5mLRE261voNNySTb0sPM5l/HKAhr3pzKFLxhssRx5bJDgoGUGf Je+mHoXoTsssozeUBaFKwaW8buYcv2dxhTc753Rutc24TOCoBdPTZlAxjjEkYB24afQr 8AsfoGskV9VKfgiUNrTeniErMOMpjpWEvkdMTJStO0LP11RCcu9LcQuDGy3yGQpfm6vz yFpmMlTEijH4zXAs1ObIMQTUfGsOT1Als9IZyvB3UhlBpIEEni7zZ79P4UDVLKLZLH6u ENAChDmbBkp8bjNhHFkftbJ/m9Dnt34Dj8Eg6PvPD2EzkDwNfx5+Egp8bFqlOyoR6d3t jOXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mGU0tRhB9g2my+2/cE06clpBuE4ux9GMlKQnA88vmOY=; fh=Tb6ENu7vBy0V2kMy3X3oVMMMBUASvN+QOARHKsgOQsM=; b=j9hbKMAp0BY+nK8I5HyPLZ43P5XN/XHHLRh0XC7a5FRwOqEwxdmc0anl4DOvYBz8vq HXh+M61AB2jnuJ82jxWxFR50J0zwfEAhHb8rRhfEykjUYV2Z6exVXs61/qbEzx7JhMDf SpLHwCZJXUxQ4uiwe/hQxT1f5Y7UtJEaMj6SnC7iYUF7K4Q0En9XFCOCerGQtLUTh9jI EqP7NyyRNUgYqEHSiWoBx1IbviZ3n47lYCEC1Xvy5Awdg/RHkbUc6/8Oj+YWxvqCrMU1 ZFK0h8Ne9L8Us6eZa+UhZDehJHJCUDTFocIOx02qo1f1E+Ibpgn7dVp9n3e4tM9TCwy4 vFGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iUHJL12h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id w6-20020a17090a8a0600b00286b47270b3si9692752pjn.151.2023.12.12.13.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 13:27:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iUHJL12h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 35C328099CD1; Tue, 12 Dec 2023 13:27:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377366AbjLLV1L (ORCPT + 99 others); Tue, 12 Dec 2023 16:27:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377383AbjLLV1I (ORCPT ); Tue, 12 Dec 2023 16:27:08 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3CBECA; Tue, 12 Dec 2023 13:27:14 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5c701bd9a3cso1547329a12.0; Tue, 12 Dec 2023 13:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702416434; x=1703021234; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=mGU0tRhB9g2my+2/cE06clpBuE4ux9GMlKQnA88vmOY=; b=iUHJL12hkaQpYvJQ51GOvvbzu/A/N0rTuQ9psB+2rNSXP6LkUljAEAFJGzmUzqsd8Y k19JbyOQNfT4Cb1i5H5juVQW+aDQl8g6TysUlVJ+HcGsjN4JK15r/Hdz65Ps0bTchMFB yMzrgeYCM86VOtVueS2DBBZcM9kprpwSXoaGyz9WSrEyzC+RLKZzasF+ZgXBNh9YR7V8 ANk7Q7yDQZQq5vYJe+b8Pxu0cjlRdfFmbAWSP+BqfujUNIkTbO+HMGuhztFmS0LNIoUD 7koDQSw/GioKmImtedBeLSVhELItrkvMSk8u2V9lldI2A4ZCLO8j1FR7MNw0edwU0DUl ig/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702416434; x=1703021234; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mGU0tRhB9g2my+2/cE06clpBuE4ux9GMlKQnA88vmOY=; b=JzdV0RzQov9nK0dE9tZioMWR0GOF/nyHxWgeI3YrZ0wmMcP9oBcgrOyNXIqqnNtyvz oX2BK3rhWM+jW9aJ2P5E6HNBHuSVtxgRTKDatDfD6SyymIG+oo94ZdzPWnN2ZbnimXZs M2OqmRZgQeSVra5BIaC70X+Ylu5EFTuB2rpZtf5B53uP2HBfXZj+/jYjPc0Zr3HeMUFH T1hWwaMyelgkpM6jDLucUbDvAMALJXhGImcC2+wlGcFGyN+ip62+j3XWbu8aSQgM8H3h nCfnJIw4Bmxfa7fAtoQAfuZMHX0nOoExnBw6emwqrHm+N79UtDQ10F65e9RztRv4EaD9 cGHw== X-Gm-Message-State: AOJu0Yw+un8AUMSWFyOZJblRxKk3LAnv2l3zJA/FrH115xQmVmUh/1sg ocKga8EYNZlVQxbK3gzJ8Fc= X-Received: by 2002:a05:6a20:3d1e:b0:18f:b870:e9b3 with SMTP id y30-20020a056a203d1e00b0018fb870e9b3mr3562327pzi.121.1702416433791; Tue, 12 Dec 2023 13:27:13 -0800 (PST) Received: from dschatzberg-fedora-PF3DHTBV ([2620:10d:c090:500::5:671e]) by smtp.gmail.com with ESMTPSA id z21-20020a656115000000b0059d219cb359sm7504411pgu.9.2023.12.12.13.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 13:27:13 -0800 (PST) Date: Tue, 12 Dec 2023 16:27:09 -0500 From: Dan Schatzberg To: Yosry Ahmed 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 Subject: Re: [PATCH V3 1/1] mm: add swapiness= arg to memory.reclaim Message-ID: References: <20231211140419.1298178-1-schatzberg.dan@gmail.com> <20231211140419.1298178-2-schatzberg.dan@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 13:27:30 -0800 (PST) On Mon, Dec 11, 2023 at 11:41:24AM -0800, Yosry Ahmed wrote: > On Mon, Dec 11, 2023 at 6:04 AM 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 value > > + to be used for the reclaim. For example: > > + > > + echo "1G swappiness=60" > memory.reclaim > > + > > + The above instructs the kernel to perform the reclaim with > > + a swappiness value of 60. Note that this has the same semantics > > + as the vm.swappiness sysctl - it sets the relative IO cost of > > + reclaiming anon vs file memory but does not allow for reclaiming > > + 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 = strsep(&buf, " ")) != 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 extend. 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?