From nobody Fri Sep 25 14:31:01 2026 Received: from mta0.migadu.com (out-129.mta0.migadu.com [91.218.175.129]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 166C546D2BA for ; Fri, 11 Sep 2026 10:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.129 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789122632; cv=none; b=YOYQ45HQ4Ok0jWf2EQOC6KxKYdp4RS7X7Uaz39VYKtYQ7gR7aUumZPbSMb7fGzqEuPGtvI1VJmG/PtwUDxXZFENamBEBuvzB6rG56nu65vDr84wpVsC2ZUKghvt+WL9ZOM58aT3LDCwMR2lb4OGkAWfC77qB/cR7gZkjhtE9fIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789122632; c=relaxed/simple; bh=g5xNOknu84CKDZN5IQmWT85FT3qL1QmesKNb79arhdM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qQ5mDLiHYu1MHCvs9XrFVo4ig1qdbjD2kqpeFZCLBQ0aA+Lse0Co3PPh0RqwUv6+nWldHj9PntxTBo+jpfrCl5AXT9s3dpUqChsnwQqP6HwP0MfBMfXcI1rFXKhlx0JAat4UDSDhTjCQwErGnfEof9PhsEq/W0BEnIbkgR8ZsBE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Aef1eTjV; arc=none smtp.client-ip=91.218.175.129 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Aef1eTjV" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=g5xNOknu84CKDZN5IQmWT85FT3qL1QmesKNb79arhdM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1789122627; v=1; x=1789727427; b=Aef1eTjVrm46A0vgLyFjNEkDfapE3r9tTcoesUBPRE4ALnx1byFWfxRUlT0Z7idyD0MRGNlu VBW/7RXTMySamhx9fqttL+wN2l8lZdOMxMIn7j+shOWWoAIZVgu1Pmp1eAzfHuznCyr/sVpuBi4 wrr0I1CRlX663oDU+kaSWWbI= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id f4fa41675c0fe4c3; Fri, 11 Sep 2026 10:30:04 +0000 X-Mizu-Trace-ID: f4fa41675c0fe4c3 X-Migadu-Flow: FLOW_OUT From: Ridong Chen To: Steven Rostedt , Masami Hiramatsu , Andrew Morton , Johannes Weiner Cc: Mathieu Desnoyers , Kairui Song , Qi Zheng , Shakeel Butt , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , David Hildenbrand , Michal Hocko , Lorenzo Stoakes , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org (open list:MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU)), Ridong Chen , Ridong Chen Subject: [PATCH v2 1/3] mm/mglru: factor out lru_gen_seq_nr_pages() Date: Fri, 11 Sep 2026 18:29:37 +0800 Message-Id: <20260911102939.2485750-2-ridong.chen@linux.dev> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911102939.2485750-1-ridong.chen@linux.dev> References: <20260911102939.2485750-1-ridong.chen@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ridong Chen Both lruvec_evictable_size() and the debugfs lru_gen_seq_show() compute the number of pages in a generation the same way: sum lrugen->nr_pages over all zones for a given (gen, type) and clamp each term to >=3D 0. Factor that out into lru_gen_seq_nr_pages() so the open-coded zone loop lives in one place. No functional change. A follow-up patch adds a tracepoint that needs the same per-generation page count, and will reuse this helper instead of open-coding it again. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ridong Chen Reviewed-by: Baolin Wang Reviewed-by: Baoquan He --- mm/vmscan.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 40d3f1b48a74..2554a6513aa8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2813,6 +2813,18 @@ static int get_nr_gens(struct lruvec *lruvec, int ty= pe) return lruvec->lrugen.max_seq - lruvec->lrugen.min_seq[type] + 1; } =20 +/* the number of pages in a generation, summed over zones and clamped to >= =3D 0 */ +static unsigned long lru_gen_seq_nr_pages(struct lru_gen_folio *lrugen, in= t gen, int type) +{ + int zone; + unsigned long size =3D 0; + + for (zone =3D 0; zone < MAX_NR_ZONES; zone++) + size +=3D max(READ_ONCE(lrugen->nr_pages[gen][type][zone]), 0L); + + return size; +} + static bool __maybe_unused seq_is_valid(struct lruvec *lruvec) { int type; @@ -4239,7 +4251,7 @@ static void set_initial_priority(struct pglist_data *= pgdat, struct scan_control =20 static unsigned long lruvec_evictable_size(struct lruvec *lruvec, int swap= piness) { - int gen, type, zone; + int gen, type; unsigned long seq, total =3D 0; struct lru_gen_folio *lrugen =3D &lruvec->lrugen; DEFINE_MAX_SEQ(lruvec); @@ -4248,8 +4260,7 @@ static unsigned long lruvec_evictable_size(struct lru= vec *lruvec, int swappiness for_each_evictable_type(type, swappiness) { for (seq =3D min_seq[type]; seq <=3D max_seq; seq++) { gen =3D lru_gen_from_seq(seq); - for (zone =3D 0; zone < MAX_NR_ZONES; zone++) - total +=3D max(READ_ONCE(lrugen->nr_pages[gen][type][zone]), 0L); + total +=3D lru_gen_seq_nr_pages(lrugen, gen, type); } } =20 @@ -5738,19 +5749,16 @@ static int lru_gen_seq_show(struct seq_file *m, voi= d *v) seq =3D 0; =20 for (; seq <=3D max_seq; seq++) { - int type, zone; + int type; int gen =3D lru_gen_from_seq(seq); unsigned long birth =3D READ_ONCE(lruvec->lrugen.timestamps[gen]); =20 seq_printf(m, " %10lu %10u", seq, jiffies_to_msecs(jiffies - birth)); =20 for (type =3D 0; type < ANON_AND_FILE; type++) { - unsigned long size =3D 0; + unsigned long size =3D lru_gen_seq_nr_pages(lrugen, gen, type); char mark =3D full && seq < min_seq[type] ? 'x' : ' '; =20 - for (zone =3D 0; zone < MAX_NR_ZONES; zone++) - size +=3D max(READ_ONCE(lrugen->nr_pages[gen][type][zone]), 0L); - seq_printf(m, " %10lu%c", size, mark); } =20 --=20 2.34.1 From nobody Fri Sep 25 14:31:01 2026 Received: from mta0.migadu.com (out-145.mta0.migadu.com [91.218.175.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FF3D46AF3C for ; Fri, 11 Sep 2026 10:30:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789122641; cv=none; b=DVeFltOdXFEggjiJRZ37eiVon8itkVaWN53P4dsV0bL8qo/6JlKYeO74WtgcTiI2OepHGe4gLS9rhNBkcpbQPZ31tcSqVNqMQHjLxpgKFzSfG2h43ynEXyQOp6Tvwtlw9R4xV4DuZo2x0pE+t4aooOOo2W/uwn2RjRpCiFc85ho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789122641; c=relaxed/simple; bh=f5e278sD3gNZ2nE15RiHlcOXf/umzmsjPSOt99uIDKs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CWE3vDxOc7AZlOKgxVDjnRtrwf0IE2IiICQSrHPoq+zQV6FuhbZEadAWQyqm7vdyT8crXjy/pUjtW2edbEv1QDwGKZp06fJKLck4W/yY4Qp82h9k3854eez+BHFTPSYwSI1LsN7b3C6/VSH0kIor2jNir0bJOWEaLtjhGhOMe50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=a1i9gxW9; arc=none smtp.client-ip=91.218.175.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="a1i9gxW9" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=f5e278sD3gNZ2nE15RiHlcOXf/umzmsjPSOt99uIDKs=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1789122637; v=1; x=1789727437; b=a1i9gxW9iuVtYN3wWZ2tqB50zw/lmzUSnqUg0inrvBsJXHd1htJsAaOTW+PU4OasyviCyKQf viEt4FQTpT26qST2EUfNFmWQjIaZXgWeShUGL06wPcg6epVy5/qoe6s/z2PK3h3uI0vsPsQ/gfq NqvfkMbOEx97Dm2fgQ8+AZOo= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 5d4f4926e87c551a; Fri, 11 Sep 2026 10:30:36 +0000 X-Mizu-Trace-ID: 5d4f4926e87c551a X-Migadu-Flow: FLOW_OUT From: Ridong Chen To: Steven Rostedt , Masami Hiramatsu , Andrew Morton , Johannes Weiner Cc: Mathieu Desnoyers , Kairui Song , Qi Zheng , Shakeel Butt , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , David Hildenbrand , Michal Hocko , Lorenzo Stoakes , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org (open list:MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU)), Ridong Chen , Ridong Chen Subject: [PATCH v2 2/3] mm/mglru: add tracepoint for scan_folios() Date: Fri, 11 Sep 2026 18:29:38 +0800 Message-Id: <20260911102939.2485750-3-ridong.chen@linux.dev> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911102939.2485750-1-ridong.chen@linux.dev> References: <20260911102939.2485750-1-ridong.chen@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ridong Chen MGLRU's scan_folios() emits the classic-LRU tracepoint trace_mm_vmscan_lru_isolate(), which predates MGLRU. It reports the scan/isolate counts and the LRU type, but carries no generation or memcg context, so a trace of an MGLRU run cannot tell which memcg a given scan belongs to, nor how far reclaim has progressed through the generations. Add mm_mglru_scan_folios next to it, reporting the same counters plus nr_sorted (folios moved to a younger generation by sort_folio()) and the MGLRU context the classic tracepoint lacks: the memcg id, and the max_seq, tier and min_seq of the type being scanned. scan_folios() is the MGLRU-specific layer where folios are actually scanned, so it has no classic-LRU counterpart. That the classic trace_mm_vmscan_lru_isolate() has lived here stably shows this is a long-lived place to hook, and the new tracepoint can be enabled on its own to observe the MGLRU-specific information. The existing tracepoint is left unchanged. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ridong Chen --- include/trace/events/vmscan.h | 63 +++++++++++++++++++++++++++++++++++ mm/vmscan.c | 6 ++++ 2 files changed, 69 insertions(+) diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index 8a872990b4be..5defa8f6719c 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h @@ -392,6 +392,69 @@ TRACE_EVENT(mm_vmscan_lru_isolate, __print_symbolic(__entry->lru, LRU_NAMES)) ); =20 +TRACE_EVENT(mm_mglru_scan_folios, + + TP_PROTO(struct lruvec *lruvec, + int highest_zoneidx, + int order, + unsigned long nr_requested, + unsigned long nr_scanned, + unsigned long nr_sorted, + unsigned long nr_skipped, + unsigned long nr_taken, + int lru, + unsigned long max_seq, + int tier, + unsigned long min_seq), + + TP_ARGS(lruvec, highest_zoneidx, order, nr_requested, nr_scanned, + nr_sorted, nr_skipped, nr_taken, lru, max_seq, tier, min_seq), + + TP_STRUCT__entry( + __field(u64, memcg_id) + __field(int, highest_zoneidx) + __field(int, order) + __field(unsigned long, nr_requested) + __field(unsigned long, nr_scanned) + __field(unsigned long, nr_sorted) + __field(unsigned long, nr_skipped) + __field(unsigned long, nr_taken) + __field(int, lru) + __field(unsigned long, max_seq) + __field(int, tier) + __field(unsigned long, min_seq) + ), + + TP_fast_assign( + __entry->memcg_id =3D mem_cgroup_id(lruvec_memcg(lruvec)); + __entry->highest_zoneidx =3D highest_zoneidx; + __entry->order =3D order; + __entry->nr_requested =3D nr_requested; + __entry->nr_scanned =3D nr_scanned; + __entry->nr_sorted =3D nr_sorted; + __entry->nr_skipped =3D nr_skipped; + __entry->nr_taken =3D nr_taken; + __entry->lru =3D lru; + __entry->max_seq =3D max_seq; + __entry->tier =3D tier; + __entry->min_seq =3D min_seq; + ), + + TP_printk("memcg_id=3D%llu classzone=3D%d order=3D%d nr_requested=3D%lu n= r_scanned=3D%lu nr_sorted=3D%lu nr_skipped=3D%lu nr_taken=3D%lu lru=3D%s ma= x_seq=3D%lu tier=3D%d min_seq=3D%lu", + __entry->memcg_id, + __entry->highest_zoneidx, + __entry->order, + __entry->nr_requested, + __entry->nr_scanned, + __entry->nr_sorted, + __entry->nr_skipped, + __entry->nr_taken, + __print_symbolic(__entry->lru, LRU_NAMES), + __entry->max_seq, + __entry->tier, + __entry->min_seq) +); + TRACE_EVENT(mm_vmscan_write_folio, =20 TP_PROTO(struct folio *folio), diff --git a/mm/vmscan.c b/mm/vmscan.c index 2554a6513aa8..67f59aa73fb9 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4876,6 +4876,12 @@ static int scan_folios(unsigned long nr_to_scan, str= uct lruvec *lruvec, trace_mm_vmscan_lru_isolate(sc->reclaim_idx, sc->order, nr_to_scan, scanned, skipped, isolated, type ? LRU_INACTIVE_FILE : LRU_INACTIVE_ANON); + trace_mm_mglru_scan_folios(lruvec, + sc->reclaim_idx, sc->order, nr_to_scan, + scanned, sorted, skipped, isolated, + type ? LRU_INACTIVE_FILE : LRU_INACTIVE_ANON, + lrugen->max_seq, tier, + lrugen->min_seq[type]); =20 *isolatedp =3D isolated; return scanned; --=20 2.34.1 From nobody Fri Sep 25 14:31:01 2026 Received: from mta0.migadu.com (out-158.mta0.migadu.com [91.218.175.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08AC4448B82 for ; Fri, 11 Sep 2026 10:30:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789122648; cv=none; b=Ri+OwBMfBZytqRgmtdUdpD+TcoACjLwkNOJLqR0x87YvuTag5jb8GXsA/NFWEqHn9Lycz89Dqv9xLwpdO8YxuoGnKP9vQtVLeTPuKEn+ry6dLDXkqiW9cZy/P3y4AwF+M5mUkBJBoTZ44PjtwmYb+diV1eI9njNaZ6DtzlGYyuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789122648; c=relaxed/simple; bh=g+Mf/kGaBSRXqlRStbFxv9nvRzYBpUgfPbFtW3GN2lM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fNTd3VUaoifpBhO8xmmPCSrvkXilbtIvfPh4d6XmwKV0dRfmQSNfyCqFbfxs14Jd7xinysUyyyb8UISp+BHsNbNrHIK0g3Y409gkEDwG7IHpey2V1Zi2GSAgM5JKVhvwLoPLhHLpp/gJLgoZb9zDbbPht85OXKiRB+oIKft8GoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=BzEEi9MF; arc=none smtp.client-ip=91.218.175.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="BzEEi9MF" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=g+Mf/kGaBSRXqlRStbFxv9nvRzYBpUgfPbFtW3GN2lM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1789122643; v=1; x=1789727443; b=BzEEi9MFIx2W5/R4L8onsD37pl0LiBvCvmUbhg0dhfrids0Qo7MXMe2CcZuwoed//NL0I3kV /jckL3QZvm+TWpsQyu+ZOwEF6nmYLh0HD8wSbAHs1nfiLZ7Uj6GcrNTpbjxMQuO5CKS1S2YEiZ8 gIqrNZjQK5YLbQB0rbSDr1pQ= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 4018faa0ac020977; Fri, 11 Sep 2026 10:30:43 +0000 X-Mizu-Trace-ID: 4018faa0ac020977 X-Migadu-Flow: FLOW_OUT From: Ridong Chen To: Steven Rostedt , Masami Hiramatsu , Andrew Morton , Johannes Weiner Cc: Mathieu Desnoyers , Kairui Song , Qi Zheng , Shakeel Butt , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , David Hildenbrand , Michal Hocko , Lorenzo Stoakes , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org (open list:MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU)), Ridong Chen , Ridong Chen Subject: [PATCH v2 3/3] mm/mglru: add tracepoint for inc_max_seq() Date: Fri, 11 Sep 2026 18:29:39 +0800 Message-Id: <20260911102939.2485750-4-ridong.chen@linux.dev> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911102939.2485750-1-ridong.chen@linux.dev> References: <20260911102939.2485750-1-ridong.chen@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ridong Chen 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, the new max_seq, the anon and file min_seq, and the number of pages in each generation for both types, summed over zones the same way the debugfs lru_gen file reports them. The nr_anon/nr_file arrays are indexed by generation slot, so the emitted max_seq/min_seq say which slot holds which seq. They are printed with __print_array(), so the output is hex and its length follows MAX_NR_GENS automatically. Paired with the mm_mglru_scan_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 Reviewed-by: Baolin Wang --- include/trace/events/vmscan.h | 38 +++++++++++++++++++++++++++++++++++ mm/vmscan.c | 23 +++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index 5defa8f6719c..a20c6b2e062f 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h @@ -455,6 +455,44 @@ TRACE_EVENT(mm_mglru_scan_folios, __entry->min_seq) ); =20 +TRACE_EVENT(mm_mglru_inc_max_seq, + + TP_PROTO(struct lruvec *lruvec, + unsigned long max_seq, + unsigned long anon_min_seq, + unsigned long file_min_seq, + unsigned long *nr_anon, + unsigned long *nr_file), + + TP_ARGS(lruvec, max_seq, anon_min_seq, file_min_seq, nr_anon, nr_file), + + TP_STRUCT__entry( + __field(u64, memcg_id) + __field(unsigned long, max_seq) + __field(unsigned long, anon_min_seq) + __field(unsigned long, file_min_seq) + __array(unsigned long, nr_anon, MAX_NR_GENS) + __array(unsigned long, nr_file, MAX_NR_GENS) + ), + + TP_fast_assign( + __entry->memcg_id =3D mem_cgroup_id(lruvec_memcg(lruvec)); + __entry->max_seq =3D max_seq; + __entry->anon_min_seq =3D anon_min_seq; + __entry->file_min_seq =3D file_min_seq; + memcpy(__entry->nr_anon, nr_anon, sizeof(__entry->nr_anon)); + memcpy(__entry->nr_file, nr_file, sizeof(__entry->nr_file)); + ), + + TP_printk("memcg_id=3D%llu max_seq=3D%lu anon_min_seq=3D%lu file_min_seq= =3D%lu nr_anon=3D%s nr_file=3D%s", + __entry->memcg_id, + __entry->max_seq, + __entry->anon_min_seq, + __entry->file_min_seq, + __print_array(__entry->nr_anon, MAX_NR_GENS, sizeof(unsigned long)), + __print_array(__entry->nr_file, MAX_NR_GENS, sizeof(unsigned long))) +); + TRACE_EVENT(mm_vmscan_write_folio, =20 TP_PROTO(struct folio *folio), diff --git a/mm/vmscan.c b/mm/vmscan.c index 67f59aa73fb9..d1495a7d469d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4100,6 +4100,27 @@ static void try_to_inc_min_seq(struct lruvec *lruvec= , int swappiness) } } =20 +static void trace_inc_max_seq(struct lruvec *lruvec) +{ + int type, gen; + unsigned long nr[ANON_AND_FILE][MAX_NR_GENS]; + struct lru_gen_folio *lrugen; + + if (!trace_mm_mglru_inc_max_seq_enabled()) + return; + + lrugen =3D &lruvec->lrugen; + for (type =3D 0; type < ANON_AND_FILE; type++) + for (gen =3D 0; gen < MAX_NR_GENS; gen++) + nr[type][gen] =3D lru_gen_seq_nr_pages(lrugen, gen, type); + + trace_mm_mglru_inc_max_seq(lruvec, + lrugen->max_seq, + lrugen->min_seq[LRU_GEN_ANON], + lrugen->min_seq[LRU_GEN_FILE], + nr[LRU_GEN_ANON], nr[LRU_GEN_FILE]); +} + static bool inc_max_seq(struct lruvec *lruvec, unsigned long seq, int swap= piness) { bool success; @@ -4159,6 +4180,8 @@ static bool inc_max_seq(struct lruvec *lruvec, unsign= ed 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_inc_max_seq(lruvec); unlock: lruvec_unlock_irq(lruvec); =20 --=20 2.34.1