Re: [RFC 09/15] drm/xe/trace: Add xe_vma_acc trace event for access counter notifications

Matthew Brost
2026-04-03T01:01:34Z

On Wed, Mar 18, 2026 at 01:14:50PM +0530, Himal Prasad Ghimiray wrote:
> Trace VMA access counter notifications with asid, address range, and
> counter type (TRIGGER or NOTIFY) to aid debugging of migration hints.
>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>

Reviewed-by: Matthew Brost <matthew.brost@intel.com>

> ---
> drivers/gpu/drm/xe/xe_access_counter.c | 7 ++++--
> drivers/gpu/drm/xe/xe_trace_bo.h | 32 +++++++++++++++++++++++---
> 2 files changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_access_counter.c b/drivers/gpu/drm/xe/xe_access_counter.c
> index 9eb9917d8da7..f93618faab02 100644
> --- a/drivers/gpu/drm/xe/xe_access_counter.c
> +++ b/drivers/gpu/drm/xe/xe_access_counter.c
> @@ -13,6 +13,7 @@
> #include "xe_device.h"
> #include "xe_gt_printk.h"
> #include "xe_hw_engine.h"
> +#include "xe_trace_bo.h"
> #include "xe_usm_queue.h"
> #include "xe_vm.h"
>
> @@ -109,6 +110,8 @@ static int xe_access_counter_service(struct xe_access_counter *ac)
> goto unlock_vm;
> }
>
> + trace_xe_vma_acc(vma, ac->consumer.counter_type);
> +
> /* TODO: Handle svm vma's */
> if (xe_vma_has_no_bo(vma))
> goto unlock_vm;
> @@ -153,7 +156,7 @@ static void xe_access_counter_queue_work_func(struct work_struct *w)
> #define USM_QUEUE_MAX_RUNTIME_MS 20
> threshold = jiffies + msecs_to_jiffies(USM_QUEUE_MAX_RUNTIME_MS);
>
> - while (xe_usm_queue_pop(ac_queue, &ac, xe_access_counter_entry_size())) {
> + while (xe_usm_queue_pop(ac_queue, &ac, sizeof(struct xe_access_counter))) {
> int err;
>
> if (!ac.gt) /* Access counter squashed during reset */
> @@ -239,7 +242,7 @@ int xe_access_counter_handler(struct xe_device *xe, struct xe_access_counter *ac
> spin_lock_irqsave(&ac_queue->lock, flags);
> full = xe_usm_queue_full(ac_queue, sizeof(struct xe_access_counter));
> if (!full) {
> - xe_usm_queue_push(ac_queue, ac, xe_access_counter_entry_size());
> + xe_usm_queue_push(ac_queue, ac, sizeof(struct xe_access_counter));
> queue_work(xe->usm.pf_wq, &ac_queue->worker);
> } else {
> drm_warn(&xe->drm,
> diff --git a/drivers/gpu/drm/xe/xe_trace_bo.h b/drivers/gpu/drm/xe/xe_trace_bo.h
> index 86323cf3be2c..eae5a5d0dbdc 100644
> --- a/drivers/gpu/drm/xe/xe_trace_bo.h
> +++ b/drivers/gpu/drm/xe/xe_trace_bo.h
> @@ -12,6 +12,7 @@
> #include <linux/tracepoint.h>
> #include <linux/types.h>
>
> +#include "xe_access_counter_types.h"
> #include "xe_bo.h"
> #include "xe_bo_types.h"
> #include "xe_vm.h"
> @@ -125,9 +126,34 @@ DEFINE_EVENT(xe_vma, xe_vma_pagefault,
> TP_ARGS(vma)
> );
>
> -DEFINE_EVENT(xe_vma, xe_vma_acc,
> - TP_PROTO(struct xe_vma *vma),
> - TP_ARGS(vma)
> +TRACE_EVENT(xe_vma_acc,
> + TP_PROTO(struct xe_vma *vma, u8 counter_type),
> + TP_ARGS(vma, counter_type),
> +
> + TP_STRUCT__entry(
> + __string(dev, __dev_name_vma(vma))
> + __field(struct xe_vma *, vma)
> + __field(struct xe_vm *, vm)
> + __field(u32, asid)
> + __field(u64, start)
> + __field(u64, end)
> + __field(u8, counter_type)
> + ),
> +
> + TP_fast_assign(
> + __assign_str(dev);
> + __entry->vma = vma;
> + __entry->vm = xe_vma_vm(vma);
> + __entry->asid = xe_vma_vm(vma)->usm.asid;
> + __entry->start = xe_vma_start(vma);
> + __entry->end = xe_vma_end(vma) - 1;
> + __entry->counter_type = counter_type;
> + ),
> +
> + TP_printk("dev=%s, vma=%p, vm=%p, asid=0x%05x, start=0x%012llx, end=0x%012llx, type=%s",
> + __get_str(dev), __entry->vma, __entry->vm,
> + __entry->asid, __entry->start, __entry->end,
> + __entry->counter_type == XE_ACCESS_COUNTER_TYPE_NOTIFY ? "NOTIFY" : "TRIGGER")
> );
>
> DEFINE_EVENT(xe_vma, xe_vma_bind,
> --
> 2.34.1
>