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 5E28FC4332F for ; Tue, 12 Dec 2023 21:46:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E973A8D0008; Tue, 12 Dec 2023 16:46:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E201B8D0007; Tue, 12 Dec 2023 16:46:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C71E88D0008; Tue, 12 Dec 2023 16:46:10 -0500 (EST) 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 B0C1B8D0007 for ; Tue, 12 Dec 2023 16:46:10 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8ACD2A0946 for ; Tue, 12 Dec 2023 21:46:10 +0000 (UTC) X-FDA: 81559499700.17.0AA7CD0 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf11.hostedemail.com (Postfix) with ESMTP id B1ADF4000F for ; Tue, 12 Dec 2023 21:46:08 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TuUmE9+9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of schatzberg.dan@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=schatzberg.dan@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702417568; 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=kNbvUbgD/ga0q6vHooPK3cYbAsvMu2YMiNOPyF47Oz8=; b=gAubGZP8jqQsv8ueUTdjaaUisi4VYHzMlkDQJbFrZr5XAIaEfvzretu3qzgjkF1SsuKu5/ kowppsxglCz4JQ3uHhC0iPBNuh1LozzKU6kyAL+Ie/7YFV1oHuExJnhsSdWFgP1sg7dAp5 hk2L/hpootCT6JOPFXzM0nMRp1eNEsw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TuUmE9+9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of schatzberg.dan@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=schatzberg.dan@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702417568; a=rsa-sha256; cv=none; b=lmjjuinWaIo2OmSjBnCi/2z743cDB8yKoX0Pb72O5Ha4XC/uarTdyF3g0wVRNoCNJZMGyw qQH8gNkmfOUQy6RrTUUhKdjzAN9BZzsQyW+J4pI7BnyQBFeWEdtIZz5K006dbYbM8zilv6 jYjJsiLgaKHDQNWHqD+7IXTkh8l0ocE= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1d053c45897so55151705ad.2 for ; Tue, 12 Dec 2023 13:46:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702417567; x=1703022367; darn=kvack.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=kNbvUbgD/ga0q6vHooPK3cYbAsvMu2YMiNOPyF47Oz8=; b=TuUmE9+9x488abIlEwX76Zfk10oqFxXu1gOdyCVvsGSB9HbL/wzMuaNg2BqnhkWTVs ChJP2JuYaKJz86E5sD5FrXHjEB3ljGXXrLBVPDkjMWC9rGe9CRyS1DWi6EnuzXRSE0O6 ttrWMHWq3Ph1pwpXZOcndAf+Qs2omQEakm+Mppsf9eROpiGtFaPcNx+C+r+as5LkRtwj +fJLr6FWJPDAI5u4PlcGcwG2a37+OUPDuo8MrTRq1jpSiTmOjN215pCM7c6dWlJ+TL4c W2M/1iQOnNON2Ozp6Y/ZAUr2vHt711N2VjpuyGkdyqIOgof1XYVQmXOnPeRTbl4DbkFW zsug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702417567; x=1703022367; 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=kNbvUbgD/ga0q6vHooPK3cYbAsvMu2YMiNOPyF47Oz8=; b=nl47QILos9h3/JRYNbi8JGvd1x70bOmeu+BTh2Ilabx/ioU4MUpS9OMQi4V6JUbEpL clYuuBhEfooBfNAIshWTU34IH9XkRLm7uNpKhBx+pvHOfXrM2ERSa9l1lVUsckDURi/B XFDnj0Z9XxN5BG9UVNo5qPw8hRvPMp2LOvECk6TnA6kgK9dcCxcI3VWf42IjMxnXOERe GnCdRLn2H2P3qfOysaJcJYeX4tZaqDDAvcjzUAfbulhuN+d157Tr+oHe2414tNZKUasl 4rJjKRE+zZ8jNiWbq1RidprZ/1pqQOj5E+liAn1md3hg4uiGUnPfzX2vfxGS1PAbYfrN KgyA== X-Gm-Message-State: AOJu0Yz2bAvaB6EZ7yXVxE83Q/oueAjaR8Hnz5CyNs0r38ETH3TF6MAh OcC66/3xrJwpT63M6K84IbQ= X-Google-Smtp-Source: AGHT+IHxpa4QDsQ3wjeymvm0sshjoWSkDipvsjqlYvllXHnWwoJ6JpH93+nCSvAYMglDwVam0K9f6w== X-Received: by 2002:a17:902:7e8c:b0:1d0:5ad7:54f8 with SMTP id z12-20020a1709027e8c00b001d05ad754f8mr5632677pla.15.1702417567506; Tue, 12 Dec 2023 13:46:07 -0800 (PST) Received: from dschatzberg-fedora-PF3DHTBV ([2620:10d:c090:500::5:671e]) by smtp.gmail.com with ESMTPSA id be3-20020a170902aa0300b001cfa4178981sm8971631plb.309.2023.12.12.13.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 13:46:06 -0800 (PST) Date: Tue, 12 Dec 2023 16:46:03 -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-Rspam-User: X-Stat-Signature: jb3es3x5pq6nr7iu4tzj6kjksqoyuwh7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B1ADF4000F X-HE-Tag: 1702417568-441097 X-HE-Meta: U2FsdGVkX19gHNuHTMjcy1LXyVEXT4cUc1t7sOi/zxv42U6XU14jWGEFqjNIi4FgjjzBiEh7JjV5SLfkqkp5Hxb6jYmkGKw5+G/rH6+8Ok1tZMIY91HpfqN5w8HKxnQ7TconrVhRpEA60LqL+YfR/88I+NA0oiV5EAgnrndnG1KRpOfZFe/ML8zU8B/kAs+f7h4q3CYsbDDZG/PAazn0xbJ5cKp/qABm2omoTHlp6sO+j1AT5/oRmJdoJ/OX6sj9W7Ne6JnvDFkTMSGIPOBmGzvnhgXBarM9TFoSHAsJhFFx617UxG1guBAIF7YqPoq6vw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0T+0fID0MA1Q+2ThazDc4j7WpGNp7+is4jLH0Ucw4Atls0w3gxA9gQWSZDm3bXUlayzfh92N5YiovSmJdCvbiROLRiBKJRHQZnZ6H5fXk+a9k4+jnrxMUrF05r5TvRuI00LTyndxLUFeB3/cGueWBsJ9pvfONnGyWGc7r0rqxt+yXHQpkobCM+4gHALjMzxLf7O/2E= 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: List-Subscribe: List-Unsubscribe: On Tue, Dec 12, 2023 at 01:31:46PM -0800, Yosry Ahmed wrote: > On Tue, Dec 12, 2023 at 1:27 PM Dan Schatzberg wrote: > > > > 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? > > 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). Understood, I'll add a preparatory patch which adds DEFINEs for MIN_SWAPPINESS and MAX_SWAPPINESS and change the usages of 0 and 200 to those. I'll also eliminate the use of -1 as Chris suggested.