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 0EFD5C4332F for ; Tue, 12 Dec 2023 21:32:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C7206B03AE; Tue, 12 Dec 2023 16:32:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 651F66B03AF; Tue, 12 Dec 2023 16:32:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C8DE6B03B1; Tue, 12 Dec 2023 16:32:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 332606B03AE for ; Tue, 12 Dec 2023 16:32:30 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 029E112030E for ; Tue, 12 Dec 2023 21:32:29 +0000 (UTC) X-FDA: 81559465260.20.A3CFF9F Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by imf26.hostedemail.com (Postfix) with ESMTP id 200CD140023 for ; Tue, 12 Dec 2023 21:32:27 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Z/fMumQU"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702416748; a=rsa-sha256; cv=none; b=PMKgYjqaxhPXcCWgMXc6sfdpA45NUaFco6cDEoACdbxGdHwbo3pko7480O0EXppeTPk7Cn kFjWB/utOMLFmk9oY1tsrDWcwe25nIpiRJUtUygKXXqGWk1M1ova2NMq1dAdxYRWfNwt5p TzFHaaVizBNkfKKQ9OauWC0WZoWAdoA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Z/fMumQU"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702416748; 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=STJ8s+1ZgorKbcpwDfrOVd1KChXP1BeRsHF4DNQJ/gw=; b=VOO7SvphCK3S5baN+Ly0/zoVcgqmVUkhPZyLH9dupNkWqyGzKWv0Q7XKGNr4jCcuzovhTN 0C6LcqIU+co1Op1tH1s64YzP6ZYRMj8rxtmBvA7Ikkd5mLbZodNEFdjrhQVEU5jktDvjNu ZdDYeR5Yjv7hXA1v5LZ+mol/iWHLtmg= Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a1f33c13ff2so530520866b.3 for ; Tue, 12 Dec 2023 13:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702416747; x=1703021547; darn=kvack.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=Z/fMumQUoRoMl+fjTT5cc2ezuCYXeh/v08pKYUjGsTPfEd5TppLtewt0cSBZGM5n5K mvpxcvUY43CpQ365KMVs8fr5M8RG1ZgYkD3UzEGvdDm1enxSc2TsH76jvGptJeb9aJUv yEv2d/Dw6Irkeva6YkAVX1x//mBELq5RB/RtHZ1XNuNgNBVaX1bqtRq9XN7v9qStTma3 KWw2igIZI706fYLIaq/82Vo1d7VbnbKcEZTMO/GC4s9Nkb68eRl5m6lD1xjxdMxx8wXH oVZHbQHKw8Sopc7GoRTxxrpNl8ElXadeESDGTym29YcxiRuKNeSyY3I1vDxjCBPz+Ld/ mOcw== 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=SB8gY+N8ANMTDYc7hPFFWncIJSbKgClg15UQeIUPPnUryRfQQkBfA+uwS4Vk31tflx trgjapw2ILBPMXRFidW5d5TNjw1PZd3xUDa80MGq6+EJqrZvL5YL4PfSMQguYJL87n6S rbrOsEwHPMrLRzTemqr1XnGLFvRfUj53rrcd2aaZl5fHq5aMlBsh+QQ+aoCmdliEiux1 P/tXrPojWuUAucbmhmCft+9OQSt2ok4HmSmQFTXhoxsDRYdEQjzf/dAw1ma1c4itiBLj aR93w+kG9cN8vVggIyS0Nrna8lUUl3ATwagEQR73e6ToyUXIFSw76HeEs6UmpR8QcTOT pW6g== X-Gm-Message-State: AOJu0YyKQNz45C8jMpyWrfpMZJ8uNomL8lr/QV+io5m0hjIDej8IXq/1 hAOc51ePREtf/W07xln8f6nGrUyKS2tKPBACjRJsSg== X-Google-Smtp-Source: AGHT+IH0fVR2m3wicfc1ELe6nAiJDzi+m6wO1H72mGA0fKcCQZvoNdz/jyd5VQOICC3W8TgaUHAOGDtzkrg1CHbJ1SM= 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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 200CD140023 X-Stat-Signature: 4frin3ek3xnrrm5dqd1pwdehyi7rojz4 X-HE-Tag: 1702416747-17875 X-HE-Meta: U2FsdGVkX1+++7hkZZqUgLKLJHJwIomHdrjQT2KglkRR43HyP4bB8bPbE5Rje4jNy72c9Rb/Safc99CbnffkEpstg3DAAtaaihVjVU2VTrA/43/GoMQv14y4pElreAYAx7rlz2ozcsyE3sxIHQxI21uN0EwddFSHWOdPqG7fCJ3GM8RJXmvjjWAJCm+/83POYWiDvtkxXV3/Ey8KPGOa6HY+0o4/jc0H/QAAm0wymJ2JNTjm9iOHeJpv64SH+lEmpAx0Y7Oei8TGtbOVJCLQMjvmTRYmHBjuPrBL4H4/C0vFzwjxjke+APmJuJXaWVs92OC7ZRIVOCUfEX14zmD1BV9oMKPj9F65CSrAQztOi8TMM81Jn8TvvMSffUPugVuH4NyqaV075XRKHCc5H0StzHoJAaiTfz71p/CoUegR6ARoNdNSx5qhUSXofM6TUVDQhhOIhMZ3fzAWAFcqajLckKxqChDCm/XokFkg9UnuIlIX8RG2+QknZpy4hQw7LBo/Gn4J7Try9iqPPlnBn1lKcy9ihxVHwGA+BcxMfWgqhyxILPjXrMwUJV08+pxlHaYkEw7+P2xqYQkssfj59YzKizZp2DGrxX2Vgph5AeTq5pgIlrTOheJy6JqhjHDSa0PVF2b4dWq1mhOq1rpwV5MzRvZQ3LnqfF1fCuEDhYlxOvGNoDo2jc+58dIV+EkVckpkJJjXKOUT4oD8NYQSDjfoXit8lNEYsOfcyMOnrloWkHcrHZzo7ZL8MAkGK8S8cizrxrOGCQpYDvRRTLdA+1xoRB/kf8GYXn0xXlrkdMKWxMfpK6sBGXNfn6xjRIKNwFVkOjfy/2mxki/c9SEU1YpImGNUtUXg5IGuqZpKNVGiRHlmcVN5FtSEzOSjVSCuzN+UtCo5LDBLrVh2b/wu0szxAEFnIQDuUK5f/5+LOIwQrjIoTmg6WZBcarfU7+XjpOPCYXI+1E+iH/R/j2kEowY HbRkceHw FdyxSVZVFYUArmM1/2MOXb6x9Nr4ocyD2h3wIrQ9t5kXoNXntrAGcDYSYf5XgrwNl0+Xbc39Unj6l0o+sC+i54TPQvx8kKjIyxpqico3NAHSVGzqFM0s3qko9L2ExiDfrQTJxuEtUus7Fv+O/LGPZGO/RRYNAWIwGKrjMshO92tt/MSw6nYsIXa7Fby6du4V+UnQgNFOSDy/jBlHJb8lPriRHDCTbcrv+BKs9qlir2O4yEeGsX5D9V59eGFEwGvyKH/u9+TsteJ7vUMo7stGbiuGj9azy8J4/KQdBepbmHJMvnmibAO5wsXEEm/InaMw06YyG 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 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).