From: Dan Schatzberg <schatzberg.dan@gmail.com>
To: Chris Li <chrisl@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Yosry Ahmed <yosryahmed@google.com>, Huan Yang <link@vivo.com>,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-mm@kvack.org, Tejun Heo <tj@kernel.org>,
Zefan Li <lizefan.x@bytedance.com>,
Jonathan Corbet <corbet@lwn.net>,
Michal Hocko <mhocko@kernel.org>,
Shakeel Butt <shakeelb@google.com>,
Muchun Song <muchun.song@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Matthew Wilcox <willy@infradead.org>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
"Vishal Moola (Oracle)" <vishal.moola@gmail.com>,
Yue Zhao <findns94@gmail.com>, Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH V3 1/1] mm: add swapiness= arg to memory.reclaim
Date: Tue, 12 Dec 2023 16:43:48 -0500 [thread overview]
Message-ID: <ZXjUFMwlz3P+4Nmk@dschatzberg-fedora-PF3DHTBV> (raw)
In-Reply-To: <CAF8kJuOhwjZZWab1poi1rPiV4u8O1CEZSO0cO23+aewt6S74-g@mail.gmail.com>
On Mon, Dec 11, 2023 at 05:06:54PM -0800, Chris Li wrote:
> Hi Dan,
>
> Thank you for the patch.
>
> On Mon, Dec 11, 2023 at 6:04 AM Dan Schatzberg <schatzberg.dan@gmail.com> wrote:
> >
> > Allow proactive reclaimers to submit an additional swappiness=<val>
> > argument to memory.reclaim. This overrides the global or per-memcg
> > swappiness setting for that reclaim attempt.
>
> 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.
> 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.
> > nr_reclaims--;
> > continue;
> > }
> > @@ -6895,6 +6896,16 @@ static ssize_t memory_oom_group_write(struct kernfs_open_file *of,
> > return nbytes;
> > }
> >
> > +enum {
> > + MEMORY_RECLAIM_SWAPPINESS = 0,
> > + MEMORY_RECLAIM_NULL,
> > +};
> > +
> > +static const match_table_t if_tokens = {
>
> What this is called "if_tokens"? I am trying to figure out what "if" refers to.
I used the same logic as in "mm: Add nodes= arg to memory.reclaim". I
can just call it tokens.
>
> > + { MEMORY_RECLAIM_SWAPPINESS, "swappiness=%d"},
> > + { MEMORY_RECLAIM_NULL, NULL },
> > +};
> > +
>
> Do we foresee a lot of tunable for the try to free page? I see. You
> want to use match_token() to do the keyword parsing.
See below
>
> > static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf,
> > size_t nbytes, loff_t off)
> > {
> > @@ -6902,12 +6913,33 @@ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf,
> > unsigned int nr_retries = MAX_RECLAIM_RETRIES;
> > unsigned long nr_to_reclaim, nr_reclaimed = 0;
> > unsigned int reclaim_options;
> > - int err;
> > + char *old_buf, *start;
> > + substring_t args[MAX_OPT_ARGS];
> > + int swappiness = -1;
> >
> > buf = strstrip(buf);
> > - err = page_counter_memparse(buf, "", &nr_to_reclaim);
> > - if (err)
> > - return err;
> > +
> > + old_buf = buf;
> > + nr_to_reclaim = memparse(buf, &buf) / PAGE_SIZE;
> > + if (buf == old_buf)
> > + return -EINVAL;
> > +
> > + buf = strstrip(buf);
> > +
> > + 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)
>
> 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=") be a bad idea? I haven't
> tried it myself though.
As above, "mm: Add nodes= 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.
next prev parent reply other threads:[~2023-12-12 21:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 14:04 [PATCH V3 0/1] Add swappiness argument " Dan Schatzberg
2023-12-11 14:04 ` [PATCH V3 1/1] mm: add swapiness= arg " Dan Schatzberg
2023-12-11 19:41 ` Yosry Ahmed
2023-12-12 21:27 ` Dan Schatzberg
2023-12-12 21:31 ` Yosry Ahmed
2023-12-12 21:46 ` Dan Schatzberg
2023-12-12 21:32 ` Chris Li
2023-12-12 1:06 ` Chris Li
2023-12-12 21:43 ` Dan Schatzberg [this message]
2023-12-13 0:12 ` Chris Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZXjUFMwlz3P+4Nmk@dschatzberg-fedora-PF3DHTBV \
--to=schatzberg.dan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=chrisl@kernel.org \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=findns94@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=link@vivo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=tj@kernel.org \
--cc=vishal.moola@gmail.com \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=yosryahmed@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox