All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ridong Chen <ridong.chen@linux.dev>
To: Steven Rostedt <rostedt@goodmis.org>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Baoquan He <baoquan.he@linux.dev>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Kairui Song <kasong@tencent.com>, Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Barry Song <baohua@kernel.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	David Hildenbrand <david@kernel.org>,
	Michal Hocko <mhocko@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	"open list:MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU)"
	<linux-mm@kvack.org>, Ridong Chen <chenridong@xiaomi.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [PATCH v2 0/3] mm/mglru: add tracepoints for scan and aging paths
Date: Mon, 19 Oct 2026 14:21:39 +0800	[thread overview]
Message-ID: <8ed89bac-d9f0-4dba-b733-7d678a4b47ac@linux.dev> (raw)
In-Reply-To: <20260911102939.2485750-1-ridong.chen@linux.dev>



On 9/11/2026 6:29 PM, Ridong Chen wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
> 
> Background
> ==========
> 
> MGLRU currently has no tracepoints of its own. The scan and evict paths
> reuse the classic-LRU tracepoints (trace_mm_vmscan_lru_isolate() and
> trace_mm_vmscan_lru_shrink_inactive()), which predate MGLRU and carry no
> generation, sequence, memcg or swappiness context. A trace of a running
> system therefore cannot tell which memcg a given scan belongs to, how far
> reclaim has progressed through the generations, or when a new generation
> is created - so how MGLRU actually operates is effectively invisible.
> 
> Implementation
> ==============
> 
> Patch 1 is a cleanup that factors the per-generation page-count
> summation into a helper, lru_gen_seq_nr_pages(), reused by patch 3.
> 
> Patch 2 adds mm_mglru_scan_folios on the scan path, and patch 3 adds
> mm_mglru_inc_max_seq on the aging path. Both carry the memcg id and the
> generation window (min_seq/max_seq), live at MGLRU-specific layers with
> no classic-LRU counterpart, and are guarded so the hot paths stay
> zero-cost when disabled.
> 
> Effect
> ======
> 
> Paired, the two tracepoints make the full aging-to-eviction window
> observable per memcg: aging advances max_seq (the leading edge), scanning
> consumes the oldest generations, and the min_seq/max_seq pair on each
> event shows how the generation window moves over time.
> 
> A sample trace, with the classic-LRU tracepoints left enabled to show
> how they interleave:
> 
>    mm_vmscan_lru_isolate: classzone=4 order=0 nr_requested=36 nr_scanned=31 nr_skipped=0 nr_taken=29 lru=inactive_file
>    mm_mglru_scan_folios: memcg_id=73 classzone=4 order=0 nr_requested=36 nr_scanned=31 nr_sorted=2 nr_skipped=0 nr_taken=29 lru=inactive_file max_seq=3 tier=3 min_seq=0
>    mm_vmscan_lru_shrink_inactive: nid=0 nr_scanned=31 nr_reclaimed=29 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=0 nr_unmap_fail=0 priority=5 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
>    mm_mglru_inc_max_seq: memcg_id=73 max_seq=4 anon_min_seq=1 file_min_seq=1 nr_anon={0x0,0x0,0x1,0x0} nr_file={0x0,0x427,0x6,0x4a}
>    mm_vmscan_lru_isolate: classzone=4 order=0 nr_requested=5 nr_scanned=5 nr_skipped=0 nr_taken=1 lru=inactive_file
>    mm_mglru_scan_folios: memcg_id=73 classzone=4 order=0 nr_requested=5 nr_scanned=5 nr_sorted=4 nr_skipped=0 nr_taken=1 lru=inactive_file max_seq=4 tier=3 min_seq=1
>    mm_vmscan_lru_shrink_inactive: nid=0 nr_scanned=5 nr_reclaimed=1 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=0 nr_unmap_fail=0 priority=5 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
> 
> The mm_mglru_scan_folios lines carry the memcg id and the generation
> window (max_seq/min_seq) that the bare mm_vmscan_lru_isolate lines above
> them cannot - those cannot even say which memcg they came from. The
> mm_mglru_inc_max_seq line then shows a new generation being created
> (max_seq 3 -> 4) with the per-generation page counts for both types.
> 
> ---
> v2: address Sashiko AI review [1] - pass struct lruvec * into the tracepoints
>      and do the memcg lookup inside TP_fast_assign.
> 
> [1] https://sashiko.dev/#/patchset/20260911072848.2346073-1-ridong.chen@linux.dev?part=2
> 
> Ridong Chen (3):
>    mm/mglru: factor out lru_gen_seq_nr_pages()
>    mm/mglru: add tracepoint for scan_folios()
>    mm/mglru: add tracepoint for inc_max_seq()
> 
>   include/trace/events/vmscan.h | 101 ++++++++++++++++++++++++++++++++++
>   mm/vmscan.c                   |  53 +++++++++++++++---
>   2 files changed, 146 insertions(+), 8 deletions(-)
> 

Hi Steven, Baolin and Baoquan,

Thanks again for reviewing v2.

Following Steven's suggestion in this thread, I first moved the vmscan
trace header under mm/ and exposed struct scan_control to it in a
separate RFC series. Patches [2/3] and [3/3] of v2 have now been
reworked on top of that and posted together with it as one series:

   [PATCH v4 0/9] mm/vmscan: move tracepoints to mm/ and add MGLRU
   tracepoints
   https://lore.kernel.org/all/20261019034426.2354049-1-ridong.chen@linux.dev/

The two MGLRU tracepoints are [8/9] and [9/9] there. Compared with v2:

- Both events now take only lruvec/sc plus the local counters, and
   derive everything else (memcg id, order, reclaim_idx, lru, max_seq,
   min_seq and the per-generation page counts) in TP_fast_assign()
   (Steven).
- Add nid, derived from lruvec_pgdat(lruvec) (Baoquan).
- Group the int fields at the end of the entry to avoid padding on
   64-bit (Steven).
- Drop v2 [1/3] "mm/mglru: factor out lru_gen_seq_nr_pages()": the
   per-generation page count is now summed inside TP_fast_assign(), so
   the helper has no user left.

Since [8/9] and [9/9] changed substantially, I did not carry over your
Reviewed-by tags. I would really appreciate it if you could take
another look at v4.

-- 
Best regards
Ridong


      parent reply	other threads:[~2026-10-19  6:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 10:29 [PATCH v2 0/3] mm/mglru: add tracepoints for scan and aging paths Ridong Chen
2026-09-11 10:29 ` [PATCH v2 1/3] mm/mglru: factor out lru_gen_seq_nr_pages() Ridong Chen
2026-09-14  7:09   ` Baolin Wang
2026-09-15  6:32   ` Baoquan He
2026-09-11 10:29 ` [PATCH v2 2/3] mm/mglru: add tracepoint for scan_folios() Ridong Chen
2026-09-14  7:47   ` Baolin Wang
2026-09-14  9:04     ` Ridong Chen
2026-09-15 11:14   ` Baoquan He
2026-09-15 12:17     ` Ridong Chen
2026-09-16  2:14       ` Baoquan He
2026-09-16 12:17         ` Ridong Chen
2026-09-17  1:07           ` Baoquan He
2026-09-17  3:12             ` Ridong Chen
2026-09-16 13:51         ` Steven Rostedt
2026-09-17  1:23           ` Baoquan He
2026-09-17  3:21             ` Ridong Chen
2026-09-11 10:29 ` [PATCH v2 3/3] mm/mglru: add tracepoint for inc_max_seq() Ridong Chen
2026-09-14  7:38   ` Baolin Wang
2026-10-19  6:21 ` Ridong Chen [this message]

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=8ed89bac-d9f0-4dba-b733-7d678a4b47ac@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=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.