Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
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: Fri, 27 Nov 2026 09:51:54 +0800	[thread overview]
Message-ID: <cfc18f34-327e-4bd2-ba82-70a50d9541ed@linux.dev> (raw)
In-Reply-To: <CAGsJ_4wu7dXwcW3dyrqgugXR6uY86oaieprQq0RuDt+=1g55Cw@mail.gmail.com>



On 11/26/2026 8:47 PM, Barry Song wrote:
> On Thu, Nov 26, 2026 at 10:16 AM Ridong Chen <ridong.chen@linux.dev> wrote:
>>
>>
>>
>> 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.
> 
> Sounds good to me, thanks! I guess we can gradually move more code from
> include/linux/mm_inline.h into mm/vmscan.h such as lruvec_add_folio,
> lruvec_add_folio_tail etc.
> 
Agreed. I would prefer to keep it out of this series though, since
patch 2 is a fix with a Fixes: tag, and moving these helpers is a
cleanup that touches more callers (mm/folio.c, mm/mlock.c and
mm/vmscan.c).

David also asked for the MGLRU helpers to move out of mm_inline.h in
the MGLRU-FG v6 thread [1], so it may be better done there or on top
of it as a separate cleanup.

[1] 
https://lore.kernel.org/linux-mm/e85a2666-9722-420b-9a60-9d4251fc3d4c@kernel.org/

-- 
Best regards
Ridong



  reply	other threads:[~2026-11-27  1:52 UTC|newest]

Thread overview: 9+ 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
2026-11-26 12:47       ` Barry Song
2026-11-27  1:51         ` Ridong Chen [this message]
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=cfc18f34-327e-4bd2-ba82-70a50d9541ed@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