Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4999028rdb; Tue, 12 Dec 2023 16:12:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeTTprqhiAf0uqlrhPIQaTUKEOCTH8iiixNj1K0Mbb0Ghl2IEYG5CttEgC0su2wNwL/FNa X-Received: by 2002:a05:6a21:789d:b0:18f:df5f:d9f3 with SMTP id bf29-20020a056a21789d00b0018fdf5fd9f3mr9967259pzc.91.1702426355940; Tue, 12 Dec 2023 16:12:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702426355; cv=none; d=google.com; s=arc-20160816; b=kQJHnIx/jORcGL3YQ5oIE7R0mHsoKOL53dMbUzSdBBnI+Fl4NgP8Rru+NmufU+vDbc WPRAjwwrt0SM6dGXojAGoejvtpA7mL5yHuuhjOwiAl9u6Ygyfu00vqYf5Q9qW/G8CKw+ 32IQHmJL+1HWfbv4mFpvWTIyAM5HZ81ImhdROHULsmqQ0otGX9FULabGOUrV4xY8ck+o +9nEA06VqlwFWEUSZ9tw/HuDMNeS2Tm0YT3gdFPIgFzsRhYS65fwe7skujgFxgWQbMVN ZW9Lvv6HHpGWVEjPs/IMfFF4ZcQNLADMgzLqjV/G6yLEqYmEZhqiDaZB7QMrC5/dh2cP 5gtg== 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=8to49i/3gjD0ba9UYickHqhKC6OowbS83FU/kINrR0w=; fh=oUZ8u0qXeG/6QqNtzgnz4hUIzIOQOQayYlduACSG0OM=; b=HxZnl85q8lHdssZ8GOESl1Yv4Kpz522OReTEWzbwd6aLnP+iGKJ5y6SfbzLRRx01Wv hdi5c4vN4ykizGKlX1ux/kcCJWTdXWxZV2/+JaV7bc9EU/i9PVMMHLyAgdo71pU/uVNb HHCzZOGB5SLOz3HGO2jiJeCAHrXkb+DbJG2yNGxpAYQZkaNDUZJHK375c6U2PW1zwuAO ZdJEZLkLxZzXG8VkbnNwC9SdxB4qe7i1XZyWQM5Jqga3GeegQX9P7ICD1tKxRymqQ2JA jTh4p3aO/3vf4eViXoBXUHLjwafB8N0JSWs6UeHCCmohTI/BPtRv2/fR8SIdlfhUSG+i uVPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BieWfkoS; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ja13-20020a170902efcd00b001d0545646d0si8438442plb.312.2023.12.12.16.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 16:12:35 -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=@kernel.org header.s=k20201202 header.b=BieWfkoS; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3F622804B2A1; Tue, 12 Dec 2023 16:12:33 -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 S232637AbjLMAMK (ORCPT + 99 others); Tue, 12 Dec 2023 19:12:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbjLMAMK (ORCPT ); Tue, 12 Dec 2023 19:12:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A18FA83 for ; Tue, 12 Dec 2023 16:12:16 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39822C433CD 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-f172.google.com with SMTP id d9443c01a7336-1d347b4d676so6717355ad.2 for ; Tue, 12 Dec 2023 16:12:16 -0800 (PST) X-Gm-Message-State: AOJu0YzUiZ8MR78r9+yzeW98r3Bk4uxvClSW3jPaPEpAd4wm1oB1yI0M g+x/2rQ/wOz7bjeTWEW2hFIzb3jC1S9WNb7439qz9Q== 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: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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 16:12:33 -0800 (PST) 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