[PATCH] mm/cma: add 'available count' and 'total count' to trace_cma_alloc_start

Xiang Gao posted 1 patch 1 month, 2 weeks ago
include/trace/events/cma.h | 17 ++++++++++++-----
mm/cma.c                   |  2 +-
2 files changed, 13 insertions(+), 6 deletions(-)
[PATCH] mm/cma: add 'available count' and 'total count' to trace_cma_alloc_start
Posted by Xiang Gao 1 month, 2 weeks ago
From: gaoxiang17 <gaoxiang17@xiaomi.com>

This makes cma info more intuitive during debugging.

Signed-off-by: gaoxiang17 <gaoxiang17@xiaomi.com>
---
 include/trace/events/cma.h | 17 ++++++++++++-----
 mm/cma.c                   |  2 +-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/include/trace/events/cma.h b/include/trace/events/cma.h
index 383c09f583ac..fbe70008ffc7 100644
--- a/include/trace/events/cma.h
+++ b/include/trace/events/cma.h
@@ -38,25 +38,32 @@ TRACE_EVENT(cma_release,
 
 TRACE_EVENT(cma_alloc_start,
 
-	TP_PROTO(const char *name, unsigned long count, unsigned int align),
+	TP_PROTO(const char *name, unsigned long request_count, unsigned long available_count,
+		unsigned long total_count, unsigned int align),
 
-	TP_ARGS(name, count, align),
+	TP_ARGS(name, request_count, available_count, total_count, align),
 
 	TP_STRUCT__entry(
 		__string(name, name)
-		__field(unsigned long, count)
+		__field(unsigned long, request_count)
+		__field(unsigned long, available_count)
+		__field(unsigned long, total_count)
 		__field(unsigned int, align)
 	),
 
 	TP_fast_assign(
 		__assign_str(name);
-		__entry->count = count;
+		__entry->count = request_count;
+		__entry->available_count = available_count;
+		__entry->total_count = total_count;
 		__entry->align = align;
 	),
 
 	TP_printk("name=%s count=%lu align=%u",
 		  __get_str(name),
-		  __entry->count,
+		  __entry->request_count,
+		  __entry->available_count,
+		  __entry->total_count,
 		  __entry->align)
 );
 
diff --git a/mm/cma.c b/mm/cma.c
index 2ffa4befb99a..e56ec64d0567 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -864,7 +864,7 @@ static struct page *__cma_alloc(struct cma *cma, unsigned long count,
 	if (!count)
 		return page;
 
-	trace_cma_alloc_start(name, count, align);
+	trace_cma_alloc_start(name, count, cma->available_count, cma->count, align);
 
 	for (r = 0; r < cma->nranges; r++) {
 		page = NULL;
-- 
2.34.1
Re: [PATCH] mm/cma: add 'available count' and 'total count' to trace_cma_alloc_start
Posted by Andrew Morton 1 month, 2 weeks ago
On Tue, 19 Aug 2025 21:48:17 +0800 Xiang Gao <gxxa03070307@gmail.com> wrote:

> From: gaoxiang17 <gaoxiang17@xiaomi.com>
> 
> This makes cma info more intuitive during debugging.
> 
> ...
>
> --- a/include/trace/events/cma.h
> +++ b/include/trace/events/cma.h
>
> ...
>
>  	TP_STRUCT__entry(
>  		__string(name, name)
> -		__field(unsigned long, count)
> +		__field(unsigned long, request_count)
> +		__field(unsigned long, available_count)
> +		__field(unsigned long, total_count)
>  		__field(unsigned int, align)
>  	),
>  
>  	TP_fast_assign(
>  		__assign_str(name);
> -		__entry->count = count;
> +		__entry->count = request_count;
> +		__entry->available_count = available_count;
> +		__entry->total_count = total_count;
>  		__entry->align = align;
>  	),
>  
>  	TP_printk("name=%s count=%lu align=%u",
>  		  __get_str(name),
> -		  __entry->count,
> +		  __entry->request_count,
> +		  __entry->available_count,
> +		  __entry->total_count,
>  		  __entry->align)

adds three args to the printk but didn't add their conversions to the
printk control string?
Re: [PATCH] mm/cma: add 'available count' and 'total count' to trace_cma_alloc_start
Posted by David Hildenbrand 1 month, 2 weeks ago
On 19.08.25 15:48, Xiang Gao wrote:
> From: gaoxiang17 <gaoxiang17@xiaomi.com>
> 
> This makes cma info more intuitive during debugging.
> 
> Signed-off-by: gaoxiang17 <gaoxiang17@xiaomi.com>
> ---

For the next time: you should have indicated that this is v2 ([PATCH 
v2]) and briefly described under the "---" the changes between v1 and v2.

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers

David / dhildenb