[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 12 Dec 2023 16:27:09 -0500
From: Dan Schatzberg <schatzberg.dan@...il.com>
To: Yosry Ahmed <yosryahmed@...gle.com>
Cc: Johannes Weiner <hannes@...xchg.org>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Huan Yang <link@...o.com>, linux-kernel@...r.kernel.org,
cgroups@...r.kernel.org, linux-mm@...ck.org,
Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
Jonathan Corbet <corbet@....net>,
Michal Hocko <mhocko@...nel.org>,
Shakeel Butt <shakeelb@...gle.com>,
Muchun Song <muchun.song@...ux.dev>,
Andrew Morton <akpm@...ux-foundation.org>,
David Hildenbrand <david@...hat.com>,
Matthew Wilcox <willy@...radead.org>,
Chris Li <chrisl@...nel.org>,
Kefeng Wang <wangkefeng.wang@...wei.com>,
"Vishal Moola (Oracle)" <vishal.moola@...il.com>,
Yue Zhao <findns94@...il.com>, Hugh Dickins <hughd@...gle.com>
Subject: Re: [PATCH V3 1/1] mm: add swapiness= arg to memory.reclaim
On Mon, Dec 11, 2023 at 11:41:24AM -0800, Yosry Ahmed wrote:
> On Mon, Dec 11, 2023 at 6:04 AM Dan Schatzberg <schatzberg.dan@...il.com> 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?
Powered by blists - more mailing lists