linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Martin Liu <liumartin@google.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Martin Liu <liumartin@google.com>,
	linux-kernel@vger.kernel.org,
	 linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH v2 3/3] mm/page_alloc: Add trace event for totalreserve_pages calculation
Date: Sat,  8 Mar 2025 03:46:02 +0000	[thread overview]
Message-ID: <20250308034606.2036033-4-liumartin@google.com> (raw)
In-Reply-To: <20250308034606.2036033-1-liumartin@google.com>

This commit introduces a new trace event,
`mm_calculate_totalreserve_pages`, which reports the new reserve value
at the exact time when it takes effect.

The `totalreserve_pages` value represents the total amount of memory
reserved across all zones and nodes in the system. This reserved memory
is crucial for ensuring that critical kernel operations have access to
sufficient memory, even under memory pressure.

By tracing the `totalreserve_pages` value, developers can gain insights
that how the total reserved memory changes over time.

Signed-off-by: Martin Liu <liumartin@google.com>
---
 include/trace/events/kmem.h | 18 ++++++++++++++++++
 mm/page_alloc.c             |  1 +
 2 files changed, 19 insertions(+)

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index 9623e68d4d26..f74925a6cf69 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -402,6 +402,24 @@ TRACE_EVENT(mm_setup_per_zone_lowmem_reserve,
 		  __entry->lowmem_reserve)
 );
 
+TRACE_EVENT(mm_calculate_totalreserve_pages,
+
+	TP_PROTO(unsigned long totalreserve_pages),
+
+	TP_ARGS(totalreserve_pages),
+
+	TP_STRUCT__entry(
+		__field(unsigned long, totalreserve_pages)
+	),
+
+	TP_fast_assign(
+		__entry->totalreserve_pages = totalreserve_pages;
+	),
+
+	TP_printk("totalreserve_pages=%lu", __entry->totalreserve_pages)
+);
+
+
 /*
  * Required for uniquely and securely identifying mm in rss_stat tracepoint.
  */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e472b1275166..69ceab250979 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5827,6 +5827,7 @@ static void calculate_totalreserve_pages(void)
 		}
 	}
 	totalreserve_pages = reserve_pages;
+	trace_mm_calculate_totalreserve_pages(totalreserve_pages);
 }
 
 /*
-- 
2.49.0.rc0.332.g42c0ae87b1-goog



  parent reply	other threads:[~2025-03-08  3:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-08  3:45 [PATCH v2 0/3] Add tracepoints for lowmem reserves, watermarks and totalreserve_pages Martin Liu
2025-03-08  3:46 ` [PATCH v2 1/3] mm/page_alloc: Add trace event for per-zone watermark setup Martin Liu
2025-03-10  0:53   ` David Rientjes
2025-03-08  3:46 ` [PATCH v2 2/3] mm/page_alloc: Add trace event for per-zone lowmem reserve setup Martin Liu
2025-03-10  0:53   ` David Rientjes
2025-03-22  9:03   ` Steven Rostedt
2025-03-08  3:46 ` Martin Liu [this message]
2025-03-10  0:54   ` [PATCH v2 3/3] mm/page_alloc: Add trace event for totalreserve_pages calculation David Rientjes
2025-03-12 15:50 ` [PATCH v2 0/3] Add tracepoints for lowmem reserves, watermarks and totalreserve_pages Martin Liu

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=20250308034606.2036033-4-liumartin@google.com \
    --to=liumartin@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /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