@@ -95,6 +95,7 @@ int xe_devm_alloc_pages(struct xe_tile *tile,
block->private = meta;
block_pfn_first =
block_offset_to_pfn(mr, drm_buddy_block_offset(block));
+ trace_xe_buddy_block_alloc(block, size, block_pfn_first);
for(i = 0; i < pages_per_block; i++) {
struct page *page;
@@ -159,8 +160,10 @@ void xe_devm_page_free(struct page *page)
xe_assert(tile->xe, i < pages_per_block);
clear_bit(i, meta->bitmap);
- if (bitmap_empty(meta->bitmap, pages_per_block))
+ if (bitmap_empty(meta->bitmap, pages_per_block)) {
free_block(block);
+ trace_xe_buddy_block_free(block, size, block_pfn_first);
+ }
}
static const struct dev_pagemap_ops xe_devm_pagemap_ops = {
@@ -11,6 +11,7 @@
#include <linux/tracepoint.h>
#include <linux/types.h>
+#include <drm/drm_buddy.h>
#include "xe_bo_types.h"
#include "xe_exec_queue_types.h"
@@ -600,6 +601,40 @@ DEFINE_EVENT_PRINT(xe_guc_ctb, xe_guc_ctb_g2h,
);
+DECLARE_EVENT_CLASS(xe_buddy_block,
+ TP_PROTO(struct drm_buddy_block *block, u64 size, u64 pfn),
+ TP_ARGS(block, size, pfn),
+
+ TP_STRUCT__entry(
+ __field(u64, block)
+ __field(u64, header)
+ __field(u64, size)
+ __field(u64, pfn)
+ ),
+
+ TP_fast_assign(
+ __entry->block = (u64)block;
+ __entry->header = block->header;
+ __entry->size = size;
+ __entry->pfn = pfn;
+ ),
+
+ TP_printk("xe svm: allocated block %llx, block header %llx, size %llx, pfn %llx\n",
+ __entry->block, __entry->header, __entry->size, __entry->pfn)
+);
+
+
+DEFINE_EVENT(xe_buddy_block, xe_buddy_block_alloc,
+ TP_PROTO(struct drm_buddy_block *block, u64 size, u64 pfn),
+ TP_ARGS(block, size, pfn)
+);
+
+
+DEFINE_EVENT(xe_buddy_block, xe_buddy_block_free,
+ TP_PROTO(struct drm_buddy_block *block, u64 size, u64 pfn),
+ TP_ARGS(block, size, pfn)
+);
+
#endif
/* This part must be outside protection */
Signed-off-by: Oak Zeng <oak.zeng@intel.com> Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Cc: Thomas Hellström <thomas.hellstrom@intel.com> Cc: Brian Welty <brian.welty@intel.com> --- drivers/gpu/drm/xe/xe_svm_devmem.c | 5 ++++- drivers/gpu/drm/xe/xe_trace.h | 35 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-)