From: Ridong Chen <ridong.chen@linux.dev>
To: Barry Song <baohua@kernel.org>
Cc: David Hildenbrand <david@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Kairui Song <kasong@tencent.com>,
Johannes Weiner <hannes@cmpxchg.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Baoquan He <baoquan.he@linux.dev>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Yu Zhao <yuzhao@google.com>,
linux-mm@kvack.org, Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH v3 1/2] mm/mglru: pass a seq range to lru_gen_add_folio()
Date: Thu, 26 Nov 2026 10:16:10 +0800 [thread overview]
Message-ID: <d61f15b0-6546-4a11-a749-3c27d743df00@linux.dev> (raw)
In-Reply-To: <CAGsJ_4x1k+-HtNU7zCPcsKwYyYfiW95+Jxrd-SvCWZm8Sq6B0A@mail.gmail.com>
On 11/26/2026 7:57 AM, Barry Song wrote:
>> +/*
>> + * Cap the seq to [min_seq, max_seq], see MIN_SEQ_UNBOUNDED and
>> + * MAX_SEQ_UNBOUNDED for no limit. With no limit and tail set, the folio is
>> + * added to the tail of the oldest gen.
>> + */
>
> Another option is to make tail and gen orthogonal, so that tail
> isn't necessarily tied to the oldest gen. This would be similar
> to the deactivate path, except that we would only need to set
> tail here without changing gen.
>
> Would that approach work as well?
>
Yes, that works for me, and it is cleaner. tail will only pick the
list end, and the two callers that pass tail=true will pass
min_seq[type] as max_seq to keep the folio in the oldest gen, like
the deactivate path in patch 2. lru_gen_folio_seq() never returns a
seq below min_seq[type], so this gives the same result as before.
The changes on top of v3 would be something like:
lru_gen_add_folio() drops the if/else:
seq = lru_gen_folio_seq(lruvec, folio);
seq = max(seq, min(min_seq, lrugen->max_seq));
seq = min(seq, max_seq);
lruvec_add_folio_tail() is outside CONFIG_LRU_GEN, so it reads
lrugen under the #ifdef:
```
#ifdef CONFIG_LRU_GEN
int type = folio_is_file_lru(folio);
unsigned long seq = READ_ONCE(lruvec->lrugen.min_seq[type]);
if (lru_gen_add_folio(lruvec, folio, MIN_SEQ_UNBOUNDED, seq,true))
return;
#endif
```
fill_evictable() caps only the inactive folios:
```
max_seq = active ? MAX_SEQ_UNBOUNDED :
READ_ONCE(lruvec->lrugen.min_seq[type]);
success = lru_gen_add_folio(lruvec, folio, MIN_SEQ_UNBOUNDED,
max_seq, !active);
```
Patch 2 stays the same.
Does this look good to you? If so, I will send v4 with it.
>> +static inline bool lru_gen_add_folio(struct lruvec *lruvec, struct folio *folio,
>> + unsigned long min_seq, unsigned long max_seq,
>> + bool tail)
>> {
>> unsigned long seq;
>> unsigned long flags;
>> @@ -406,9 +413,12 @@ static inline bool __lru_gen_add_folio(struct lruvec *lruvec, struct folio *foli
>> if (folio_test_unevictable(folio) || !lrugen->enabled)
>> return false;
>>
>> - seq = lru_gen_folio_seq(lruvec, folio, reclaiming);
>> - if (scanned_seq != -1UL)
>> - seq = max(seq, min(scanned_seq + 1, lrugen->max_seq));
>> + if (tail)
>> + seq = READ_ONCE(lrugen->min_seq[type]);
>> + else
>> + seq = lru_gen_folio_seq(lruvec, folio);
>
> Then we wouldn't need any if/else branches here.
>
>> + seq = max(seq, min(min_seq, lrugen->max_seq));
>
> Thanks,
> Barry
--
Best regards
Ridong
next prev parent reply other threads:[~2026-11-26 2:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 9:40 [PATCH v3 0/2] mm/mglru: deactivate anon folios into the oldest generation Ridong Chen
2026-11-25 9:40 ` [PATCH v3 1/2] mm/mglru: pass a seq range to lru_gen_add_folio() Ridong Chen
2026-11-25 23:57 ` Barry Song
2026-11-26 2:16 ` Ridong Chen [this message]
2026-11-26 12:47 ` Barry Song
2026-11-25 9:40 ` [PATCH v3 2/2] mm/mglru: deactivate anon folios into the oldest generation Ridong Chen
2026-11-26 0:02 ` Barry Song
2026-11-26 2:18 ` Ridong Chen
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=d61f15b0-6546-4a11-a749-3c27d743df00@linux.dev \
--to=ridong.chen@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=chenridong@xiaomi.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=qi.zheng@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=vbabka@kernel.org \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
--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