Re: [PATCH -next v4 2/2] mm: vmscan: add new event to trace shrink lru

From: Steven Rostedt
Date: Wed Dec 20 2023 - 12:35:54 EST


On Tue, 19 Dec 2023 17:21:23 -0800
Bixuan Cui <cuibixuan@xxxxxxxx> wrote:

> diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
> index b99cd28c9815..02868bdc5999 100644
> --- a/include/trace/events/vmscan.h
> +++ b/include/trace/events/vmscan.h
> @@ -395,7 +395,24 @@ TRACE_EVENT(mm_vmscan_write_folio,
> show_reclaim_flags(__entry->reclaim_flags))
> );
>
> -TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
> +TRACE_EVENT(mm_vmscan_lru_shrink_inactive_start,
> +
> + TP_PROTO(int nid),
> +
> + TP_ARGS(nid),
> +
> + TP_STRUCT__entry(
> + __field(int, nid)
> + ),
> +
> + TP_fast_assign(
> + __entry->nid = nid;
> + ),
> +
> + TP_printk("nid=%d", __entry->nid)
> +);
> +
> +TRACE_EVENT(mm_vmscan_lru_shrink_inactive_end,
>
> TP_PROTO(int nid,
> unsigned long nr_scanned, unsigned long nr_reclaimed,
> @@ -446,7 +463,24 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
> show_reclaim_flags(__entry->reclaim_flags))
> );
>
> -TRACE_EVENT(mm_vmscan_lru_shrink_active,
> +TRACE_EVENT(mm_vmscan_lru_shrink_active_start,
> +
> + TP_PROTO(int nid),
> +
> + TP_ARGS(nid),
> +
> + TP_STRUCT__entry(
> + __field(int, nid)
> + ),
> +
> + TP_fast_assign(
> + __entry->nid = nid;
> + ),
> +
> + TP_printk("nid=%d", __entry->nid)
> +);
> +
> +TRACE_EVENT(mm_vmscan_lru_shrink_active_end,
>

These two events are identical, please use DECLARE_EVENT_CLASS and
DEFINE_EVENT macros:

DECLARE_EVENT_CLASS(mm_vmscan_lru_shrink_start_template,

TP_PROTO(int nid),

TP_ARGS(nid),

TP_STRUCT__entry(
__field(int, nid)
),

TP_fast_assign(
__entry->nid = nid;
),

TP_printk("nid=%d", __entry->nid)
);

DEFINE_EVENT(mm_vmscan_lru_shrink_start_template, mm_vmscan_lru_shrink_inactive_start,
TP_PROTO(int nid),
TP_ARGS(nid)
);

DEFINE_EVENT(mm_vmscan_lru_shrink_start_template, mm_vmscan_lru_shrink_active_end,
TP_PROTO(int nid),
TP_ARGS(nid)
);

This saves a bit of memory footprint when doing so.

-- Steve