* [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command
@ 2026-12-03 4:00 Chuanhua Han
2026-12-03 5:20 ` Barry Song
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Chuanhua Han @ 2026-12-03 4:00 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jonathan Corbet, Kairui Song
Cc: Axel Rasmussen, Baolin Wang, Baoquan He, Barry Song,
Liam R. Howlett, linux-doc, linux-mm, Michal Hocko, Mike Rapoport,
Qi Zheng, Randy Dunlap, Shakeel Butt, Shuah Khan, Vlastimil Babka,
Wei Xu, Yuanchu Xie, Chuanhua Han, Chuanhua Han
From: Chuanhua Han <hanchuanhua@xiaomi.com>
The fourth field of the aging command in /sys/kernel/debug/lru_gen is
documented as can_swap, but lru_gen_seq_write() parses it as a
swappiness value, the same as for the eviction command.
Commit b40599930f00 ("mm: add max swappiness arg to lru_gen for
anonymous memory only") added "max" to this field, but documented it
only for eviction.
For aging, the value decides which VMAs the page table walk scans: 0
skips anon and shmem VMAs, "max" skips file VMAs other than shmem, and
any value in [1, 200] scans both. Document the field as swappiness.
Signed-off-by: Chuanhua Han <hanchuanhua@xiaomi.com>
---
v1 -> v2:
- Reword the subject to make it clear this is a doc fix (Barry)
- Say "VMAs" instead of "pages" and mention shmem VMAs (Barry)
- Fix the From/Signed-off-by mismatch (Barry)
- Drop the test notes (Barry)
v1: https://lore.kernel.org/linux-mm/20261202121419.4026587-1-hanchuanhua@xiaomi.com/
Documentation/admin-guide/mm/multigen_lru.rst | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst
index 9cb54b4ff5d9..7c2c6af61fe0 100644
--- a/Documentation/admin-guide/mm/multigen_lru.rst
+++ b/Documentation/admin-guide/mm/multigen_lru.rst
@@ -122,10 +122,13 @@ the former is the largest and that of the latter is the smallest.
Users can write the following command to ``lru_gen`` to create a new
generation ``max_gen_nr+1``:
- ``+ memcg_id node_id max_gen_nr [can_swap [force_scan]]``
+ ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]``
-``can_swap`` defaults to the swap setting and, if it is set to ``1``,
-it forces the scan of anon pages when swap is off, and vice versa.
+``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness``
+and the valid range is [0-200, max]. If it is set to ``0``, the page
+table walk skips anon and shmem VMAs; if it is set to ``max``, it skips
+file VMAs other than shmem; otherwise, it scans both. For any nonzero
+value, anon and shmem VMAs are scanned even when swap is off.
``force_scan`` defaults to ``1`` and, if it is set to ``0``, it
employs heuristics to reduce the overhead, which is likely to reduce
the coverage as well.
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command
2026-12-03 4:00 [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command Chuanhua Han
@ 2026-12-03 5:20 ` Barry Song
2026-12-03 5:29 ` + mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch added to mm-new branch Andrew Morton
2026-12-03 6:43 ` [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command Qi Zheng
2 siblings, 0 replies; 6+ messages in thread
From: Barry Song @ 2026-12-03 5:20 UTC (permalink / raw)
To: Chuanhua Han
Cc: Andrew Morton, David Hildenbrand, Jonathan Corbet, Kairui Song,
Axel Rasmussen, Baolin Wang, Baoquan He, Liam R. Howlett,
linux-doc, linux-mm, Michal Hocko, Mike Rapoport, Qi Zheng,
Randy Dunlap, Shakeel Butt, Shuah Khan, Vlastimil Babka, Wei Xu,
Yuanchu Xie, Chuanhua Han
On Thu, Dec 3, 2026 at 12:00 PM Chuanhua Han <hanchuanhua802@gmail.com> wrote:
>
> From: Chuanhua Han <hanchuanhua@xiaomi.com>
>
> The fourth field of the aging command in /sys/kernel/debug/lru_gen is
> documented as can_swap, but lru_gen_seq_write() parses it as a
> swappiness value, the same as for the eviction command.
> Commit b40599930f00 ("mm: add max swappiness arg to lru_gen for
> anonymous memory only") added "max" to this field, but documented it
> only for eviction.
>
> For aging, the value decides which VMAs the page table walk scans: 0
> skips anon and shmem VMAs, "max" skips file VMAs other than shmem, and
> any value in [1, 200] scans both. Document the field as swappiness.
>
> Signed-off-by: Chuanhua Han <hanchuanhua@xiaomi.com>
> ---
> v1 -> v2:
> - Reword the subject to make it clear this is a doc fix (Barry)
> - Say "VMAs" instead of "pages" and mention shmem VMAs (Barry)
> - Fix the From/Signed-off-by mismatch (Barry)
> - Drop the test notes (Barry)
> v1: https://lore.kernel.org/linux-mm/20261202121419.4026587-1-hanchuanhua@xiaomi.com/
Thanks,
Reviewed-by: Barry Song <baohua@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* + mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch added to mm-new branch
2026-12-03 4:00 [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command Chuanhua Han
2026-12-03 5:20 ` Barry Song
@ 2026-12-03 5:29 ` Andrew Morton
2026-12-03 6:43 ` [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command Qi Zheng
2 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2026-12-03 5:29 UTC (permalink / raw)
To: mm-commits, yuanchu, weixugc, vbabka, skhan, shakeel.butt, rppt,
rdunlap, qi.zheng, mhocko, liam, kasong, david, corbet,
baoquan.he, baolin.wang, baohua, axelrasmussen, hanchuanhua, akpm
The patch titled
Subject: mm/mglru: fix the outdated can_swap field of the aging command
has been added to the -mm mm-new branch. Its filename is
mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Chuanhua Han <hanchuanhua@xiaomi.com>
Subject: mm/mglru: fix the outdated can_swap field of the aging command
Date: Thu, 03 Dec 2026 12:00:03 +0800
The fourth field of the aging command in /sys/kernel/debug/lru_gen is
documented as can_swap, but lru_gen_seq_write() parses it as a swappiness
value, the same as for the eviction command. Commit b40599930f00 ("mm:
add max swappiness arg to lru_gen for anonymous memory only") added "max"
to this field, but documented it only for eviction.
For aging, the value decides which VMAs the page table walk scans: 0 skips
anon and shmem VMAs, "max" skips file VMAs other than shmem, and any value
in [1, 200] scans both. Document the field as swappiness.
Link: https://patch.msgid.link/20261203040003.16978-1-hanchuanhua802@gmail.com
Signed-off-by: Chuanhua Han <hanchuanhua@xiaomi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Barry Song <baohua@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kairui Song <kasong@tencent.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Qi Zheng <qi.zheng@linux.dev>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Documentation/admin-guide/mm/multigen_lru.rst | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
--- a/Documentation/admin-guide/mm/multigen_lru.rst~mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command
+++ a/Documentation/admin-guide/mm/multigen_lru.rst
@@ -122,10 +122,13 @@ the former is the largest and that of th
Users can write the following command to ``lru_gen`` to create a new
generation ``max_gen_nr+1``:
- ``+ memcg_id node_id max_gen_nr [can_swap [force_scan]]``
+ ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]``
-``can_swap`` defaults to the swap setting and, if it is set to ``1``,
-it forces the scan of anon pages when swap is off, and vice versa.
+``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness``
+and the valid range is [0-200, max]. If it is set to ``0``, the page
+table walk skips anon and shmem VMAs; if it is set to ``max``, it skips
+file VMAs other than shmem; otherwise, it scans both. For any nonzero
+value, anon and shmem VMAs are scanned even when swap is off.
``force_scan`` defaults to ``1`` and, if it is set to ``0``, it
employs heuristics to reduce the overhead, which is likely to reduce
the coverage as well.
_
Patches currently in -mm which might be from hanchuanhua@xiaomi.com are
mm-mglru-remove-the-unused-scan_control-argument-of-isolate_folio.patch
mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command
2026-12-03 4:00 [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command Chuanhua Han
2026-12-03 5:20 ` Barry Song
2026-12-03 5:29 ` + mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch added to mm-new branch Andrew Morton
@ 2026-12-03 6:43 ` Qi Zheng
2026-12-03 8:40 ` Barry Song
2 siblings, 1 reply; 6+ messages in thread
From: Qi Zheng @ 2026-12-03 6:43 UTC (permalink / raw)
To: Chuanhua Han, Andrew Morton, David Hildenbrand, Jonathan Corbet,
Kairui Song
Cc: Axel Rasmussen, Baolin Wang, Baoquan He, Barry Song,
Liam R. Howlett, linux-doc, linux-mm, Michal Hocko, Mike Rapoport,
Randy Dunlap, Shakeel Butt, Shuah Khan, Vlastimil Babka, Wei Xu,
Yuanchu Xie, Chuanhua Han
Hi Chuanhua,
On 12/3/26 12:00 PM, Chuanhua Han wrote:
> From: Chuanhua Han <hanchuanhua@xiaomi.com>
>
> The fourth field of the aging command in /sys/kernel/debug/lru_gen is
> documented as can_swap, but lru_gen_seq_write() parses it as a
> swappiness value, the same as for the eviction command.
> Commit b40599930f00 ("mm: add max swappiness arg to lru_gen for
> anonymous memory only") added "max" to this field, but documented it
> only for eviction.
>
> For aging, the value decides which VMAs the page table walk scans: 0
> skips anon and shmem VMAs, "max" skips file VMAs other than shmem, and
> any value in [1, 200] scans both. Document the field as swappiness.
>
> Signed-off-by: Chuanhua Han <hanchuanhua@xiaomi.com>
> ---
> v1 -> v2:
> - Reword the subject to make it clear this is a doc fix (Barry)
> - Say "VMAs" instead of "pages" and mention shmem VMAs (Barry)
> - Fix the From/Signed-off-by mismatch (Barry)
> - Drop the test notes (Barry)
> v1: https://lore.kernel.org/linux-mm/20261202121419.4026587-1-hanchuanhua@xiaomi.com/
>
> Documentation/admin-guide/mm/multigen_lru.rst | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst
> index 9cb54b4ff5d9..7c2c6af61fe0 100644
> --- a/Documentation/admin-guide/mm/multigen_lru.rst
> +++ b/Documentation/admin-guide/mm/multigen_lru.rst
> @@ -122,10 +122,13 @@ the former is the largest and that of the latter is the smallest.
> Users can write the following command to ``lru_gen`` to create a new
> generation ``max_gen_nr+1``:
>
> - ``+ memcg_id node_id max_gen_nr [can_swap [force_scan]]``
> + ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]``
>
> -``can_swap`` defaults to the swap setting and, if it is set to ``1``,
> -it forces the scan of anon pages when swap is off, and vice versa.
> +``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness``
Or could this also be `memcg->swappiness` under cgroup v1?
> +and the valid range is [0-200, max]. If it is set to ``0``, the page
> +table walk skips anon and shmem VMAs; if it is set to ``max``, it skips
> +file VMAs other than shmem; otherwise, it scans both. For any nonzero
> +value, anon and shmem VMAs are scanned even when swap is off.
It reads a bit odd at first glance.
Maybe add a note on why we still need to scan here — e.g. to update the
stats? Demotion could also be a case?
Thanks,
Qi
> ``force_scan`` defaults to ``1`` and, if it is set to ``0``, it
> employs heuristics to reduce the overhead, which is likely to reduce
> the coverage as well.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command
2026-12-03 6:43 ` [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command Qi Zheng
@ 2026-12-03 8:40 ` Barry Song
2026-12-03 9:08 ` Qi Zheng
0 siblings, 1 reply; 6+ messages in thread
From: Barry Song @ 2026-12-03 8:40 UTC (permalink / raw)
To: qi.zheng
Cc: akpm, axelrasmussen, baohua, baolin.wang, baoquan.he, corbet,
david, hanchuanhua802, hanchuanhua, kasong, liam, linux-doc,
linux-mm, mhocko, rdunlap, rppt, shakeel.butt, skhan, vbabka,
weixugc, yuanchu
On Thu, Dec 3, 2026 at 2:43 PM Qi Zheng <qi.zheng@linux.dev> wrote:
>
> Hi Chuanhua,
>
> On 12/3/26 12:00 PM, Chuanhua Han wrote:
> > From: Chuanhua Han <hanchuanhua@xiaomi.com>
> >
> > The fourth field of the aging command in /sys/kernel/debug/lru_gen is
> > documented as can_swap, but lru_gen_seq_write() parses it as a
> > swappiness value, the same as for the eviction command.
> > Commit b40599930f00 ("mm: add max swappiness arg to lru_gen for
> > anonymous memory only") added "max" to this field, but documented it
> > only for eviction.
> >
> > For aging, the value decides which VMAs the page table walk scans: 0
> > skips anon and shmem VMAs, "max" skips file VMAs other than shmem, and
> > any value in [1, 200] scans both. Document the field as swappiness.
> >
> > Signed-off-by: Chuanhua Han <hanchuanhua@xiaomi.com>
> > ---
> > v1 -> v2:
> > - Reword the subject to make it clear this is a doc fix (Barry)
> > - Say "VMAs" instead of "pages" and mention shmem VMAs (Barry)
> > - Fix the From/Signed-off-by mismatch (Barry)
> > - Drop the test notes (Barry)
> > v1: https://lore.kernel.org/linux-mm/20261202121419.4026587-1-hanchuanhua@xiaomi.com/
> >
> > Documentation/admin-guide/mm/multigen_lru.rst | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst
> > index 9cb54b4ff5d9..7c2c6af61fe0 100644
> > --- a/Documentation/admin-guide/mm/multigen_lru.rst
> > +++ b/Documentation/admin-guide/mm/multigen_lru.rst
> > @@ -122,10 +122,13 @@ the former is the largest and that of the latter is the smallest.
> > Users can write the following command to ``lru_gen`` to create a new
> > generation ``max_gen_nr+1``:
> >
> > - ``+ memcg_id node_id max_gen_nr [can_swap [force_scan]]``
> > + ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]``
> >
> > -``can_swap`` defaults to the swap setting and, if it is set to ``1``,
> > -it forces the scan of anon pages when swap is off, and vice versa.
> > +``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness``
>
> Or could this also be `memcg->swappiness` under cgroup v1?
Good catch. Currently, the documentation only mentions
/proc/sys/vm/swappiness for both the eviction and aging paths.
However, we actually override either vm_swappiness or
memcg->swappiness in cgroup v1.
static int run_cmd(char cmd, u64 memcg_id, int nid, unsigned long seq,
struct scan_control *sc, int swappiness, unsigned long opt)
{
...
if (swappiness < MIN_SWAPPINESS)
swappiness = get_swappiness(lruvec, sc);
else if (swappiness > SWAPPINESS_ANON_ONLY)
goto done;
..
return err;
}
I guess we can put some words for both "Proactive reclaim" and "aging" path
with the below incremental changes?
From 36deb839afb2c1a3421a54889c1e43bdea438016 Mon Sep 17 00:00:00 2001
From: Barry Song <baohua@kernel.org>
Date: Thu, 3 Dec 2026 16:33:50 +0800
Subject: [PATCH]
Fix-mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch
Also mention that the swappiness override can override the memcg's
swappiness in cgroup v1.
Suggested-by: Qi Zheng <qi.zheng@linux.dev>
Signed-off-by: Barry Song <baohua@kernel.org>
---
Documentation/admin-guide/mm/multigen_lru.rst | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst
index e59621fb052f..cfb208430411 100644
--- a/Documentation/admin-guide/mm/multigen_lru.rst
+++ b/Documentation/admin-guide/mm/multigen_lru.rst
@@ -125,10 +125,11 @@ generation ``max_gen_nr+1``:
``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]``
``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness``
-and the valid range is [0-200, max]. If it is set to ``0``, the page
-table walk skips anon and shmem VMAs; if it is set to ``max``, it skips
-file VMAs other than shmem; otherwise, it scans both. For any nonzero
-value, anon and shmem VMAs are scanned even when swap is off.
+or ``memory.swappiness`` in cgroup v1. The valid range is [0-200, max].
+If it is set to ``0``, the page table walk skips anon and shmem VMAs;
+if it is set to ``max``, it skips file VMAs other than shmem; otherwise,
+it scans both. For any nonzero value, anon and shmem VMAs are scanned
+even when swap is off.
``force_scan`` defaults to ``1`` and, if it is set to ``0``, it
employs heuristics to reduce the overhead, which is likely to reduce
the coverage as well.
@@ -153,10 +154,11 @@ generations less than or equal to ``min_gen_nr``.
``min_gen_nr`` should be less than ``max_gen_nr-1``, since
``max_gen_nr`` and ``max_gen_nr-1`` are not fully aged and therefore
-cannot be evicted. ``swappiness``
-overrides the default value in ``/proc/sys/vm/swappiness`` and the valid
-range is [0-200, max], with max being exclusively used for the reclamation
-of anonymous memory. ``nr_to_reclaim`` limits the number of pages to evict.
+cannot be evicted. ``swappiness`` overrides the default value in
+``/proc/sys/vm/swappiness`` or ``memory.swappiness`` in cgroup v1.
+The valid range is [0-200, max], with ``max`` being used exclusively
+for the reclamation of anonymous memory. ``nr_to_reclaim`` limits
+the number of pages to evict.
A typical use case is that a job scheduler runs this command before it
tries to land a new job on a server. If it fails to materialize enough
--
2.39.3 (Apple Git-146)
>
> > +and the valid range is [0-200, max]. If it is set to ``0``, the page
> > +table walk skips anon and shmem VMAs; if it is set to ``max``, it skips
> > +file VMAs other than shmem; otherwise, it scans both. For any nonzero
> > +value, anon and shmem VMAs are scanned even when swap is off.
>
> It reads a bit odd at first glance.
>
> Maybe add a note on why we still need to scan here — e.g. to update the
> stats? Demotion could also be a case?
The context is already clear that we're talking about aging:
"Users can write the following command to ``lru_gen`` to create a new
generation ``max_gen_nr+1``."
So it should already be clear that the scan is for aging, right?
Thanks,
Barry
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command
2026-12-03 8:40 ` Barry Song
@ 2026-12-03 9:08 ` Qi Zheng
0 siblings, 0 replies; 6+ messages in thread
From: Qi Zheng @ 2026-12-03 9:08 UTC (permalink / raw)
To: Barry Song
Cc: akpm, axelrasmussen, baolin.wang, baoquan.he, corbet, david,
hanchuanhua802, hanchuanhua, kasong, liam, linux-doc, linux-mm,
mhocko, rdunlap, rppt, shakeel.butt, skhan, vbabka, weixugc,
yuanchu
Hi Barry,
On 12/3/26 4:40 PM, Barry Song wrote:
> On Thu, Dec 3, 2026 at 2:43 PM Qi Zheng <qi.zheng@linux.dev> wrote:
>>
>> Hi Chuanhua,
>>
>> On 12/3/26 12:00 PM, Chuanhua Han wrote:
>>> From: Chuanhua Han <hanchuanhua@xiaomi.com>
>>>
>>> The fourth field of the aging command in /sys/kernel/debug/lru_gen is
>>> documented as can_swap, but lru_gen_seq_write() parses it as a
>>> swappiness value, the same as for the eviction command.
>>> Commit b40599930f00 ("mm: add max swappiness arg to lru_gen for
>>> anonymous memory only") added "max" to this field, but documented it
>>> only for eviction.
>>>
>>> For aging, the value decides which VMAs the page table walk scans: 0
>>> skips anon and shmem VMAs, "max" skips file VMAs other than shmem, and
>>> any value in [1, 200] scans both. Document the field as swappiness.
>>>
>>> Signed-off-by: Chuanhua Han <hanchuanhua@xiaomi.com>
>>> ---
>>> v1 -> v2:
>>> - Reword the subject to make it clear this is a doc fix (Barry)
>>> - Say "VMAs" instead of "pages" and mention shmem VMAs (Barry)
>>> - Fix the From/Signed-off-by mismatch (Barry)
>>> - Drop the test notes (Barry)
>>> v1: https://lore.kernel.org/linux-mm/20261202121419.4026587-1-hanchuanhua@xiaomi.com/
>>>
>>> Documentation/admin-guide/mm/multigen_lru.rst | 9 ++++++---
>>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst
>>> index 9cb54b4ff5d9..7c2c6af61fe0 100644
>>> --- a/Documentation/admin-guide/mm/multigen_lru.rst
>>> +++ b/Documentation/admin-guide/mm/multigen_lru.rst
>>> @@ -122,10 +122,13 @@ the former is the largest and that of the latter is the smallest.
>>> Users can write the following command to ``lru_gen`` to create a new
>>> generation ``max_gen_nr+1``:
>>>
>>> - ``+ memcg_id node_id max_gen_nr [can_swap [force_scan]]``
>>> + ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]``
>>>
>>> -``can_swap`` defaults to the swap setting and, if it is set to ``1``,
>>> -it forces the scan of anon pages when swap is off, and vice versa.
>>> +``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness``
>>
>> Or could this also be `memcg->swappiness` under cgroup v1?
>
> Good catch. Currently, the documentation only mentions
> /proc/sys/vm/swappiness for both the eviction and aging paths.
> However, we actually override either vm_swappiness or
> memcg->swappiness in cgroup v1.
>
> static int run_cmd(char cmd, u64 memcg_id, int nid, unsigned long seq,
> struct scan_control *sc, int swappiness, unsigned long opt)
> {
> ...
> if (swappiness < MIN_SWAPPINESS)
> swappiness = get_swappiness(lruvec, sc);
> else if (swappiness > SWAPPINESS_ANON_ONLY)
> goto done;
> ..
> return err;
> }
>
> I guess we can put some words for both "Proactive reclaim" and "aging" path
> with the below incremental changes?
LGTM!
>
> From 36deb839afb2c1a3421a54889c1e43bdea438016 Mon Sep 17 00:00:00 2001
> From: Barry Song <baohua@kernel.org>
> Date: Thu, 3 Dec 2026 16:33:50 +0800
> Subject: [PATCH]
> Fix-mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch
>
> Also mention that the swappiness override can override the memcg's
> swappiness in cgroup v1.
>
> Suggested-by: Qi Zheng <qi.zheng@linux.dev>
> Signed-off-by: Barry Song <baohua@kernel.org>
> ---
> Documentation/admin-guide/mm/multigen_lru.rst | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst
> index e59621fb052f..cfb208430411 100644
> --- a/Documentation/admin-guide/mm/multigen_lru.rst
> +++ b/Documentation/admin-guide/mm/multigen_lru.rst
> @@ -125,10 +125,11 @@ generation ``max_gen_nr+1``:
> ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]``
>
> ``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness``
> -and the valid range is [0-200, max]. If it is set to ``0``, the page
> -table walk skips anon and shmem VMAs; if it is set to ``max``, it skips
> -file VMAs other than shmem; otherwise, it scans both. For any nonzero
> -value, anon and shmem VMAs are scanned even when swap is off.
> +or ``memory.swappiness`` in cgroup v1. The valid range is [0-200, max].
> +If it is set to ``0``, the page table walk skips anon and shmem VMAs;
> +if it is set to ``max``, it skips file VMAs other than shmem; otherwise,
> +it scans both. For any nonzero value, anon and shmem VMAs are scanned
> +even when swap is off.
> ``force_scan`` defaults to ``1`` and, if it is set to ``0``, it
> employs heuristics to reduce the overhead, which is likely to reduce
> the coverage as well.
> @@ -153,10 +154,11 @@ generations less than or equal to ``min_gen_nr``.
>
> ``min_gen_nr`` should be less than ``max_gen_nr-1``, since
> ``max_gen_nr`` and ``max_gen_nr-1`` are not fully aged and therefore
> -cannot be evicted. ``swappiness``
> -overrides the default value in ``/proc/sys/vm/swappiness`` and the valid
> -range is [0-200, max], with max being exclusively used for the reclamation
> -of anonymous memory. ``nr_to_reclaim`` limits the number of pages to evict.
> +cannot be evicted. ``swappiness`` overrides the default value in
> +``/proc/sys/vm/swappiness`` or ``memory.swappiness`` in cgroup v1.
> +The valid range is [0-200, max], with ``max`` being used exclusively
> +for the reclamation of anonymous memory. ``nr_to_reclaim`` limits
> +the number of pages to evict.
>
> A typical use case is that a job scheduler runs this command before it
> tries to land a new job on a server. If it fails to materialize enough
> >
> >> +and the valid range is [0-200, max]. If it is set to > ``0``, the
page
> >> +table walk skips anon and shmem VMAs; if it is set to > ``max``,
it skips
> >> +file VMAs other than shmem; otherwise, it scans both. > For any
nonzero
> >> +value, anon and shmem VMAs are scanned even when swap > is off.
> >
> > It reads a bit odd at first glance.
> >
> > Maybe add a note on why we still need to scan here — e.> g. to
update the
> > stats? Demotion could also be a case?
>
> The context is already clear that we're talking about > aging:
> "Users can write the following command to ``lru_gen`` to > create a new
> generation ``max_gen_nr+1``."
> So it should already be clear that the scan is for aging, right?
Fair enough.
It just seemed odd to me that we still scan anon pages in the swap-off
case. That seems fine as is — the aging section covers the details of
what actually happens.
Thanks,
Qi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-03 9:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 4:00 [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command Chuanhua Han
2026-12-03 5:20 ` Barry Song
2026-12-03 5:29 ` + mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch added to mm-new branch Andrew Morton
2026-12-03 6:43 ` [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command Qi Zheng
2026-12-03 8:40 ` Barry Song
2026-12-03 9:08 ` Qi Zheng
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.