lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231004190249.829015-4-shr@devkernel.io>
Date:   Wed,  4 Oct 2023 12:02:48 -0700
From:   Stefan Roesch <shr@...kernel.io>
To:     kernel-team@...com
Cc:     shr@...kernel.io, akpm@...ux-foundation.org, david@...hat.com,
        hannes@...xchg.org, riel@...riel.com, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org
Subject: [PATCH v1 3/4] mm/ksm: add tracepoint for ksm advisor

This adds a new tracepoint for the ksm advisor. It reports the last scan
time and the new setting of the pages_to_scan parameter.

Signed-off-by: Stefan Roesch <shr@...kernel.io>
---
 include/trace/events/ksm.h | 28 ++++++++++++++++++++++++++++
 mm/ksm.c                   |  2 ++
 2 files changed, 30 insertions(+)

diff --git a/include/trace/events/ksm.h b/include/trace/events/ksm.h
index b5ac35c1d0e8..164133014922 100644
--- a/include/trace/events/ksm.h
+++ b/include/trace/events/ksm.h
@@ -245,6 +245,34 @@ TRACE_EVENT(ksm_remove_rmap_item,
 			__entry->pfn, __entry->rmap_item, __entry->mm)
 );
 
+/**
+ * ksm_advisor - called after the advisor has run
+ *
+ * @scan_time:		scan time in seconds
+ * @pages_to_scan:	new pages_to_scan value
+ *
+ * Allows to trace the ksm advisor.
+ */
+TRACE_EVENT(ksm_advisor,
+
+	TP_PROTO(s64 scan_time, unsigned long pages_to_scan),
+
+	TP_ARGS(scan_time, pages_to_scan),
+
+	TP_STRUCT__entry(
+		__field(s64,		scan_time)
+		__field(unsigned long,	pages_to_scan)
+	),
+
+	TP_fast_assign(
+		__entry->scan_time	= scan_time;
+		__entry->pages_to_scan	= pages_to_scan;
+	),
+
+	TP_printk("ksm scan time %lld pages_to_scan %lu",
+			__entry->scan_time, __entry->pages_to_scan)
+);
+
 #endif /* _TRACE_KSM_H */
 
 /* This part must be outside protection */
diff --git a/mm/ksm.c b/mm/ksm.c
index 12e70f806b2b..93dff974f6ea 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -415,6 +415,8 @@ static void scan_time_advisor(s64 scan_time)
 	advisor_ctx.change = change;
 	advisor_ctx.scan_time = scan_time;
 	ksm_thread_pages_to_scan = pages;
+
+	trace_ksm_advisor(scan_time, pages);
 }
 
 static void run_advisor(void)
-- 
2.39.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ