mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm/mglru: restore accidentally removed seq < max_seq check
@ 2026-09-15 10:15 Barry Song (Xiaomi)
  2026-09-16  3:23 ` Baolin Wang
  2026-09-16  8:41 ` Kairui Song
  0 siblings, 2 replies; 3+ messages in thread
From: Barry Song (Xiaomi) @ 2026-09-15 10:15 UTC (permalink / raw)
  To: akpm
  Cc: axelrasmussen, baohua, baoquan.he, david, hannes, kasong,
	linux-kernel, linux-mm, ljs, mhocko, qi.zheng, ridong.chen,
	shakeel.butt, weixugc, yuanchu, yuzhao, Chuanhua Han

Since commit 798c0330c2ca ("mm/mglru: rework aging feedback"),
the following sanity check was accidentally removed:
       if (seq < max_seq)
               return 0;

That means we can perform aging for any value less than or equal to
max_gen_nr.

This has been inconsistent with
Documentation/admin-guide/mm/multigen_lru.rst, which states:

 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]]``

The correct semantics are that writing a value smaller than
max_gen_nr should return 0, since the requested generation already
exists.

Fixes: 798c0330c2ca ("mm/mglru: rework aging feedback")
Reported-by: Chuanhua Han <hanchuanhua802@gmail.com>
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
---
 mm/vmscan.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 5354eb8d3a07..18c4d3595749 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -5827,6 +5827,9 @@ static int run_aging(struct lruvec *lruvec, unsigned long seq,
 {
 	DEFINE_MAX_SEQ(lruvec);
 
+	if (seq < max_seq)
+		return 0;
+
 	if (seq > max_seq)
 		return -EINVAL;
 
-- 
2.39.3 (Apple Git-146)


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

* Re: [PATCH] mm/mglru: restore accidentally removed seq < max_seq check
  2026-09-15 10:15 [PATCH] mm/mglru: restore accidentally removed seq < max_seq check Barry Song (Xiaomi)
@ 2026-09-16  3:23 ` Baolin Wang
  2026-09-16  8:41 ` Kairui Song
  1 sibling, 0 replies; 3+ messages in thread
From: Baolin Wang @ 2026-09-16  3:23 UTC (permalink / raw)
  To: Barry Song (Xiaomi), akpm
  Cc: axelrasmussen, baoquan.he, david, hannes, kasong, linux-kernel,
	linux-mm, ljs, mhocko, qi.zheng, ridong.chen, shakeel.butt,
	weixugc, yuanchu, yuzhao, Chuanhua Han



On 9/15/26 6:15 PM, Barry Song (Xiaomi) wrote:
> Since commit 798c0330c2ca ("mm/mglru: rework aging feedback"),
> the following sanity check was accidentally removed:
>         if (seq < max_seq)
>                 return 0;
> 
> That means we can perform aging for any value less than or equal to
> max_gen_nr.
> 
> This has been inconsistent with
> Documentation/admin-guide/mm/multigen_lru.rst, which states:
> 
>   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]]``
> 
> The correct semantics are that writing a value smaller than
> max_gen_nr should return 0, since the requested generation already
> exists.
> 
> Fixes: 798c0330c2ca ("mm/mglru: rework aging feedback")
> Reported-by: Chuanhua Han <hanchuanhua802@gmail.com>
> Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
> ---

LGTM.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>

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

* Re: [PATCH] mm/mglru: restore accidentally removed seq < max_seq check
  2026-09-15 10:15 [PATCH] mm/mglru: restore accidentally removed seq < max_seq check Barry Song (Xiaomi)
  2026-09-16  3:23 ` Baolin Wang
@ 2026-09-16  8:41 ` Kairui Song
  1 sibling, 0 replies; 3+ messages in thread
From: Kairui Song @ 2026-09-16  8:41 UTC (permalink / raw)
  To: Barry Song (Xiaomi)
  Cc: akpm, axelrasmussen, baoquan.he, david, hannes, linux-kernel,
	linux-mm, ljs, mhocko, qi.zheng, ridong.chen, shakeel.butt,
	weixugc, yuanchu, yuzhao, Chuanhua Han

On Tue, Sep 15, 2026 at 6:51 PM Barry Song (Xiaomi) <baohua@kernel.org> wrote:
>
> Since commit 798c0330c2ca ("mm/mglru: rework aging feedback"),
> the following sanity check was accidentally removed:
>        if (seq < max_seq)
>                return 0;
>
> That means we can perform aging for any value less than or equal to
> max_gen_nr.
>
> This has been inconsistent with
> Documentation/admin-guide/mm/multigen_lru.rst, which states:
>
>  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]]``
>
> The correct semantics are that writing a value smaller than
> max_gen_nr should return 0, since the requested generation already
> exists.
>
> Fixes: 798c0330c2ca ("mm/mglru: rework aging feedback")
> Reported-by: Chuanhua Han <hanchuanhua802@gmail.com>
> Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
> ---
>  mm/vmscan.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 5354eb8d3a07..18c4d3595749 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -5827,6 +5827,9 @@ static int run_aging(struct lruvec *lruvec, unsigned long seq,
>  {
>         DEFINE_MAX_SEQ(lruvec);
>
> +       if (seq < max_seq)
> +               return 0;
> +
>         if (seq > max_seq)
>                 return -EINVAL;

Reviewed-by: Kairui Song <kasong@tencent.com>

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

end of thread, other threads:[~2026-09-16  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 10:15 [PATCH] mm/mglru: restore accidentally removed seq < max_seq check Barry Song (Xiaomi)
2026-09-16  3:23 ` Baolin Wang
2026-09-16  8:41 ` Kairui Song

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

all inboxes | Powered by JetHome®