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 2/2] mm/mglru: add tracepoint for inc_max_seq
Date: Wed, 9 Sep 2026 20:43:23 +0800 [thread overview]
Message-ID: <ebd30222-01db-491f-852c-bf5261f95f47@linux.dev> (raw)
In-Reply-To: <CAGsJ_4zvJmdiicZAefUyjn4RjP=hBxE95fjpR9HM+SFJ8S_aCQ@mail.gmail.com>
On 9/9/2026 2:45 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>
>>
>> Aging in MGLRU advances max_seq via inc_max_seq(), creating a new
>> youngest generation. There is currently no tracepoint on this path, so
>> the moment a new generation is created, and how the min_seq of each type
>> trails behind it, cannot be observed as it happens.
>>
>> Add mm_mglru_inc_max_seq, emitted right after max_seq is bumped, with
>> the memcg id and the new max_seq alongside the anon and file min_seq.
>> Paired with the mm_mglru_isolate_folios tracepoint it makes the full
>> aging-to-eviction window observable per memcg.
>>
>> Assisted-by: Claude:claude-opus-4-8
>> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
>> ---
>> include/trace/events/vmscan.h | 30 ++++++++++++++++++++++++++++++
>> mm/vmscan.c | 4 ++++
>> 2 files changed, 34 insertions(+)
>>
>> diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
>> index a0e3cf75294b..ab93c2f4b318 100644
>> --- a/include/trace/events/vmscan.h
>> +++ b/include/trace/events/vmscan.h
>> @@ -439,6 +439,36 @@ TRACE_EVENT(mm_mglru_isolate_folios,
>> __entry->max_seq)
>> );
>>
>> +TRACE_EVENT(mm_mglru_inc_max_seq,
>> +
>> + TP_PROTO(u64 memcg_id,
>> + unsigned long max_seq,
>> + unsigned long anon_min_seq,
>> + unsigned long file_min_seq),
>> +
>> + TP_ARGS(memcg_id, max_seq, anon_min_seq, file_min_seq),
>> +
>> + TP_STRUCT__entry(
>> + __field(u64, memcg_id)
>> + __field(unsigned long, max_seq)
>> + __field(unsigned long, anon_min_seq)
>> + __field(unsigned long, file_min_seq)
>> + ),
>> +
>> + TP_fast_assign(
>> + __entry->memcg_id = memcg_id;
>> + __entry->max_seq = max_seq;
>> + __entry->anon_min_seq = anon_min_seq;
>> + __entry->file_min_seq = file_min_seq;
>> + ),
>> +
>> + TP_printk("memcg_id=%llu max_seq=%lu anon_min_seq=%lu file_min_seq=%lu",
>> + __entry->memcg_id,
>> + __entry->max_seq,
>> + __entry->anon_min_seq,
>> + __entry->file_min_seq)
>> +);
>> +
>> TRACE_EVENT(mm_vmscan_write_folio,
>>
>> TP_PROTO(struct folio *folio),
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index 771fe6827939..3c806a57d113 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -4065,6 +4065,10 @@ static bool inc_max_seq(struct lruvec *lruvec, unsigned long seq, int swappiness
>> WRITE_ONCE(lrugen->timestamps[next], jiffies);
>> /* make sure preceding modifications appear */
>> smp_store_release(&lrugen->max_seq, lrugen->max_seq + 1);
>> + trace_mm_mglru_inc_max_seq(mem_cgroup_id(lruvec_memcg(lruvec)),
>> + lrugen->max_seq,
>> + lrugen->min_seq[LRU_GEN_ANON],
>> + lrugen->min_seq[LRU_GEN_FILE]);
>
> I suspect we also want to know the number of pages in each generation,
> similar to:
>
> /sys/kernel/debug # cat lru_gen
> memcg 1 /
> node 0
> 0 25672 0 85
> 1 25672 0 4249
> 2 25672 21 0
> 3 25672 0 0
> memcg 19 /A
> node 0
> 0 23036 0 0
> 1 23036 0 0
> 2 23036 0 0
> 3 23036 0 0
>
Thanks.
Will add.
--
Best regards
Ridong
next prev parent reply other threads:[~2026-09-09 12:43 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
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 [this message]
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=ebd30222-01db-491f-852c-bf5261f95f47@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.