All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Francis <David.Francis@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: David Francis <David.Francis@amd.com>,
	Sunil Khatri <Sunil.Khatri@amd.com>
Subject: [PATCH v2] drm/amdgpu: Add trace events for pid register/deregister
Date: Fri, 7 Aug 2026 09:42:41 -0400	[thread overview]
Message-ID: <20260807134241.845819-1-David.Francis@amd.com> (raw)

Some debugging applications need to track when a process starts
or stops using the amdgpu driver. For those processes, add ftrace
events that track when a amdgpu_vm task info is changed or destroyed.

v2: Deregister in fini, not destroy.

cc: Sunil Khatri <Sunil.Khatri@amd.com>
Signed-off-by: David Francis <David.Francis@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 17 +++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  7 +++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
index 5324030a13f5..2aeda13e49dd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
@@ -732,6 +732,23 @@ TRACE_EVENT(amdgpu_userq_state_changed,
 		      __entry->client_id, __entry->queue_type, __entry->doorbell_index, __entry->to)
 );
 
+TRACE_EVENT(amdgpu_register_pid,
+	    TP_PROTO(uint32_t pid),
+	    TP_ARGS(pid),
+	    TP_STRUCT__entry(__field(uint32_t, pid)),
+	    TP_fast_assign(__entry->pid = pid;),
+	    TP_printk("amdgpu register pid %d",
+		      __entry->pid)
+);
+TRACE_EVENT(amdgpu_deregister_pid,
+	    TP_PROTO(uint32_t pid),
+	    TP_ARGS(pid),
+	    TP_STRUCT__entry(__field(uint32_t, pid)),
+	    TP_fast_assign(__entry->pid = pid;),
+	    TP_printk("amdgpu deregister pid %d",
+		      __entry->pid)
+);
+
 #undef AMDGPU_JOB_GET_TIMELINE_NAME
 #endif
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index aac8ace9d7a6..48a725a0154e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2543,6 +2543,10 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm)
 	if (vm->task_info->task.pid == current->pid)
 		return;
 
+	if (vm->task_info->task.pid)
+		trace_amdgpu_deregister_pid(vm->task_info->task.pid);
+	trace_amdgpu_register_pid(current->pid);
+
 	vm->task_info->task.pid = current->pid;
 	get_task_comm(vm->task_info->task.comm, current);
 
@@ -2803,6 +2807,9 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 			 ti->process_name, ti->task.pid, ti->task.comm, ti->tgid);
 	}
 
+	if (vm->task_info->task.pid)
+		trace_amdgpu_deregister_pid(vm->task_info->task.pid);
+
 	amdgpu_vm_put_task_info(vm->task_info);
 }
 
-- 
2.34.1


             reply	other threads:[~2026-08-07 13:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 13:42 David Francis [this message]
2026-08-07 16:05 ` [PATCH v2] drm/amdgpu: Add trace events for pid register/deregister Khatri, Sunil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260807134241.845819-1-David.Francis@amd.com \
    --to=david.francis@amd.com \
    --cc=Sunil.Khatri@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.