Re: [PATCH v2] mm: add alloc_contig_migrate_range allocation statistics

From: Steven Rostedt
Date: Wed Feb 28 2024 - 09:46:00 EST


On Wed, 28 Feb 2024 05:11:17 +0000
Richard Chang <richardycc@xxxxxxxxxx> wrote:

> alloc_contig_migrate_range has every information to be able to
> understand big contiguous allocation latency. For example, how many
> pages are migrated, how many times they were needed to unmap from
> page tables.
>
> This patch adds the trace event to collect the allocation statistics.
> In the field, it was quite useful to understand CMA allocation
> latency.
>
> Signed-off-by: Richard Chang <richardycc@xxxxxxxxxx>
> ---
> * from v1 - https://lore.kernel.org/linux-mm/20240226100045.2083962-1-richardycc@xxxxxxxxxx/
> * Move the trace event int field to the end of the longs - rostedt
> * Do the calculation only when tracing is enabled - rostedt
>
> include/trace/events/kmem.h | 38 +++++++++++++++++++++++++++++++++++++
> mm/internal.h | 3 ++-
> mm/page_alloc.c | 32 ++++++++++++++++++++++++++-----
> mm/page_isolation.c | 2 +-
> 4 files changed, 68 insertions(+), 7 deletions(-)
>
> diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
> index 58688768ef0f..6e62cc64cd92 100644
> --- a/include/trace/events/kmem.h
> +++ b/include/trace/events/kmem.h
> @@ -304,6 +304,44 @@ TRACE_EVENT(mm_page_alloc_extfrag,
> __entry->change_ownership)
> );
>
> +TRACE_EVENT(mm_alloc_contig_migrate_range_info,
> +
> + TP_PROTO(unsigned long start,
> + unsigned long end,
> + unsigned long nr_migrated,
> + unsigned long nr_reclaimed,
> + unsigned long nr_mapped,
> + int migratetype),

Well, you didn't need to change the order of the parameters.

Anyway, from a tracing point of view:

Reviewed-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx.

-- Steve

> +
> + TP_ARGS(start, end, nr_migrated, nr_reclaimed, nr_mapped, migratetype),
> +
> + TP_STRUCT__entry(
> + __field(unsigned long, start)
> + __field(unsigned long, end)
> + __field(unsigned long, nr_migrated)
> + __field(unsigned long, nr_reclaimed)
> + __field(unsigned long, nr_mapped)
> + __field(int, migratetype)
> + ),
> +