linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zhongkun He <hezhongkun.hzk@bytedance.com>
To: akpm@linux-foundation.org
Cc: hannes@cmpxchg.org, mhocko@suse.com, yosry.ahmed@linux.dev,
	muchun.song@linux.dev, yuzhao@google.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	Zhongkun He <hezhongkun.hzk@bytedance.com>
Subject: [PATCH V3 0/3] add max arg to swappiness in memory.reclaim and lru_gen
Date: Wed,  9 Apr 2025 15:06:17 +0800	[thread overview]
Message-ID: <cover.1744169302.git.hezhongkun.hzk@bytedance.com> (raw)

This patchset add max arg to swappiness in memory.reclaim and lru_gen
for anon only proactive memory reclaim.

With the 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. But we can not relciam memory just from anon folios.

This patch introduces a new macro, SWAPPINESS_ANON_ONLY, defined as
MAX_SWAPPINESS + 1, represent the max arg semantics. It specifically
indicates that reclamation should occur only from anonymous pages.

Patch 1 add swappiness=max arg to memory.reclaim
suggested-by: Yosry Ahmed

Patch 2 add max arg to lru_gen for proactie memory reclaim in MGLRU.
The MGLRU already supports reclaiming exclusively from anonymous pages.
This patch formalizes that behavior by introducing a max parameter to
represent the corresponding semantics, and explicitly uses the
SWAPPINESS_ANON_ONLY macro in the code to denote this logic.

Patch 3 add more comments for cache_trim_mode from
Johannes Weiner in [1].

[1]:
https://lore.kernel.org/all/20250314141833.GA1316033@cmpxchg.org/

Here is the previous discussion:
https://lore.kernel.org/all/20250314033350.1156370-1-hezhongkun.hzk@bytedance.com/
https://lore.kernel.org/all/20250312094337.2296278-1-hezhongkun.hzk@bytedance.com/
https://lore.kernel.org/all/20250318135330.3358345-1-hezhongkun.hzk@bytedance.com/

V3:
In MGLRU, add max swappiness arg to lru_gen for proactive memory reclaim. 
Add the use of SWAPPINESS_ANON_ONLY in place of 'MAX_SWAPPINESS + 1' to
improves code clarity and makes the intention more explicit.

Add more comments about cache_trim_mode.

V2:
Add max arg to swappiness as the mode of reclaim from anon memory only
in memory.reclaim.

Zhongkun He (3):
  mm: add swappiness=max arg to memory.reclaim for only anon reclaim
  mm: add max swappiness arg to lru_gen for anonymous memory only
  mm: vmscan: add more comments about cache_trim_mode

 Documentation/admin-guide/cgroup-v2.rst       |  3 ++
 Documentation/admin-guide/mm/multigen_lru.rst |  5 +--
 include/linux/swap.h                          |  4 +++
 mm/memcontrol.c                               |  5 +++
 mm/vmscan.c                                   | 36 ++++++++++++++-----
 5 files changed, 43 insertions(+), 10 deletions(-)

-- 
2.39.5



             reply	other threads:[~2025-04-09  7:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09  7:06 Zhongkun He [this message]
2025-04-09  7:06 ` [PATCH V3 1/3] mm: add swappiness=max arg to memory.reclaim for only anon reclaim Zhongkun He
2025-04-10  2:09   ` Andrew Morton
2025-04-10  3:48     ` [External] " Zhongkun He
2025-04-09  7:06 ` [PATCH V3 2/3] mm: add max swappiness arg to lru_gen for anonymous memory only Zhongkun He
2025-04-10  2:09   ` Andrew Morton
2025-04-10  4:50     ` [External] " Zhongkun He
2025-04-30  7:59   ` Dan Carpenter
2025-05-01  1:56     ` [External] " Zhongkun He
2025-05-02  6:58       ` Dan Carpenter
2025-05-07  3:27         ` Zhongkun He
2025-04-09  7:06 ` [PATCH V3 3/3] mm: vmscan: add more comments about cache_trim_mode 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=cover.1744169302.git.hezhongkun.hzk@bytedance.com \
    --to=hezhongkun.hzk@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=yosry.ahmed@linux.dev \
    --cc=yuzhao@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