Skip to contentSkip to conversation

drm/amdgpu: add pid and name of the process with userq manager

PATCH In review Sunil Khatri 2 participants 3 messages Apr 8, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: add pid and name of the process with userq manager

Add the pid and the process name of the process with the userq manager which could be used in debugging and understanding error messages better.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       | 8 ++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h | 2 ++
 2 files changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +8 -0
index 4262c320ad1d..f73bcca35287 100644
@@ -1357,6 +1357,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 {
 	struct amdgpu_device *adev = drm_to_adev(dev);
 	struct amdgpu_fpriv *fpriv;
+	struct task_struct *task;
 	int r, pasid;
 
 	/* Ensure IB tests are run on ring */
@@ -1426,6 +1427,13 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 
 	amdgpu_ctx_mgr_init(&fpriv->ctx_mgr, adev);
 
+	task = get_pid_task(rcu_access_pointer(file_priv->pid), PIDTYPE_PID);
+	if (task) {
+		fpriv->userq_mgr.pid = task->pid;
+		fpriv->userq_mgr.process_name = kstrdup(task->comm, GFP_KERNEL);
+		put_task_struct(task);
+	}
+
 	r = amdgpu_userq_mgr_init(&fpriv->userq_mgr, adev);
 	if (r)
 		DRM_WARN("Can't setup usermode queues, use legacy workload submission only\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h +2 -0
index ec1a4ca6f632..a495b24165f9 100644
@@ -77,6 +77,8 @@ struct amdgpu_userq_mgr {
 	struct amdgpu_device		*adev;
 	struct delayed_work		resume_work;
 	struct list_head		list;
+	pid_t				pid;
+	char				*process_name;
 };
 
 struct amdgpu_db_info {
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 drm/amdgpu: update the error logging for more information

add process and pid information in the userqueue error logging to make it more useful in resolving the error by logs.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c +12 -6
index ecd49cf15b2a..3b55601b012f 100644
@@ -67,7 +67,8 @@ amdgpu_userqueue_cleanup(struct amdgpu_userq_mgr *uq_mgr,
 	if (f && !dma_fence_is_signaled(f)) {
 		ret = dma_fence_wait_timeout(f, true, msecs_to_jiffies(100));
 		if (ret <= 0) {
-			DRM_ERROR("Timed out waiting for fence f=%p\n", f);
+			DRM_ERROR("Timed out waiting for fence f=%p for process:%s:%d\n",
+				  f, uq_mgr->process_name, uq_mgr->pid);
 			return;
 		}
 	}
@@ -436,7 +437,8 @@ amdgpu_userqueue_resume_all(struct amdgpu_userq_mgr *uq_mgr)
 	}
 
 	if (ret)
-		DRM_ERROR("Failed to resume all the queue\n");
+		DRM_ERROR("Failed to resume all the queue for process:%s:%d\n",
+			  uq_mgr->process_name, uq_mgr->pid);
 	return ret;
 }
 
@@ -594,7 +596,8 @@ amdgpu_userqueue_suspend_all(struct amdgpu_userq_mgr *uq_mgr)
 	}
 
 	if (ret)
-		DRM_ERROR("Couldn't suspend all the queues\n");
+		DRM_ERROR("Couldn't suspend all the queues for process:%s:%d\n",
+			  uq_mgr->process_name, uq_mgr->pid);
 	return ret;
 }
 
@@ -611,7 +614,8 @@ amdgpu_userqueue_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr)
 			continue;
 		ret = dma_fence_wait_timeout(f, true, msecs_to_jiffies(100));
 		if (ret <= 0) {
-			DRM_ERROR("Timed out waiting for fence f=%p\n", f);
+			DRM_ERROR("Timed out waiting for fence f=%p for process:%s:%d\n",
+				  f, uq_mgr->process_name, uq_mgr->pid);
 			return -ETIMEDOUT;
 		}
 	}
@@ -630,13 +634,15 @@ amdgpu_userqueue_suspend(struct amdgpu_userq_mgr *uq_mgr,
 	/* Wait for any pending userqueue fence work to finish */
 	ret = amdgpu_userqueue_wait_for_signal(uq_mgr);
 	if (ret) {
-		DRM_ERROR("Not suspending userqueue, timeout waiting for work\n");
+		DRM_ERROR("Not suspending userqueue, timeout waiting for work process:%s:%d\n",
+			  uq_mgr->process_name, uq_mgr->pid);
 		return;
 	}
 
 	ret = amdgpu_userqueue_suspend_all(uq_mgr);
 	if (ret) {
-		DRM_ERROR("Failed to evict userqueue\n");
+		DRM_ERROR("Failed to evict userqueue for process:%s:%d\n",
+			  uq_mgr->process_name, uq_mgr->pid);
 		return;
 	}
 
Signature · 1 line
2.34.1
maintainer
#2 lore raw
In reply to Sunil Khatri

Am 08.04.25 um 14:41 schrieb Sunil Khatri:

Quoted 3 lines

Add the pid and the process name of the process with the userq manager which could be used in debugging and understanding error messages better.

That should be unnecessary.

We already have that in the DRM file as well as the VM which is also updated when the fd moves from the X server to the client.

Regards,
Christian.

Quoted 46 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       | 8 ++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h | 2 ++
 2 files changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +8 -0
index 4262c320ad1d..f73bcca35287 100644
@@ -1357,6 +1357,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 {
 	struct amdgpu_device *adev = drm_to_adev(dev);
 	struct amdgpu_fpriv *fpriv;
+	struct task_struct *task;
 	int r, pasid;
 
 	/* Ensure IB tests are run on ring */
@@ -1426,6 +1427,13 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 
 	amdgpu_ctx_mgr_init(&fpriv->ctx_mgr, adev);
 
+	task = get_pid_task(rcu_access_pointer(file_priv->pid), PIDTYPE_PID);
+	if (task) {
+		fpriv->userq_mgr.pid = task->pid;
+		fpriv->userq_mgr.process_name = kstrdup(task->comm, GFP_KERNEL);
+		put_task_struct(task);
+	}
+
 	r = amdgpu_userq_mgr_init(&fpriv->userq_mgr, adev);
 	if (r)
 		DRM_WARN("Can't setup usermode queues, use legacy workload submission only\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h +2 -0
index ec1a4ca6f632..a495b24165f9 100644
@@ -77,6 +77,8 @@ struct amdgpu_userq_mgr {
 	struct amdgpu_device		*adev;
 	struct delayed_work		resume_work;
 	struct list_head		list;
+	pid_t				pid;
+	char				*process_name;
 };
 
 struct amdgpu_db_info {