Skip to contentSkip to conversation

mm/mglru: restore accidentally removed seq < max_seq check

PATCH Applied Barry Song (Xiaomi) 3 participants 3 messages Sep 15 – Sep 16

Subsystems (3)
lore
Share & tools
lore

Barry Song (Xiaomi)

author reviewer
#0 lore raw

PATCH 1/1 mm/mglru: restore accidentally removed seq < max_seq check

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")
---
 mm/vmscan.c | 3 +++
 1 file changed, 3 insertions(+)
mm/vmscan.c +3 -0
index 5354eb8d3a07..18c4d3595749 100644
@@ -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;
 
Signature · 1 line
2.39.3 (Apple Git-146)
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Barry Song (Xiaomi)

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]]``
Quoted 8 lines

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")

---

LGTM.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Barry Song (Xiaomi)
Quoted 33 lines · Barry Song (Xiaomi)

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")
---
 mm/vmscan.c | 3 +++
 1 file changed, 3 insertions(+)
mm/vmscan.c +0 -0
index 5354eb8d3a07..18c4d3595749 100644

mm/vmscan.c static int run_aging(struct lruvec *lruvec, unsigned long seq, · line 5834

Quoted 8 lines
mm/vmscan.c +3 -0
@@ -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;