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 89531C4332F for ; Wed, 13 Dec 2023 00:12:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E91B6B0415; Tue, 12 Dec 2023 19:12:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 199516B0416; Tue, 12 Dec 2023 19:12:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 039936B0417; Tue, 12 Dec 2023 19:12:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E67E86B0415 for ; Tue, 12 Dec 2023 19:12:22 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C5947A20C8 for ; Wed, 13 Dec 2023 00:12:22 +0000 (UTC) X-FDA: 81559868124.10.250CA06 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf22.hostedemail.com (Postfix) with ESMTP id 352CEC001B for ; Wed, 13 Dec 2023 00:12:19 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BieWfkoS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702426340; 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=8to49i/3gjD0ba9UYickHqhKC6OowbS83FU/kINrR0w=; b=HwTBU4sb+f/B1peLqKHwGcRxi5t8BNQSjtv6AWP0FAYajWqTYNhqXDGcJr22T+MFGTVWsK Tl0wzTzec0zd63eUICgIqd6dw9C5k7QQ3lLUj7Kwb8piY8dS/AXcTrgg5g9Nk08WYeKFa5 RJ+a9yPutiudkl1OHiZ8bPRm4CBk7NU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BieWfkoS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702426340; a=rsa-sha256; cv=none; b=4pmqC2jOQa29VaaLuSv/M0+KjHXCg1FQWNzHLDza5jiXKBqq7Aja9m17fWM2FqFN2vj128 xkXJ1hxROO//QMCFDRC/OE17g6uqHXgvntjKFPJRVzHBlvynexMUi4bT3nYhCvqzWOlgal TL0+VFZ2kQU+QKGZzVtp5/HvXK9X8lA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 2CF20CE1C88 for ; Wed, 13 Dec 2023 00:12:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12CC1C433CA for ; Wed, 13 Dec 2023 00:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702426336; bh=3F4dsqpRhuQwOEtTQukyRXUSM+s6kv9hJnJvZec4ghk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BieWfkoSn4fzWvNABtWqwni1BeXblwzuk94SWrXYYLRr93rhvnfIHABcCSNhWE8kn ZJDO/pyDy9wX3Hh6UZqpilCgnp2cURvqTG4QWhajKJBIEz5xQtYxUQC6CjvOf2kUYI AHfHkKV4R/VAgccaS86s7P4CY1DBztU23AJ0T6evUmxcZ0q3Eeep2aKE6XwSerpCRb J0KmHWnbpZ/pGQg6Tx5NczchKxfHVCuhycJa96HW8O0I97yXvWNoB5/EDviolRHu7z 1tRhYPAGMdQZTTJbB4dyrPCkPs20BchCRGPnqhupLOYFV+g8AEo6QVSGZIew4P5as/ mYFJh7uDw/jyg== Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d345b187bbso8176125ad.0 for ; Tue, 12 Dec 2023 16:12:16 -0800 (PST) X-Gm-Message-State: AOJu0YzsE2eceDmvybXT6u5xwfHOEGnf5uyByg9QuQnUQo3BFZac6r/b cDro+aHHQAo41awf7BJR4tdJI2ou4G3NLmMULKNHIQ== X-Google-Smtp-Source: AGHT+IGkbsUfD9WhztVNCjlcyZqRmTLHlOxzRjPUbeqATssEHNZVzY+SpfoaeCTLYKZPrGLmgfnkbwehTlMcfLrZTl0= X-Received: by 2002:a17:902:f549:b0:1d0:708c:d04b with SMTP id h9-20020a170902f54900b001d0708cd04bmr8657498plf.31.1702426335471; Tue, 12 Dec 2023 16:12:15 -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 16:12:04 -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: Johannes Weiner , Roman Gushchin , Yosry Ahmed , 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: qu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x8t2ewECRqjb0HLpXUv0fwhvEkfNKG jtt0vuqM 91UTFqRPY7wY3u3F1+WXUjf/XPYaGCH8m4yT+X8837sMQ+G69sHOmDukA2Fu/0l8NH51vHiVhjXqvk+7gIznBfO3hLNW1uTfkj3KfOqySPYlaBughE82Y1uS/i4lwcJFtb9eDL+G5iniujAPaJQCHl6G9f9GmXcDmPbbpXfIpIkqPwtIawV6DcfhT+UqBeKIdvjETACsB9AyioKCg95bWpzxV1w93bVC2KQCrLKWTY+nv91MkwYXUwZCHDYgWs5TVz1R1rQ5Z9LhBgmBRX6+5uDeVGvAqcVHkcvQBUFRq+Fx1wdp5a/NCcFVB2g== 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: Hi Dan, On Tue, Dec 12, 2023 at 1:43=E2=80=AFPM Dan Schatzberg wrote: > > > I am curious what prompted you to develop this patch. I understand > > what this patch does, just want to know more of your background story > > why this is needed. > > I wrote about this in some detail in the cover letter (0/1). Take a > look and let me know if the rationale is still unclear. Ah, found it. I was not CC on the cover letter but CC on the 1/1 patch. That is why I did not pick up the cover letter. Yes, the cover letter explanation was great. Exactly what I am looking for. > > > Instead of passing -1, maybe we can use mem_cgroup_swappiness(memcg); > > > > Yeah this makes sense, I'll go ahead and make that change and > eliminate the -1. Thanks > > > > nr_reclaims--; > > > continue; > > > } > > > @@ -6895,6 +6896,16 @@ static ssize_t memory_oom_group_write(struct k= ernfs_open_file *of, > > > return nbytes; > > > } > > > > > > +enum { > > > + MEMORY_RECLAIM_SWAPPINESS =3D 0, > > > + MEMORY_RECLAIM_NULL, > > > +}; > > > + > > > +static const match_table_t if_tokens =3D { > > > > What this is called "if_tokens"? I am trying to figure out what "if" re= fers to. > > I used the same logic as in "mm: Add nodes=3D arg to memory.reclaim". I > can just call it tokens. Thanks. I will take a look at that change. > > > + > > > + old_buf =3D buf; > > > + nr_to_reclaim =3D memparse(buf, &buf) / PAGE_SIZE; > > > + if (buf =3D=3D old_buf) > > > + return -EINVAL; > > > + > > > + buf =3D strstrip(buf); > > > + > > > + 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) > > > > Agree with Yosry on the 200 magic value. > > > > I am also wondering if there is an easier way to just parse one > > keyword. Will using strcmp("swappiness=3D") be a bad idea? I haven't > > tried it myself though. > > As above, "mm: Add nodes=3D arg to memory.reclaim" was previously in the > mm tree doing it this way, so I duplicated it. I think given that > there have been lots of discussions about extending this interface, > this match table has some potential future value and I don't see a > major downside to using it in favor of strcmp. Yes, that is totally your call. I am fine as it is. Just the micro optimization of me trying to see if there is a slimmer way to do it. Chris