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

Configure Feed

Select the types of activity you want to include in your feed.

mm/page_alloc: add trace event for per-zone watermark setup

Patch series "Add tracepoints for lowmem reserves, watermarks and
totalreserve_pages", v2.

This patchset introduces tracepoints to track changes in the lowmem
reserves, watermarks and totalreserve_pages. This helps to track
the exact timing of such changes and understand their relation to
reclaim activities.

The tracepoints added are:

mm_setup_per_zone_lowmem_reserve
mm_setup_per_zone_wmarks
mm_calculate_totalreserve_pagesi


This patch (of 3):

This commit introduces the `mm_setup_per_zone_wmarks` trace event,
which provides detailed insights into the kernel's per-zone watermark
configuration, offering precise timing and the ability to correlate
watermark changes with specific kernel events.

While `/proc/zoneinfo` provides some information about zone watermarks,
this trace event offers:

1. The ability to link watermark changes to specific kernel events and
logic.

2. The ability to capture rapid or short-lived changes in watermarks
that may be missed by user-space polling

3. Diagnosing unexpected kswapd activity or excessive direct reclaim
triggered by rapidly changing watermarks.

Link: https://lkml.kernel.org/r/20250308034606.2036033-1-liumartin@google.com
Link: https://lkml.kernel.org/r/20250308034606.2036033-2-liumartin@google.com
Signed-off-by: Martin Liu <liumartin@google.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Martin Liu <liumartin@google.com>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Martin Liu and committed by
Andrew Morton
8c02048d 116eb468

+34
+33
include/trace/events/kmem.h
··· 342 342 __entry->nr_mapped) 343 343 ); 344 344 345 + TRACE_EVENT(mm_setup_per_zone_wmarks, 346 + 347 + TP_PROTO(struct zone *zone), 348 + 349 + TP_ARGS(zone), 350 + 351 + TP_STRUCT__entry( 352 + __field(int, node_id) 353 + __string(name, zone->name) 354 + __field(unsigned long, watermark_min) 355 + __field(unsigned long, watermark_low) 356 + __field(unsigned long, watermark_high) 357 + __field(unsigned long, watermark_promo) 358 + ), 359 + 360 + TP_fast_assign( 361 + __entry->node_id = zone->zone_pgdat->node_id; 362 + __assign_str(name); 363 + __entry->watermark_min = zone->_watermark[WMARK_MIN]; 364 + __entry->watermark_low = zone->_watermark[WMARK_LOW]; 365 + __entry->watermark_high = zone->_watermark[WMARK_HIGH]; 366 + __entry->watermark_promo = zone->_watermark[WMARK_PROMO]; 367 + ), 368 + 369 + TP_printk("node_id=%d zone name=%s watermark min=%lu low=%lu high=%lu promo=%lu", 370 + __entry->node_id, 371 + __get_str(name), 372 + __entry->watermark_min, 373 + __entry->watermark_low, 374 + __entry->watermark_high, 375 + __entry->watermark_promo) 376 + ); 377 + 345 378 /* 346 379 * Required for uniquely and securely identifying mm in rss_stat tracepoint. 347 380 */
+1
mm/page_alloc.c
··· 6006 6006 zone->_watermark[WMARK_LOW] = min_wmark_pages(zone) + tmp; 6007 6007 zone->_watermark[WMARK_HIGH] = low_wmark_pages(zone) + tmp; 6008 6008 zone->_watermark[WMARK_PROMO] = high_wmark_pages(zone) + tmp; 6009 + trace_mm_setup_per_zone_wmarks(zone); 6009 6010 6010 6011 spin_unlock_irqrestore(&zone->lock, flags); 6011 6012 }