Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/ksm: add tracepoint for ksm advisor

This adds a new tracepoint for the ksm advisor. It reports the last scan
time, the new setting of the pages_to_scan parameter and the average cpu
percent usage of the ksmd background thread for the last scan.

Link: https://lkml.kernel.org/r/20231218231054.1625219-4-shr@devkernel.io
Signed-off-by: Stefan Roesch <shr@devkernel.io>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@surriel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Stefan Roesch and committed by
Andrew Morton
5088b497 66790e9a

+34
+33
include/trace/events/ksm.h
··· 245 245 __entry->pfn, __entry->rmap_item, __entry->mm) 246 246 ); 247 247 248 + /** 249 + * ksm_advisor - called after the advisor has run 250 + * 251 + * @scan_time: scan time in seconds 252 + * @pages_to_scan: new pages_to_scan value 253 + * @cpu_percent: cpu usage in percent 254 + * 255 + * Allows to trace the ksm advisor. 256 + */ 257 + TRACE_EVENT(ksm_advisor, 258 + 259 + TP_PROTO(s64 scan_time, unsigned long pages_to_scan, 260 + unsigned int cpu_percent), 261 + 262 + TP_ARGS(scan_time, pages_to_scan, cpu_percent), 263 + 264 + TP_STRUCT__entry( 265 + __field(s64, scan_time) 266 + __field(unsigned long, pages_to_scan) 267 + __field(unsigned int, cpu_percent) 268 + ), 269 + 270 + TP_fast_assign( 271 + __entry->scan_time = scan_time; 272 + __entry->pages_to_scan = pages_to_scan; 273 + __entry->cpu_percent = cpu_percent; 274 + ), 275 + 276 + TP_printk("ksm scan time %lld pages_to_scan %lu cpu percent %u", 277 + __entry->scan_time, __entry->pages_to_scan, 278 + __entry->cpu_percent) 279 + ); 280 + 248 281 #endif /* _TRACE_KSM_H */ 249 282 250 283 /* This part must be outside protection */
+1
mm/ksm.c
··· 458 458 advisor_ctx.cpu_time = cpu_time; 459 459 460 460 ksm_thread_pages_to_scan = pages; 461 + trace_ksm_advisor(scan_time, pages, cpu_percent); 461 462 } 462 463 463 464 static void advisor_stop_scan(void)