linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/4] add max arg to swappiness in memory.reclaim and lru_gen
@ 2025-04-21  9:13 Zhongkun He
  2025-04-21  9:13 ` [PATCH V4 1/4] mm: add swappiness=max arg to memory.reclaim for only anon reclaim Zhongkun He
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Zhongkun He @ 2025-04-21  9:13 UTC (permalink / raw)
  To: akpm
  Cc: hannes, mhocko, yosry.ahmed, muchun.song, yuzhao, linux-mm,
	linux-kernel, Zhongkun He

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 more comments for cache_trim_mode from
Johannes Weiner in [1].

Patch 3 add max arg to lru_gen for proactive 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.

Patch 4 using SWAPPINESS_ANON_ONLY in MGLRU
Using SWAPPINESS_ANON_ONLY instead of MAX_SWAPPINESS + 1
to indicate reclaiming only from anonymous pages makes the
code more readable and explicit

[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/

V4:
Split the patch in MGLRU and add comments to make the code clearer
from Andrew Morton.

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 (4):
  mm: add swappiness=max arg to memory.reclaim for only anon reclaim
  mm: vmscan: add more comments about cache_trim_mode
  mm: add max swappiness arg to lru_gen for anonymous memory only
  mm: using SWAPPINESS_ANON_ONLY in MGLRU

 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                                   | 42 +++++++++++++++----
 5 files changed, 49 insertions(+), 10 deletions(-)

-- 
2.39.5



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-05-07  7:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-21  9:13 [PATCH V4 0/4] add max arg to swappiness in memory.reclaim and lru_gen Zhongkun He
2025-04-21  9:13 ` [PATCH V4 1/4] mm: add swappiness=max arg to memory.reclaim for only anon reclaim Zhongkun He
2025-04-21  9:34   ` Muchun Song
2025-04-22  6:16     ` [External] " Zhongkun He
2025-04-21  9:13 ` [PATCH V4 2/4] mm: vmscan: add more comments about cache_trim_mode Zhongkun He
2025-04-21  9:13 ` [PATCH V4 3/4] mm: add max swappiness arg to lru_gen for anonymous memory only Zhongkun He
2025-04-21  9:35   ` Muchun Song
2025-04-22  6:18     ` [External] " Zhongkun He
2025-05-07  7:10   ` [PATCH update] " Zhongkun He
2025-04-21  9:13 ` [PATCH V4 4/4] mm: using SWAPPINESS_ANON_ONLY in MGLRU Zhongkun He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox