Re: [RFC PATCH V3 14/17] trace/kscand: Add tracing of scanning and migration

Jonathan Cameron
2025-10-03T10:28:55Z

On Thu, 14 Aug 2025 15:33:04 +0000
Raghavendra K T <raghavendra.kt@amd.com> wrote:

> Add tracing support to track
> - start and end of scanning.
> - migration.
>
> CC: Steven Rostedt <rostedt@goodmis.org>
> CC: Masami Hiramatsu <mhiramat@kernel.org>
> CC: linux-trace-kernel@vger.kernel.org
>
CC s are part of tags block so no blank line.

Probably move them under the --- as I doubt we need to keep these
in the git log long term.

> Signed-off-by: Raghavendra K T <raghavendra.kt@amd.com>
> ---
> include/trace/events/kmem.h | 99 +++++++++++++++++++++++++++++++++++++
> mm/kscand.c | 9 ++++
> 2 files changed, 108 insertions(+)
>
> diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
> index f74925a6cf69..d6e544b067b9 100644
> --- a/include/trace/events/kmem.h
> +++ b/include/trace/events/kmem.h
> @@ -9,6 +9,105 @@
> #include <linux/tracepoint.h>
> #include <trace/events/mmflags.h>
>
> +#ifdef CONFIG_KSCAND
> +DECLARE_EVENT_CLASS(kmem_mm_class,
> +
> + TP_PROTO(struct mm_struct *mm),
> +
> + TP_ARGS(mm),
> +
> + TP_STRUCT__entry(
> + __field( struct mm_struct *, mm )

Trace header formatting is sometimes interesting. But I have no
idea why you have this padded like that.

> + ),
> +
> + TP_fast_assign(
> + __entry->mm = mm;
> + ),
> +
> + TP_printk("mm = %p", __entry->mm)
> +);
> +
> +DEFINE_EVENT(kmem_mm_class, kmem_mm_enter,
> + TP_PROTO(struct mm_struct *mm),
> + TP_ARGS(mm)
> +);
> +
> +DEFINE_EVENT(kmem_mm_class, kmem_mm_exit,
> + TP_PROTO(struct mm_struct *mm),
> + TP_ARGS(mm)
> +);
> +
> +DEFINE_EVENT(kmem_mm_class, kmem_scan_mm_start,
> + TP_PROTO(struct mm_struct *mm),
> + TP_ARGS(mm)
> +);
> +
> +TRACE_EVENT(kmem_scan_mm_end,
> +
> + TP_PROTO( struct mm_struct *mm,
> + unsigned long start,
> + unsigned long total,
> + unsigned long scan_period,
> + unsigned long scan_size,
> + int target_node),
> +
> + TP_ARGS(mm, start, total, scan_period, scan_size, target_node),
> +
> + TP_STRUCT__entry(
> + __field( struct mm_struct *, mm )
> + __field( unsigned long, start )
> + __field( unsigned long, total )
> + __field( unsigned long, scan_period )
> + __field( unsigned long, scan_size )
> + __field( int, target_node )

Similar. Aligning stuff might make sense but why the spacing before the type?