Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: cma: add trace events for CMA allocations and freeings

Add trace events for cma_alloc() and cma_release().

The cma_alloc tracepoint is used both for successful and failed allocations,
in case of allocation failure pfn=-1UL is stored and printed.

Signed-off-by: Stefan Strogin <stefan.strogin@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Michal Nazarewicz <mpn@google.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: Thierry Reding <treding@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Stefan Strogin and committed by
Linus Torvalds
99e8ea6c cdd7875e

+71
+66
include/trace/events/cma.h
··· 1 + #undef TRACE_SYSTEM 2 + #define TRACE_SYSTEM cma 3 + 4 + #if !defined(_TRACE_CMA_H) || defined(TRACE_HEADER_MULTI_READ) 5 + #define _TRACE_CMA_H 6 + 7 + #include <linux/types.h> 8 + #include <linux/tracepoint.h> 9 + 10 + TRACE_EVENT(cma_alloc, 11 + 12 + TP_PROTO(unsigned long pfn, const struct page *page, 13 + unsigned int count, unsigned int align), 14 + 15 + TP_ARGS(pfn, page, count, align), 16 + 17 + TP_STRUCT__entry( 18 + __field(unsigned long, pfn) 19 + __field(const struct page *, page) 20 + __field(unsigned int, count) 21 + __field(unsigned int, align) 22 + ), 23 + 24 + TP_fast_assign( 25 + __entry->pfn = pfn; 26 + __entry->page = page; 27 + __entry->count = count; 28 + __entry->align = align; 29 + ), 30 + 31 + TP_printk("pfn=%lx page=%p count=%u align=%u", 32 + __entry->pfn, 33 + __entry->page, 34 + __entry->count, 35 + __entry->align) 36 + ); 37 + 38 + TRACE_EVENT(cma_release, 39 + 40 + TP_PROTO(unsigned long pfn, const struct page *page, 41 + unsigned int count), 42 + 43 + TP_ARGS(pfn, page, count), 44 + 45 + TP_STRUCT__entry( 46 + __field(unsigned long, pfn) 47 + __field(const struct page *, page) 48 + __field(unsigned int, count) 49 + ), 50 + 51 + TP_fast_assign( 52 + __entry->pfn = pfn; 53 + __entry->page = page; 54 + __entry->count = count; 55 + ), 56 + 57 + TP_printk("pfn=%lx page=%p count=%u", 58 + __entry->pfn, 59 + __entry->page, 60 + __entry->count) 61 + ); 62 + 63 + #endif /* _TRACE_CMA_H */ 64 + 65 + /* This part must be outside protection */ 66 + #include <trace/define_trace.h>
+5
mm/cma.c
··· 23 23 # define DEBUG 24 24 #endif 25 25 #endif 26 + #define CREATE_TRACE_POINTS 26 27 27 28 #include <linux/memblock.h> 28 29 #include <linux/err.h> ··· 35 34 #include <linux/cma.h> 36 35 #include <linux/highmem.h> 37 36 #include <linux/io.h> 37 + #include <trace/events/cma.h> 38 38 39 39 #include "cma.h" 40 40 ··· 416 414 start = bitmap_no + mask + 1; 417 415 } 418 416 417 + trace_cma_alloc(page ? pfn : -1UL, page, count, align); 418 + 419 419 pr_debug("%s(): returned %p\n", __func__, page); 420 420 return page; 421 421 } ··· 450 446 451 447 free_contig_range(pfn, count); 452 448 cma_clear_bitmap(cma, pfn, count); 449 + trace_cma_release(pfn, pages, count); 453 450 454 451 return true; 455 452 }