linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ridong Chen <ridong.chen@linux.dev>
To: Barry Song <baohua@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	David Hildenbrand <david@kernel.org>,
	Michal Hocko <mhocko@kernel.org>, Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Kairui Song <kasong@tencent.com>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-mm@kvack.org, Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH RFC 1/2] mm/mglru: add tracepoint for folio isolation
Date: Wed, 9 Sep 2026 20:41:49 +0800	[thread overview]
Message-ID: <acb81c51-318b-4a00-aad9-515929076662@linux.dev> (raw)
In-Reply-To: <CAGsJ_4wxZ0pc0UMAXe3xKW0=PTzYv31ieoJa1v01SoLczPVOCA@mail.gmail.com>



On 9/9/2026 8:11 PM, Barry Song wrote:
> On Wed, Sep 9, 2026 at 8:00 PM Ridong Chen <ridong.chen@linux.dev> wrote:
>>
>>
>>
>> On 9/9/2026 2:40 PM, Barry Song wrote:
>>> On Mon, Sep 7, 2026 at 12:25 PM Ridong Chen <ridong.chen@linux.dev> wrote:
>>>>
>>>> From: Ridong Chen <chenridong@xiaomi.com>
>>>>
>>>> MGLRU's scan_folios() and evict_folios() emit the classic-LRU
>>>> tracepoints trace_mm_vmscan_lru_isolate() and
>>>> trace_mm_vmscan_lru_shrink_inactive(). Those predate MGLRU and are
>>>> indistinguishable from the classic-LRU path: they carry no generation,
>>>> sequence, memcg or swappiness context, so a trace of an MGLRU run cannot
>>>> tell which memcg a given scan/evict belongs to, nor how far reclaim has
>>>> progressed through the generations.
>>>>
>>>> Add mm_mglru_isolate_folios, emitted once per isolate_folios() call with
>>>> the memcg id, the type actually scanned, the effective swappiness, the
>>>> scanned/isolated counts, and the anon/file min_seq and max_seq. The
>>>> min_seq/max_seq triplet ties each isolation to the generation layout it
>>>> ran against, which the classic-LRU tracepoints cannot express.
>>>>
>>>> This is emitted at the isolate_folios() layer, which is MGLRU-specific
>>>> and has no classic-LRU counterpart, so it neither changes nor duplicates
>>>> the existing scan/evict tracepoints.
>>>>
>>>
>>> I have no objection to MGLRU having some tracepoints. However, one
>>> major concern is that the code is changing rapidly, so the tracepoints
>>> may not be stable. We would need to maintain them as the code evolves.
>>>
>>
>> Indeed. GEN-LRU has been available for several years now, and many vendors are
>> already using it, so adding tracepoints is a necessary step.
>>
>>>> Assisted-by: Claude:claude-opus-4-8
>>>> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
>>>> ---
>>>>    include/trace/events/vmscan.h | 47 +++++++++++++++++++++++++++++++++++
>>>>    mm/vmscan.c                   |  9 ++++++-
>>>>    2 files changed, 55 insertions(+), 1 deletion(-)
>>>>
>>> [...]
>>>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>>>> index 8409ea4bbf37..771fe6827939 100644
>>>> --- a/mm/vmscan.c
>>>> +++ b/mm/vmscan.c
>>> [...]
>>>> @@ -4876,6 +4877,12 @@ static int isolate_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
>>>>                   goto retry;
>>>>           }
>>>>
>>>> +done:
>>>> +       trace_mm_mglru_isolate_folios(mem_cgroup_id(lruvec_memcg(lruvec)),
>>>> +                                     type, swappiness, total_scanned, *isolated,
>>>> +                                     lrugen->min_seq[LRU_GEN_ANON],
>>>> +                                     lrugen->min_seq[LRU_GEN_FILE],
>>>> +                                     lrugen->max_seq);
>>>
>>> Maybe `scan_folios()` would be a better place for this, as it can more
>>> directly reflect what we're doing for each type.
>>>
>>
>> scan_folios() already contains the trace_mm_vmscan_lru_isolate
>> tracepoint(traditional tracepoint), but it lacks any GEN-LRU-specific
>> information. Adding another tracepoint there would be redundant. Therefore, I
>> placed the new tracepoint in isolate_folios(), where it can capture GEN-LRU's
>> specific details. Additionally, it can indicate whether a fallback to the other
>> type has occurred.
> 
> if `trace_mm_vmscan_lru_isolate` is located in `scan_folios()`, that
> would be strong evidence that `scan_folios()` is a better place for
> adding a new tracepoint for LRU gen.
> 
> There is no need to avoid this location just because we already have a
> tracepoint here. In fact, I think this is evidence that it is a better
> place, not the opposite.
> 

Good point.

Thank you very much, that does make sense.

> BTW, `isolate_folios()` might be deleted soon, depending on how we
> improve MGLRU and on some ongoing work from Kairui. But `scan_folios()`
> should be long-lived, as we need to scan folios in any case. Therefore,
> adding tracepoints to `isolate_folios()` doesn't seem to be related to
> the stable ABI concern mentioned in your cover letter.
> 
> Best Regards
> Barry

-- 
Best regards
Ridong



  reply	other threads:[~2026-09-09 12:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  4:24 [PATCH RFC 0/2] mm/mglru: add tracepoints for aging and isolation Ridong Chen
2026-09-07  4:24 ` [PATCH RFC 1/2] mm/mglru: add tracepoint for folio isolation Ridong Chen
2026-09-09  6:40   ` Barry Song
2026-09-09 12:00     ` Ridong Chen
2026-09-09 12:11       ` Barry Song
2026-09-09 12:41         ` Ridong Chen [this message]
2026-09-07  4:24 ` [PATCH RFC 2/2] mm/mglru: add tracepoint for inc_max_seq Ridong Chen
2026-09-09  6:45   ` Barry Song
2026-09-09 12:43     ` Ridong Chen
2026-09-08 13:45 ` [PATCH RFC 0/2] mm/mglru: add tracepoints for aging and isolation Steven Rostedt
2026-09-09 11:37   ` 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=acb81c51-318b-4a00-aad9-515929076662@linux.dev \
    --to=ridong.chen@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=chenridong@xiaomi.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=qi.zheng@linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=shakeel.butt@linux.dev \
    --cc=weixugc@google.com \
    --cc=yuanchu@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;
as well as URLs for NNTP newsgroup(s).