From: Michal Hocko <mhocko@suse.com>
To: Zhongkun He <hezhongkun.hzk@bytedance.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
muchun.song@linux.dev, linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: Re: [PATCH V1] mm: vmscan: skip the file folios in proactive reclaim if swappiness is MAX
Date: Thu, 13 Mar 2025 10:42:21 +0100 [thread overview]
Message-ID: <Z9KofXR3KOIBXb1A@tiehlicka> (raw)
In-Reply-To: <CACSyD1PU59py6rjiZ5snvRL449OmuH9W+RMbNpmOfhO80XuW5Q@mail.gmail.com>
On Thu 13-03-25 16:57:34, Zhongkun He wrote:
> On Thu, Mar 13, 2025 at 3:57 PM Michal Hocko <mhocko@suse.com> wrote:
> >
> > On Thu 13-03-25 11:48:12, Zhongkun He wrote:
> > > With this patch 'commit <68cd9050d871> ("mm: add swappiness= arg to
> > > memory.reclaim")', we can submit an additional swappiness=<val> argument
> > > to memory.reclaim. It is very useful because we can dynamically adjust
> > > the reclamation ratio based on the anonymous folios and file folios of
> > > each cgroup. For example,when swappiness is set to 0, we only reclaim
> > > from file folios.
> > >
> > > However,we have also encountered a new issue: when swappiness is set to
> > > the MAX_SWAPPINESS, it may still only reclaim file folios. This is due
> > > to the knob of cache_trim_mode, which depends solely on the ratio of
> > > inactive folios, regardless of whether there are a large number of cold
> > > folios in anonymous folio list.
> > >
> > > So, we hope to add a new control logic where proactive memory reclaim only
> > > reclaims from anonymous folios when swappiness is set to MAX_SWAPPINESS.
> > > For example, something like this:
> > >
> > > echo "2M swappiness=200" > /sys/fs/cgroup/memory.reclaim
> > >
> > > will perform reclaim on the rootcg with a swappiness setting of 200 (max
> > > swappiness) regardless of the file folios. Users have a more comprehensive
> > > view of the application's memory distribution because there are many
> > > metrics available. For example, if we find that a certain cgroup has a
> > > large number of inactive anon folios, we can reclaim only those and skip
> > > file folios, because with the zram/zswap, the IO tradeoff that
> > > cache_trim_mode is making doesn't hold - file refaults will cause IO,
> > > whereas anon decompression will not.
> > >
> > > With this patch, the swappiness argument of memory.reclaim has a more
> > > precise semantics: 0 means reclaiming only from file pages, while 200
> > > means reclaiming just from anonymous pages.
> >
> > Well, with this patch we have 0 - always swap, 200 - never swap and
> > anything inbetween behaves more or less arbitrary, right? Not a new
> > problem with swappiness but would it make more sense to drop all the
> > heuristics for scanning LRUs and simply use the given swappiness when
> > doing the pro active reclaim?
>
> Thanks for your suggestion! I totally agree with you. I'm preparing to send
> another patch to do this and a new thread to discuss, because I think the
> implementation doesn't conflict with this one. Do you think so ?
If the change will enforce SCAN_FRACT for proactive reclaim with
swappiness given then it will make the balancing much smoother but I do
not think the behavior at both ends of the scale would imply only single
LRU scanning mode.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2025-03-13 9:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 3:48 [PATCH V1] mm: vmscan: skip the file folios in proactive reclaim if swappiness is MAX Zhongkun He
2025-03-13 7:57 ` Michal Hocko
2025-03-13 8:57 ` Zhongkun He
2025-03-13 9:42 ` Michal Hocko [this message]
2025-03-13 11:55 ` [External] " Zhongkun He
2025-03-13 9:02 ` [External] " Zhongkun He
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=Z9KofXR3KOIBXb1A@tiehlicka \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hezhongkun.hzk@bytedance.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.