[PATCH] mm: cma: Add the CMA instance name to the cma_alloc_start trace event

From: Georgi Djakov
Date: Fri Mar 26 2021 - 11:55:21 EST


During CMA allocation, print also the name to identify the CMA instance.

Suggested-by: Minchan Kim <minchan@xxxxxxxxxx>
Signed-off-by: Georgi Djakov <georgi.djakov@xxxxxxxxxx>
---
include/trace/events/cma.h | 9 ++++++---
mm/cma.c | 2 +-
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/trace/events/cma.h b/include/trace/events/cma.h
index cdfd06afb39a..be1525a10457 100644
--- a/include/trace/events/cma.h
+++ b/include/trace/events/cma.h
@@ -63,21 +63,24 @@ TRACE_EVENT(cma_release,

TRACE_EVENT(cma_alloc_start,

- TP_PROTO(unsigned int count, unsigned int align),
+ TP_PROTO(const char *name, unsigned int count, unsigned int align),

- TP_ARGS(count, align),
+ TP_ARGS(name, count, align),

TP_STRUCT__entry(
+ __string(name, name)
__field(unsigned int, count)
__field(unsigned int, align)
),

TP_fast_assign(
+ __assign_str(name, name);
__entry->count = count;
__entry->align = align;
),

- TP_printk("count=%u align=%u",
+ TP_printk("name=%s count=%u align=%u",
+ __get_str(name),
__entry->count,
__entry->align)
);
diff --git a/mm/cma.c b/mm/cma.c
index 984c85fd16ec..df5673d0b23d 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -443,7 +443,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
if (!count)
goto out;

- trace_cma_alloc_start(count, align);
+ trace_cma_alloc_start(cma->name, count, align);

mask = cma_bitmap_aligned_mask(cma, align);
offset = cma_bitmap_aligned_offset(cma, align);