Skip to contentSkip to conversation

Improve gpu_scheduler trace events + UAPI

PATCH Superseded Pierre-Eric Pelloux-Prayer 5 participants 20 messages Mar 20, 2025 – Apr 9, 2025

Subsystems (19)

v8 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v8 cover Improve gpu_scheduler trace events + UAPI

Hi,

The initial goal of this series was to improve the drm and amdgpu trace events to be able to expose more of the inner workings of the scheduler and drivers to developers via tools.

Then, the series evolved to become focused only on gpu_scheduler. The changes around vblank events will be part of a different series, as well as the amdgpu ones.

Moreover Sima suggested to make some trace events stable uAPI, so tools can rely on them long term.

The first patches extend and cleanup the gpu scheduler events, then add a documentation entry in drm-uapi.rst.

The last 2 patches are new in v8. One is based on a suggestion from Tvrtko and gets rid of drm_sched_job::id. The other is a cleanup of amdgpu trace events to use the fence=%llu:%llu format.

The drm_sched_job patches don't affect gpuvis which has code to parse the gpu_scheduler events but these events are not enabled.

Changes since v7:
* uint64_t -> u64
* reworked dependencies tracing (Tvrtko)
* use common name prefix for all events (Tvrtko)
* dropped drm_sched_job::id (Tvrtko)

Useful links:
- userspace tool using the updated events:
https://gitlab.freedesktop.org/tomstdenis/umr/-/merge_requests/37
- v7:
https://lists.freedesktop.org/archives/dri-devel/2025-January/488117.html

Pierre-Eric Pelloux-Prayer (10):
drm/debugfs: output client_id in in drm_clients_info drm/sched: store the drm client_id in drm_sched_fence drm/sched: add device name to the drm_sched_process_job event drm/sched: cleanup gpu_scheduler trace events
drm/sched: trace dependencies for gpu jobs
drm/sched: add the drm_client_id to the drm_sched_run/exec_job events drm/sched: cleanup event names
drm/doc: document some tracepoints as uAPI
drm: get rid of drm_sched_job::id
drm/amdgpu: update trace format to match gpu_scheduler_trace

 Documentation/gpu/drm-uapi.rst                |  19 ++++
 drivers/accel/amdxdna/aie2_ctx.c              |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c        |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       |   8 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.h       |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h     |  32 ++----
 drivers/gpu/drm/drm_debugfs.c                 |  10 +-
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c  |   2 +-
 drivers/gpu/drm/imagination/pvr_job.c         |   2 +-
 drivers/gpu/drm/imagination/pvr_queue.c       |   5 +-
 drivers/gpu/drm/imagination/pvr_queue.h       |   2 +-
 drivers/gpu/drm/lima/lima_gem.c               |   2 +-
 drivers/gpu/drm/lima/lima_sched.c             |   6 +-
 drivers/gpu/drm/lima/lima_sched.h             |   3 +-
 drivers/gpu/drm/msm/msm_gem_submit.c          |   8 +-
 drivers/gpu/drm/nouveau/nouveau_sched.c       |   3 +-
 drivers/gpu/drm/panfrost/panfrost_drv.c       |   2 +-
 drivers/gpu/drm/panthor/panthor_drv.c         |   3 +-
 drivers/gpu/drm/panthor/panthor_mmu.c         |   2 +-
 drivers/gpu/drm/panthor/panthor_sched.c       |   5 +-
 drivers/gpu/drm/panthor/panthor_sched.h       |   3 +-
 .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 103 +++++++++++++-----
 drivers/gpu/drm/scheduler/sched_entity.c      |  16 ++-
 drivers/gpu/drm/scheduler/sched_fence.c       |   4 +-
 drivers/gpu/drm/scheduler/sched_internal.h    |   2 +-
 drivers/gpu/drm/scheduler/sched_main.c        |  11 +-
 drivers/gpu/drm/v3d/v3d_submit.c              |   2 +-
 drivers/gpu/drm/xe/xe_sched_job.c             |   3 +-
 include/drm/gpu_scheduler.h                   |  13 ++-
 30 files changed, 186 insertions(+), 96 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v8 1/10 drm/debugfs: output client_id in in drm_clients_info

client_id is a unique id used by fdinfo. Having it listed in 'clients' output means a userspace application can correlate the fields, eg:
given a fdinfo id get the fdinfo name.

Geiven that client_id is a uint64_t, we use a %20llu printf format to keep the output aligned (20 = digit count of the biggest uint64_t).

---
 drivers/gpu/drm/drm_debugfs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_debugfs.c +6 -4
index 6b2178864c7e..aed51c8883fd 100644
@@ -77,14 +77,15 @@ static int drm_clients_info(struct seq_file *m, void *data)
 	kuid_t uid;
 
 	seq_printf(m,
-		   "%20s %5s %3s master a %5s %10s %*s\n",
+		   "%20s %5s %3s master a %5s %10s %*s %20s\n",
 		   "command",
 		   "tgid",
 		   "dev",
 		   "uid",
 		   "magic",
 		   DRM_CLIENT_NAME_MAX_LEN,
-		   "name");
+		   "name",
+		   "id");
 
 	/* dev->filelist is sorted youngest first, but we want to present
 	 * oldest first (i.e. kernel, servers, clients), so walk backwardss.
@@ -100,7 +101,7 @@ static int drm_clients_info(struct seq_file *m, void *data)
 		pid = rcu_dereference(priv->pid);
 		task = pid_task(pid, PIDTYPE_TGID);
 		uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID;
-		seq_printf(m, "%20s %5d %3d   %c    %c %5d %10u %*s\n",
+		seq_printf(m, "%20s %5d %3d   %c    %c %5d %10u %*s %20llu\n",
 			   task ? task->comm : "<unknown>",
 			   pid_vnr(pid),
 			   priv->minor->index,
@@ -109,7 +110,8 @@ static int drm_clients_info(struct seq_file *m, void *data)
 			   from_kuid_munged(seq_user_ns(m), uid),
 			   priv->magic,
 			   DRM_CLIENT_NAME_MAX_LEN,
-			   priv->client_name ? priv->client_name : "<unset>");
+			   priv->client_name ? priv->client_name : "<unset>",
+			   priv->client_id);
 		rcu_read_unlock();
 		mutex_unlock(&priv->client_name_lock);
 	}
Signature · 1 line
2.43.0
#2 lore raw

PATCH v8 2/10 drm/sched: store the drm client_id in drm_sched_fence

In reply to Pierre-Eric Pelloux-Prayer

This will be used in a later commit to trace the drm client_id in some of the gpu_scheduler trace events.

This requires changing all the users of drm_sched_job_init to add an extra parameter.

The newly added drm_client_id field in the drm_sched_fence is a bit of a duplicate of the owner one. One suggestion I received was to merge those 2 fields - this can't be done right now as amdgpu uses some special values (AMDGPU_FENCE_OWNER_*) that can't really be translated into a client id. Christian is working on getting rid of those; when it's done we should be able to squash owner/drm_client_id together.

---
 drivers/accel/amdxdna/aie2_ctx.c             |  3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c       |  3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c      |  8 +++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.h      |  3 ++-
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c |  2 +-
 drivers/gpu/drm/imagination/pvr_job.c        |  2 +-
 drivers/gpu/drm/imagination/pvr_queue.c      |  5 +++--
 drivers/gpu/drm/imagination/pvr_queue.h      |  2 +-
 drivers/gpu/drm/lima/lima_gem.c              |  2 +-
 drivers/gpu/drm/lima/lima_sched.c            |  6 ++++--
 drivers/gpu/drm/lima/lima_sched.h            |  3 ++-
 drivers/gpu/drm/msm/msm_gem_submit.c         |  8 +++++---
 drivers/gpu/drm/nouveau/nouveau_sched.c      |  3 ++-
 drivers/gpu/drm/panfrost/panfrost_drv.c      |  2 +-
 drivers/gpu/drm/panthor/panthor_drv.c        |  3 ++-
 drivers/gpu/drm/panthor/panthor_mmu.c        |  2 +-
 drivers/gpu/drm/panthor/panthor_sched.c      |  5 +++--
 drivers/gpu/drm/panthor/panthor_sched.h      |  3 ++-
 drivers/gpu/drm/scheduler/sched_fence.c      |  4 +++-
 drivers/gpu/drm/scheduler/sched_internal.h   |  2 +-
 drivers/gpu/drm/scheduler/sched_main.c       |  6 ++++--
 drivers/gpu/drm/v3d/v3d_submit.c             |  2 +-
 drivers/gpu/drm/xe/xe_sched_job.c            |  3 ++-
 include/drm/gpu_scheduler.h                  | 10 +++++++++-
 25 files changed, 61 insertions(+), 33 deletions(-)
drivers/accel/amdxdna/aie2_ctx.c +2 -1
index 00d215ac866e..8fb107305872 100644
@@ -827,7 +827,8 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
 		goto up_sem;
 	}
 
-	ret = drm_sched_job_init(&job->base, &hwctx->priv->entity, 1, hwctx);
+	ret = drm_sched_job_init(&job->base, &hwctx->priv->entity, 1, hwctx,
+				 hwctx->client->filp->client_id);
 	if (ret) {
 		XDNA_ERR(xdna, "DRM job init failed, ret %d", ret);
 		goto free_chain;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -1
index 4cec3a873995..1a77ba7036c9 100644
@@ -639,7 +639,7 @@ int amdgpu_amdkfd_submit_ib(struct amdgpu_device *adev,
 		goto err;
 	}
 
-	ret = amdgpu_job_alloc(adev, NULL, NULL, NULL, 1, &job);
+	ret = amdgpu_job_alloc(adev, NULL, NULL, NULL, 1, &job, 0);
 	if (ret)
 		goto err;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -1
index 5cc5f59e3018..d115fa10f8ee 100644
@@ -293,7 +293,8 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
 
 	for (i = 0; i < p->gang_size; ++i) {
 		ret = amdgpu_job_alloc(p->adev, vm, p->entities[i], vm,
-				       num_ibs[i], &p->jobs[i]);
+				       num_ibs[i], &p->jobs[i],
+				       p->filp->client_id);
 		if (ret)
 			goto free_all_kdata;
 		p->jobs[i]->enforce_isolation = p->adev->enforce_isolation[fpriv->xcp_id];
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +5 -3
index 1d26be3c6d9d..c8c3f2601548 100644
@@ -203,7 +203,8 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 
 int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 		     struct drm_sched_entity *entity, void *owner,
-		     unsigned int num_ibs, struct amdgpu_job **job)
+		     unsigned int num_ibs, struct amdgpu_job **job,
+		     u64 drm_client_id)
 {
 	if (num_ibs == 0)
 		return -EINVAL;
@@ -221,7 +222,8 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	if (!entity)
 		return 0;
 
-	return drm_sched_job_init(&(*job)->base, entity, 1, owner);
+	return drm_sched_job_init(&(*job)->base, entity, 1, owner,
+				  drm_client_id);
 }
 
 int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,
@@ -231,7 +233,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,
 {
 	int r;
 
-	r = amdgpu_job_alloc(adev, NULL, entity, owner, 1, job);
+	r = amdgpu_job_alloc(adev, NULL, entity, owner, 1, job, 0);
 	if (r)
 		return r;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +2 -1
index ce6b9ba967ff..5a8bc6342222 100644
@@ -90,7 +90,8 @@ static inline struct amdgpu_ring *amdgpu_job_ring(struct amdgpu_job *job)
 
 int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 		     struct drm_sched_entity *entity, void *owner,
-		     unsigned int num_ibs, struct amdgpu_job **job);
+		     unsigned int num_ibs, struct amdgpu_job **job,
+		     u64 drm_client_id);
 int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,
 			     struct drm_sched_entity *entity, void *owner,
 			     size_t size, enum amdgpu_ib_pool_type pool_type,
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +1 -1
index 3c0a5c3e0e3d..76c742328edb 100644
@@ -534,7 +534,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
 
 	ret = drm_sched_job_init(&submit->sched_job,
 				 &ctx->sched_entity[args->pipe],
-				 1, submit->ctx);
+				 1, submit->ctx, file->client_id);
 	if (ret)
 		goto err_submit_put;
 
drivers/gpu/drm/imagination/pvr_job.c +1 -1
index 1cdb3cfd058d..907d3f735a3f 100644
@@ -446,7 +446,7 @@ create_job(struct pvr_device *pvr_dev,
 	if (err)
 		goto err_put_job;
 
-	err = pvr_queue_job_init(job);
+	err = pvr_queue_job_init(job, pvr_file->file->client_id);
 	if (err)
 		goto err_put_job;
 
drivers/gpu/drm/imagination/pvr_queue.c +3 -2
index eba69309bb6c..c2169e8a855d 100644
@@ -1069,6 +1069,7 @@ static int pvr_queue_cleanup_fw_context(struct pvr_queue *queue)
 /**
  * pvr_queue_job_init() - Initialize queue related fields in a pvr_job object.
  * @job: The job to initialize.
+ * @drm_client_id: drm_file.client_id submitting the job
  *
  * Bind the job to a queue and allocate memory to guarantee pvr_queue_job_arm()
  * and pvr_queue_job_push() can't fail. We also make sure the context type is
@@ -1078,7 +1079,7 @@ static int pvr_queue_cleanup_fw_context(struct pvr_queue *queue)
  *  * 0 on success, or
  *  * An error code if something failed.
  */
-int pvr_queue_job_init(struct pvr_job *job)
+int pvr_queue_job_init(struct pvr_job *job, u64 drm_client_id)
 {
 	/* Fragment jobs need at least one native fence wait on the geometry job fence. */
 	u32 min_native_dep_count = job->type == DRM_PVR_JOB_TYPE_FRAGMENT ? 1 : 0;
@@ -1095,7 +1096,7 @@ int pvr_queue_job_init(struct pvr_job *job)
 	if (!pvr_cccb_cmdseq_can_fit(&queue->cccb, job_cmds_size(job, min_native_dep_count)))
 		return -E2BIG;
 
-	err = drm_sched_job_init(&job->base, &queue->entity, 1, THIS_MODULE);
+	err = drm_sched_job_init(&job->base, &queue->entity, 1, THIS_MODULE, drm_client_id);
 	if (err)
 		return err;
 
drivers/gpu/drm/imagination/pvr_queue.h +1 -1
index 93fe9ac9f58c..fc1986d73fc8 100644
@@ -143,7 +143,7 @@ struct pvr_queue {
 
 bool pvr_queue_fence_is_ufo_backed(struct dma_fence *f);
 
-int pvr_queue_job_init(struct pvr_job *job);
+int pvr_queue_job_init(struct pvr_job *job, u64 drm_client_id);
 
 void pvr_queue_job_cleanup(struct pvr_job *job);
 
drivers/gpu/drm/lima/lima_gem.c +1 -1
index 9bb997dbb4b9..f46f961afc56 100644
@@ -341,7 +341,7 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit)
 
 	err = lima_sched_task_init(
 		submit->task, submit->ctx->context + submit->pipe,
-		bos, submit->nr_bos, vm);
+		bos, submit->nr_bos, vm, file->client_id);
 	if (err)
 		goto err_out1;
 
drivers/gpu/drm/lima/lima_sched.c +4 -2
index 825135a26aa4..c9959fc3be47 100644
@@ -113,7 +113,8 @@ static inline struct lima_sched_pipe *to_lima_pipe(struct drm_gpu_scheduler *sch
 int lima_sched_task_init(struct lima_sched_task *task,
 			 struct lima_sched_context *context,
 			 struct lima_bo **bos, int num_bos,
-			 struct lima_vm *vm)
+			 struct lima_vm *vm,
+			 u64 drm_client_id)
 {
 	int err, i;
 
@@ -124,7 +125,8 @@ int lima_sched_task_init(struct lima_sched_task *task,
 	for (i = 0; i < num_bos; i++)
 		drm_gem_object_get(&bos[i]->base.base);
 
-	err = drm_sched_job_init(&task->base, &context->base, 1, vm);
+	err = drm_sched_job_init(&task->base, &context->base, 1, vm,
+				 drm_client_id);
 	if (err) {
 		kfree(task->bos);
 		return err;
drivers/gpu/drm/lima/lima_sched.h +2 -1
index 85b23ba901d5..1a08faf8a529 100644
@@ -88,7 +88,8 @@ struct lima_sched_pipe {
 int lima_sched_task_init(struct lima_sched_task *task,
 			 struct lima_sched_context *context,
 			 struct lima_bo **bos, int num_bos,
-			 struct lima_vm *vm);
+			 struct lima_vm *vm,
+			 u64 drm_client_id);
 void lima_sched_task_fini(struct lima_sched_task *task);
 
 int lima_sched_context_init(struct lima_sched_pipe *pipe,
drivers/gpu/drm/msm/msm_gem_submit.c +5 -3
index 3e9aa2cc38ef..d9be0fe3d674 100644
@@ -30,7 +30,7 @@
 static struct msm_gem_submit *submit_create(struct drm_device *dev,
 		struct msm_gpu *gpu,
 		struct msm_gpu_submitqueue *queue, uint32_t nr_bos,
-		uint32_t nr_cmds)
+		uint32_t nr_cmds, u64 drm_client_id)
 {
 	static atomic_t ident = ATOMIC_INIT(0);
 	struct msm_gem_submit *submit;
@@ -54,7 +54,8 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
 		return ERR_PTR(ret);
 	}
 
-	ret = drm_sched_job_init(&submit->base, queue->entity, 1, queue);
+	ret = drm_sched_job_init(&submit->base, queue->entity, 1, queue,
+				 drm_client_id);
 	if (ret) {
 		kfree(submit->hw_fence);
 		kfree(submit);
@@ -693,7 +694,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 		}
 	}
 
-	submit = submit_create(dev, gpu, queue, args->nr_bos, args->nr_cmds);
+	submit = submit_create(dev, gpu, queue, args->nr_bos, args->nr_cmds,
+			       file->client_id);
 	if (IS_ERR(submit)) {
 		ret = PTR_ERR(submit);
 		goto out_post_unlock;
drivers/gpu/drm/nouveau/nouveau_sched.c +2 -1
index d326e55d2d24..460a5fb02412 100644
@@ -87,7 +87,8 @@ nouveau_job_init(struct nouveau_job *job,
 	}
 
 	ret = drm_sched_job_init(&job->base, &sched->entity,
-				 args->credits, NULL);
+				 args->credits, NULL,
+				 job->file_priv->client_id);
 	if (ret)
 		goto err_free_chains;
 
drivers/gpu/drm/panfrost/panfrost_drv.c +1 -1
index 0f3935556ac7..f4f20d11ecd9 100644
@@ -312,7 +312,7 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,
 
 	ret = drm_sched_job_init(&job->base,
 				 &file_priv->sched_entity[slot],
-				 1, NULL);
+				 1, NULL, file->client_id);
 	if (ret)
 		goto out_put_job;
 
drivers/gpu/drm/panthor/panthor_drv.c +2 -1
index 06fe46e32073..bd8e1900c919 100644
@@ -989,7 +989,8 @@ static int panthor_ioctl_group_submit(struct drm_device *ddev, void *data,
 		const struct drm_panthor_queue_submit *qsubmit = &jobs_args[i];
 		struct drm_sched_job *job;
 
-		job = panthor_job_create(pfile, args->group_handle, qsubmit);
+		job = panthor_job_create(pfile, args->group_handle, qsubmit,
+					 file->client_id);
 		if (IS_ERR(job)) {
 			ret = PTR_ERR(job);
 			goto out_cleanup_submit_ctx;
drivers/gpu/drm/panthor/panthor_mmu.c +1 -1
index 12a02e28f50f..e0c79bd2d173 100644
@@ -2516,7 +2516,7 @@ panthor_vm_bind_job_create(struct drm_file *file,
 	kref_init(&job->refcount);
 	job->vm = panthor_vm_get(vm);
 
-	ret = drm_sched_job_init(&job->base, &vm->entity, 1, vm);
+	ret = drm_sched_job_init(&job->base, &vm->entity, 1, vm, file->client_id);
 	if (ret)
 		goto err_put_job;
 
drivers/gpu/drm/panthor/panthor_sched.c +3 -2
index 4d31d1967716..56bac7a765ac 100644
@@ -3729,7 +3729,8 @@ struct panthor_vm *panthor_job_vm(struct drm_sched_job *sched_job)
 struct drm_sched_job *
 panthor_job_create(struct panthor_file *pfile,
 		   u16 group_handle,
-		   const struct drm_panthor_queue_submit *qsubmit)
+		   const struct drm_panthor_queue_submit *qsubmit,
+		   u64 drm_client_id)
 {
 	struct panthor_group_pool *gpool = pfile->groups;
 	struct panthor_job *job;
@@ -3801,7 +3802,7 @@ panthor_job_create(struct panthor_file *pfile,
 
 	ret = drm_sched_job_init(&job->base,
 				 &job->group->queues[job->queue_idx]->entity,
-				 credits, job->group);
+				 credits, job->group, drm_client_id);
 	if (ret)
 		goto err_put_job;
 
drivers/gpu/drm/panthor/panthor_sched.h +2 -1
index e650a445cf50..742b0b4ff3a3 100644
@@ -29,7 +29,8 @@ int panthor_group_get_state(struct panthor_file *pfile,
 struct drm_sched_job *
 panthor_job_create(struct panthor_file *pfile,
 		   u16 group_handle,
-		   const struct drm_panthor_queue_submit *qsubmit);
+		   const struct drm_panthor_queue_submit *qsubmit,
+		   u64 drm_client_id);
 struct drm_sched_job *panthor_job_get(struct drm_sched_job *job);
 struct panthor_vm *panthor_job_vm(struct drm_sched_job *sched_job);
 void panthor_job_put(struct drm_sched_job *job);
drivers/gpu/drm/scheduler/sched_fence.c +3 -1
index e971528504a5..d208d384d38d 100644
@@ -206,7 +206,8 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f)
 EXPORT_SYMBOL(to_drm_sched_fence);
 
 struct drm_sched_fence *drm_sched_fence_alloc(struct drm_sched_entity *entity,
-					      void *owner)
+					      void *owner,
+					      u64 drm_client_id)
 {
 	struct drm_sched_fence *fence = NULL;
 
@@ -215,6 +216,7 @@ struct drm_sched_fence *drm_sched_fence_alloc(struct drm_sched_entity *entity,
 		return NULL;
 
 	fence->owner = owner;
+	fence->drm_client_id = drm_client_id;
 	spin_lock_init(&fence->lock);
 
 	return fence;
drivers/gpu/drm/scheduler/sched_internal.h +1 -1
index 599cf6e1bb74..7ea5a6736f98 100644
@@ -24,7 +24,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity);
 struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity);
 
 struct drm_sched_fence *drm_sched_fence_alloc(struct drm_sched_entity *s_entity,
-					      void *owner);
+					      void *owner, u64 drm_client_id);
 void drm_sched_fence_init(struct drm_sched_fence *fence,
 			  struct drm_sched_entity *entity);
 void drm_sched_fence_free(struct drm_sched_fence *fence);
drivers/gpu/drm/scheduler/sched_main.c +4 -2
index bfea608a7106..501eae13acb3 100644
@@ -764,6 +764,7 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs);
  * @credits: the number of credits this job contributes to the schedulers
  * credit limit
  * @owner: job owner for debugging
+ * @drm_client_id: drm_file.client_id of the owner
  *
  * Refer to drm_sched_entity_push_job() documentation
  * for locking considerations.
@@ -784,7 +785,8 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs);
  */
 int drm_sched_job_init(struct drm_sched_job *job,
 		       struct drm_sched_entity *entity,
-		       u32 credits, void *owner)
+		       u32 credits, void *owner,
+		       uint64_t drm_client_id)
 {
 	if (!entity->rq) {
 		/* This will most likely be followed by missing frames
@@ -810,7 +812,7 @@ int drm_sched_job_init(struct drm_sched_job *job,
 
 	job->entity = entity;
 	job->credits = credits;
-	job->s_fence = drm_sched_fence_alloc(entity, owner);
+	job->s_fence = drm_sched_fence_alloc(entity, owner, drm_client_id);
 	if (!job->s_fence)
 		return -ENOMEM;
 
drivers/gpu/drm/v3d/v3d_submit.c +1 -1
index 4ff5de46fb22..5171ffe9012d 100644
@@ -169,7 +169,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
 	job->file = file_priv;
 
 	ret = drm_sched_job_init(&job->base, &v3d_priv->sched_entity[queue],
-				 1, v3d_priv);
+				 1, v3d_priv, file_priv->client_id);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/xe/xe_sched_job.c +2 -1
index 1905ca590965..f4679cb9a56b 100644
@@ -113,7 +113,8 @@ struct xe_sched_job *xe_sched_job_create(struct xe_exec_queue *q,
 	kref_init(&job->refcount);
 	xe_exec_queue_get(job->q);
 
-	err = drm_sched_job_init(&job->drm, q->entity, 1, NULL);
+	err = drm_sched_job_init(&job->drm, q->entity, 1, NULL,
+				 q->xef->drm->client_id);
 	if (err)
 		goto err_free;
 
include/drm/gpu_scheduler.h +9 -1
index 50928a7ae98e..032214a49138 100644
@@ -305,6 +305,13 @@ struct drm_sched_fence {
          * @owner: job owner for debugging
          */
 	void				*owner;
+
+	/**
+	 * @drm_client_id:
+	 *
+	 * The client_id of the drm_file which owns the job.
+	 */
+	uint64_t			drm_client_id;
 };
 
 struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f);
@@ -587,7 +594,8 @@ drm_sched_pick_best(struct drm_gpu_scheduler **sched_list,
 
 int drm_sched_job_init(struct drm_sched_job *job,
 		       struct drm_sched_entity *entity,
-		       u32 credits, void *owner);
+		       u32 credits, void *owner,
+		       u64 drm_client_id);
 void drm_sched_job_arm(struct drm_sched_job *job);
 void drm_sched_entity_push_job(struct drm_sched_job *sched_job);
 int drm_sched_job_add_dependency(struct drm_sched_job *job,
Signature · 1 line
2.43.0
#3 lore raw

PATCH v8 3/10 drm/sched: add device name to the drm_sched_process_job event

In reply to Pierre-Eric Pelloux-Prayer

Since switching the scheduler from using kthreads to workqueues in commit a6149f039369 ("drm/sched: Convert drm scheduler to use a work queue rather than kthread") userspace applications cannot determine the device from the PID of the threads sending the trace events anymore.

Each queue had its own kthread which had a given PID for the whole time. So, at least for amdgpu, it was possible to associate a PID to the hardware queues of each GPU in the system. Then, when a drm_run_job trace event was received by userspace, the source PID allowed to associate it back to the correct GPU.

With workqueues this is not possible anymore, so the event needs to contain the dev_name() to identify the device.

---
 drivers/gpu/drm/scheduler/gpu_scheduler_trace.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +4 -2
index f56e77e7f6d0..713df3516a17 100644
@@ -42,6 +42,7 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 			     __field(uint64_t, id)
 			     __field(u32, job_count)
 			     __field(int, hw_job_count)
+			     __string(dev, dev_name(sched_job->sched->dev))
 			     ),
 
 	    TP_fast_assign(
@@ -52,9 +53,10 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 			   __entry->job_count = spsc_queue_count(&entity->job_queue);
 			   __entry->hw_job_count = atomic_read(
 				   &sched_job->sched->credit_count);
+			   __assign_str(dev);
 			   ),
-	    TP_printk("entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw job count:%d",
-		      __entry->entity, __entry->id,
+	    TP_printk("dev=%s, entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw job count:%d",
+		      __get_str(dev), __entry->entity, __entry->id,
 		      __entry->fence, __get_str(name),
 		      __entry->job_count, __entry->hw_job_count)
 );
Signature · 1 line
2.43.0
#4 lore raw

PATCH v8 4/10 drm/sched: cleanup gpu_scheduler trace events

In reply to Pierre-Eric Pelloux-Prayer

A fence uniquely identify a job, so this commits updates the places where a kernel pointer was used as an identifier by:

"fence=%llu:%llu"

---
 .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 45 ++++++++++---------
 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +24 -21
index 713df3516a17..21a85ee59066 100644
@@ -36,28 +36,29 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
 	    TP_ARGS(sched_job, entity),
 	    TP_STRUCT__entry(
-			     __field(struct drm_sched_entity *, entity)
-			     __field(struct dma_fence *, fence)
-			     __string(name, sched_job->sched->name)
 			     __field(uint64_t, id)
+			     __string(name, sched_job->sched->name)
 			     __field(u32, job_count)
 			     __field(int, hw_job_count)
 			     __string(dev, dev_name(sched_job->sched->dev))
+			     __field(u64, fence_context)
+			     __field(u64, fence_seqno)
 			     ),
 
 	    TP_fast_assign(
-			   __entry->entity = entity;
 			   __entry->id = sched_job->id;
-			   __entry->fence = &sched_job->s_fence->finished;
 			   __assign_str(name);
 			   __entry->job_count = spsc_queue_count(&entity->job_queue);
 			   __entry->hw_job_count = atomic_read(
 				   &sched_job->sched->credit_count);
 			   __assign_str(dev);
+			   __entry->fence_context = sched_job->s_fence->finished.context;
+			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
+
 			   ),
-	    TP_printk("dev=%s, entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw job count:%d",
-		      __get_str(dev), __entry->entity, __entry->id,
-		      __entry->fence, __get_str(name),
+	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d",
+		      __get_str(dev), __entry->id,
+		      __entry->fence_context, __entry->fence_seqno, __get_str(name),
 		      __entry->job_count, __entry->hw_job_count)
 );
 
@@ -75,37 +76,39 @@ TRACE_EVENT(drm_sched_process_job,
 	    TP_PROTO(struct drm_sched_fence *fence),
 	    TP_ARGS(fence),
 	    TP_STRUCT__entry(
-		    __field(struct dma_fence *, fence)
+		    __field(u64, fence_context)
+		    __field(u64, fence_seqno)
 		    ),
 
 	    TP_fast_assign(
-		    __entry->fence = &fence->finished;
+		    __entry->fence_context = fence->finished.context;
+		    __entry->fence_seqno = fence->finished.seqno;
 		    ),
-	    TP_printk("fence=%p signaled", __entry->fence)
+	    TP_printk("fence=%llu:%llu signaled",
+		      __entry->fence_context, __entry->fence_seqno)
 );
 
 TRACE_EVENT(drm_sched_job_wait_dep,
 	    TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
 	    TP_ARGS(sched_job, fence),
 	    TP_STRUCT__entry(
-			     __string(name, sched_job->sched->name)
+			     __field(u64, fence_context)
+			     __field(u64, fence_seqno)
 			     __field(uint64_t, id)
-			     __field(struct dma_fence *, fence)
-			     __field(uint64_t, ctx)
-			     __field(unsigned, seqno)
+			     __field(u64, ctx)
+			     __field(u64, seqno)
 			     ),
 
 	    TP_fast_assign(
-			   __assign_str(name);
+			   __entry->fence_context = sched_job->s_fence->finished.context;
+			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
 			   __entry->id = sched_job->id;
-			   __entry->fence = fence;
 			   __entry->ctx = fence->context;
 			   __entry->seqno = fence->seqno;
 			   ),
-	    TP_printk("job ring=%s, id=%llu, depends fence=%p, context=%llu, seq=%u",
-		      __get_str(name), __entry->id,
-		      __entry->fence, __entry->ctx,
-		      __entry->seqno)
+	    TP_printk("fence=%llu:%llu, id=%llu depends on unsignalled fence=%llu:%llu",
+		      __entry->fence_context, __entry->fence_seqno, __entry->id,
+		      __entry->ctx, __entry->seqno)
 );
 
 #endif /* _GPU_SCHED_TRACE_H_ */
Signature · 1 line
2.43.0
Reviewed-by on v8 4/10
#5 lore raw

Re: [PATCH v8 04/10] drm/sched: cleanup gpu_scheduler trace events

Quoted 32 lines · Pierre-Eric Pelloux-Prayer

A fence uniquely identify a job, so this commits updates the places where a kernel pointer was used as an identifier by:

    "fence=%llu:%llu"
---
  .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 45 ++++++++++---------
  1 file changed, 24 insertions(+), 21 deletions(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +3 -4
index 713df3516a17..21a85ee59066 100644
@@ -36,28 +36,29 @@ DECLARE_EVENT_CLASS(drm_sched_job,
  	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
  	    TP_ARGS(sched_job, entity),
  	    TP_STRUCT__entry(
-			     __field(struct drm_sched_entity *, entity)
-			     __field(struct dma_fence *, fence)
-			     __string(name, sched_job->sched->name)
  			     __field(uint64_t, id)
+			     __string(name, sched_job->sched->name)
  			     __field(u32, job_count)
  			     __field(int, hw_job_count)
  			     __string(dev, dev_name(sched_job->sched->dev))
+			     __field(u64, fence_context)
+			     __field(u64, fence_seqno)
  			     ),
 
  	    TP_fast_assign(
-			   __entry->entity = entity;

drivers/gpu/drm/scheduler/gpu_scheduler_trace.h DECLARE_EVENT_CLASS(drm_sched_job, · line 57

Quoted 10 lines
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +3 -1
  			   __entry->id = sched_job->id;
-			   __entry->fence = &sched_job->s_fence->finished;
  			   __assign_str(name);
  			   __entry->job_count = spsc_queue_count(&entity->job_queue);
  			   __entry->hw_job_count = atomic_read(
  				   &sched_job->sched->credit_count);
  			   __assign_str(dev);
+			   __entry->fence_context = sched_job->s_fence->finished.context;
+			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
+

You add this blank line only to remove in the following patch.

Otherwise LGTM.

Regards,

Tvrtko

Quoted 63 lines
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +18 -16
  			   ),
-	    TP_printk("dev=%s, entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw job count:%d",
-		      __get_str(dev), __entry->entity, __entry->id,
-		      __entry->fence, __get_str(name),
+	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d",
+		      __get_str(dev), __entry->id,
+		      __entry->fence_context, __entry->fence_seqno, __get_str(name),
  		      __entry->job_count, __entry->hw_job_count)
  );
 
@@ -75,37 +76,39 @@ TRACE_EVENT(drm_sched_process_job,
  	    TP_PROTO(struct drm_sched_fence *fence),
  	    TP_ARGS(fence),
  	    TP_STRUCT__entry(
-		    __field(struct dma_fence *, fence)
+		    __field(u64, fence_context)
+		    __field(u64, fence_seqno)
  		    ),
 
  	    TP_fast_assign(
-		    __entry->fence = &fence->finished;
+		    __entry->fence_context = fence->finished.context;
+		    __entry->fence_seqno = fence->finished.seqno;
  		    ),
-	    TP_printk("fence=%p signaled", __entry->fence)
+	    TP_printk("fence=%llu:%llu signaled",
+		      __entry->fence_context, __entry->fence_seqno)
  );
 
  TRACE_EVENT(drm_sched_job_wait_dep,
  	    TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
  	    TP_ARGS(sched_job, fence),
  	    TP_STRUCT__entry(
-			     __string(name, sched_job->sched->name)
+			     __field(u64, fence_context)
+			     __field(u64, fence_seqno)
  			     __field(uint64_t, id)
-			     __field(struct dma_fence *, fence)
-			     __field(uint64_t, ctx)
-			     __field(unsigned, seqno)
+			     __field(u64, ctx)
+			     __field(u64, seqno)
  			     ),
 
  	    TP_fast_assign(
-			   __assign_str(name);
+			   __entry->fence_context = sched_job->s_fence->finished.context;
+			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
  			   __entry->id = sched_job->id;
-			   __entry->fence = fence;
  			   __entry->ctx = fence->context;
  			   __entry->seqno = fence->seqno;
  			   ),
-	    TP_printk("job ring=%s, id=%llu, depends fence=%p, context=%llu, seq=%u",
-		      __get_str(name), __entry->id,
-		      __entry->fence, __entry->ctx,
-		      __entry->seqno)
+	    TP_printk("fence=%llu:%llu, id=%llu depends on unsignalled fence=%llu:%llu",
+		      __entry->fence_context, __entry->fence_seqno, __entry->id,
+		      __entry->ctx, __entry->seqno)
  );
 
  #endif /* _GPU_SCHED_TRACE_H_ */
#6 lore raw

PATCH v8 5/10 drm/sched: trace dependencies for gpu jobs

In reply to Pierre-Eric Pelloux-Prayer

We can't trace dependencies from drm_sched_job_add_dependency because when it's called the job's fence is not available yet.

So instead each dependency is traced individually when drm_sched_entity_push_job is used.

Tracing the dependencies allows tools to analyze the dependencies between the jobs (previously it was only possible for fences traced by drm_sched_job_wait_dep).

---
 .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 24 ++++++++++++++++++-
 drivers/gpu/drm/scheduler/sched_entity.c      |  8 +++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +23 -1
index 21a85ee59066..5d9992ad47d3 100644
@@ -54,7 +54,6 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 			   __assign_str(dev);
 			   __entry->fence_context = sched_job->s_fence->finished.context;
 			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
-
 			   ),
 	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d",
 		      __get_str(dev), __entry->id,
@@ -88,6 +87,29 @@ TRACE_EVENT(drm_sched_process_job,
 		      __entry->fence_context, __entry->fence_seqno)
 );
 
+TRACE_EVENT(drm_sched_job_add_dep,
+	TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
+	TP_ARGS(sched_job, fence),
+	TP_STRUCT__entry(
+		    __field(u64, fence_context)
+		    __field(u64, fence_seqno)
+		    __field(u64, id)
+		    __field(u64, ctx)
+		    __field(u64, seqno)
+		    ),
+
+	TP_fast_assign(
+		    __entry->fence_context = sched_job->s_fence->finished.context;
+		    __entry->fence_seqno = sched_job->s_fence->finished.seqno;
+		    __entry->id = sched_job->id;
+		    __entry->ctx = fence->context;
+		    __entry->seqno = fence->seqno;
+		    ),
+	TP_printk("fence=%llu:%llu, id=%llu depends on fence=%llu:%llu",
+		  __entry->fence_context, __entry->fence_seqno, __entry->id,
+		  __entry->ctx, __entry->seqno)
+);
+
 TRACE_EVENT(drm_sched_job_wait_dep,
 	    TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
 	    TP_ARGS(sched_job, fence),
drivers/gpu/drm/scheduler/sched_entity.c +8 -0
index a6d2a4722d82..047e42cfb129 100644
@@ -580,6 +580,14 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
 	ktime_t submit_ts;
 
 	trace_drm_sched_job(sched_job, entity);
+
+	if (trace_drm_sched_job_add_dep_enabled()) {
+		struct dma_fence *entry;
+		unsigned long index;
+
+		xa_for_each(&sched_job->dependencies, index, entry)
+			trace_drm_sched_job_add_dep(sched_job, entry);
+	}
 	atomic_inc(entity->rq->sched->score);
 	WRITE_ONCE(entity->last_user, current->group_leader);
 
Signature · 1 line
2.43.0
Reviewed-by on v8 5/10
#7 lore raw

Re: [PATCH v8 05/10] drm/sched: trace dependencies for gpu jobs

Quoted 67 lines · Pierre-Eric Pelloux-Prayer

We can't trace dependencies from drm_sched_job_add_dependency because when it's called the job's fence is not available yet.

So instead each dependency is traced individually when drm_sched_entity_push_job is used.

Tracing the dependencies allows tools to analyze the dependencies between the jobs (previously it was only possible for fences traced by drm_sched_job_wait_dep).

---
  .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 24 ++++++++++++++++++-
  drivers/gpu/drm/scheduler/sched_entity.c      |  8 +++++++
  2 files changed, 31 insertions(+), 1 deletion(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +23 -1
index 21a85ee59066..5d9992ad47d3 100644
@@ -54,7 +54,6 @@ DECLARE_EVENT_CLASS(drm_sched_job,
  			   __assign_str(dev);
  			   __entry->fence_context = sched_job->s_fence->finished.context;
  			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
-
  			   ),
  	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d",
  		      __get_str(dev), __entry->id,
@@ -88,6 +87,29 @@ TRACE_EVENT(drm_sched_process_job,
  		      __entry->fence_context, __entry->fence_seqno)
  );
 
+TRACE_EVENT(drm_sched_job_add_dep,
+	TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
+	TP_ARGS(sched_job, fence),
+	TP_STRUCT__entry(
+		    __field(u64, fence_context)
+		    __field(u64, fence_seqno)
+		    __field(u64, id)
+		    __field(u64, ctx)
+		    __field(u64, seqno)
+		    ),
+
+	TP_fast_assign(
+		    __entry->fence_context = sched_job->s_fence->finished.context;
+		    __entry->fence_seqno = sched_job->s_fence->finished.seqno;
+		    __entry->id = sched_job->id;
+		    __entry->ctx = fence->context;
+		    __entry->seqno = fence->seqno;
+		    ),
+	TP_printk("fence=%llu:%llu, id=%llu depends on fence=%llu:%llu",
+		  __entry->fence_context, __entry->fence_seqno, __entry->id,
+		  __entry->ctx, __entry->seqno)
+);
+
  TRACE_EVENT(drm_sched_job_wait_dep,
  	    TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
  	    TP_ARGS(sched_job, fence),
drivers/gpu/drm/scheduler/sched_entity.c +1 -0
index a6d2a4722d82..047e42cfb129 100644
@@ -580,6 +580,14 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
  	ktime_t submit_ts;
 
  	trace_drm_sched_job(sched_job, entity);
+

drivers/gpu/drm/scheduler/sched_entity.c void drm_sched_entity_push_job(struct drm_sched_job *sched_job) · line 593

Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +7 -0
+	if (trace_drm_sched_job_add_dep_enabled()) {
+		struct dma_fence *entry;
+		unsigned long index;
+
+		xa_for_each(&sched_job->dependencies, index, entry)
+			trace_drm_sched_job_add_dep(sched_job, entry);
+	}
  	atomic_inc(entity->rq->sched->score);
  	WRITE_ONCE(entity->last_user, current->group_leader);
 

Regards,

Tvrtko

#8 lore raw

PATCH v8 6/10 drm/sched: add the drm_client_id to the drm_sched_run/exec_job events

In reply to Pierre-Eric Pelloux-Prayer

For processes with multiple drm_file instances, the drm_client_id is the only way to map jobs back to their unique owner.

It's even more useful if drm client_name is set, because now a tool can map jobs to the client name instead of only having access to the process name.

---
 drivers/gpu/drm/scheduler/gpu_scheduler_trace.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +4 -2
index 5d9992ad47d3..38cdd659a286 100644
@@ -43,6 +43,7 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 			     __string(dev, dev_name(sched_job->sched->dev))
 			     __field(u64, fence_context)
 			     __field(u64, fence_seqno)
+			     __field(u64, client_id)
 			     ),
 
 	    TP_fast_assign(
@@ -54,11 +55,12 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 			   __assign_str(dev);
 			   __entry->fence_context = sched_job->s_fence->finished.context;
 			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
+			   __entry->client_id = sched_job->s_fence->drm_client_id;
 			   ),
-	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d",
+	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d, client_id:%llu",
 		      __get_str(dev), __entry->id,
 		      __entry->fence_context, __entry->fence_seqno, __get_str(name),
-		      __entry->job_count, __entry->hw_job_count)
+		      __entry->job_count, __entry->hw_job_count, __entry->client_id)
 );
 
 DEFINE_EVENT(drm_sched_job, drm_sched_job,
Signature · 1 line
2.43.0
Acked-by on v8 6/10
#9 lore raw

Re: [PATCH v8 06/10] drm/sched: add the drm_client_id to the drm_sched_run/exec_job events

Quoted 9 lines · Pierre-Eric Pelloux-Prayer

For processes with multiple drm_file instances, the drm_client_id is the only way to map jobs back to their unique owner.

It's even more useful if drm client_name is set, because now a tool can map jobs to the client name instead of only having access to the process name.

Signed-off-by Pierre-Eric Pelloux-Prayer
Quoted 41 lines

<[email protected]>
---
 drivers/gpu/drm/scheduler/gpu_scheduler_trace.h | 6 ++++--

 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0 -0
index 5d9992ad47d3..38cdd659a286 100644
@@ -43,6 +43,7 @@ DECLARE_EVENT_CLASS(drm_sched_job,

       __string(dev, dev_name(sched_job-

Quoted 1 line

sched->dev))

       __field(u64, fence_context) __field(u64, fence_seqno)

drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1 -0
+			     __field(u64, client_id)

       ),

      TP_fast_assign(

drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0 -0
@@ -54,11 +55,12 @@ DECLARE_EVENT_CLASS(drm_sched_job,
  			   __assign_str(dev);

     __entry->fence_context = sched_job-

Quoted 1 line

s_fence->finished.context;

     __entry->fence_seqno = sched_job-

Quoted 1 line

s_fence->finished.seqno;

drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1 -0
+			   __entry->client_id = sched_job->s_fence-
Quoted 1 line

drm_client_id;

     ),

drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0 -1
-	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s,

job count:%u, hw job count:%d",

drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1 -0
+	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s,

job count:%u, hw job count:%d, client_id:%llu", __get_str(dev), __entry->id, __entry->fence_context, __entry->fence_seqno, __get_str(name),

drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1 -1
-		      __entry->job_count, __entry->hw_job_count)
+		      __entry->job_count, __entry->hw_job_count,

__entry->client_id)
 );

 DEFINE_EVENT(drm_sched_job, drm_sched_job,

#10 lore raw

PATCH v8 7/10 drm/sched: cleanup event names

In reply to Pierre-Eric Pelloux-Prayer

All events now start with the same prefix (drm_sched_job_).

drm_sched_job_wait_dep was misleading because it wasn't waiting at all. It's now replaced by trace_drm_sched_job_unschedulable, which is only traced if the job cannot be scheduled. For moot dependencies, nothing is traced.

---
 drivers/gpu/drm/scheduler/gpu_scheduler_trace.h | 8 ++++----
 drivers/gpu/drm/scheduler/sched_entity.c        | 8 ++++----
 drivers/gpu/drm/scheduler/sched_main.c          | 4 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +4 -4
index 38cdd659a286..4ce53e493fef 100644
@@ -63,17 +63,17 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 		      __entry->job_count, __entry->hw_job_count, __entry->client_id)
 );
 
-DEFINE_EVENT(drm_sched_job, drm_sched_job,
+DEFINE_EVENT(drm_sched_job, drm_sched_job_queue,
 	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
 	    TP_ARGS(sched_job, entity)
 );
 
-DEFINE_EVENT(drm_sched_job, drm_run_job,
+DEFINE_EVENT(drm_sched_job, drm_sched_job_run,
 	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
 	    TP_ARGS(sched_job, entity)
 );
 
-TRACE_EVENT(drm_sched_process_job,
+TRACE_EVENT(drm_sched_job_done,
 	    TP_PROTO(struct drm_sched_fence *fence),
 	    TP_ARGS(fence),
 	    TP_STRUCT__entry(
@@ -112,7 +112,7 @@ TRACE_EVENT(drm_sched_job_add_dep,
 		  __entry->ctx, __entry->seqno)
 );
 
-TRACE_EVENT(drm_sched_job_wait_dep,
+TRACE_EVENT(drm_sched_job_unschedulable,
 	    TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
 	    TP_ARGS(sched_job, fence),
 	    TP_STRUCT__entry(
drivers/gpu/drm/scheduler/sched_entity.c +4 -4
index 047e42cfb129..0bad247f783e 100644
@@ -470,10 +470,10 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)
 
 	while ((entity->dependency =
 			drm_sched_job_dependency(sched_job, entity))) {
-		trace_drm_sched_job_wait_dep(sched_job, entity->dependency);
-
-		if (drm_sched_entity_add_dependency_cb(entity))
+		if (drm_sched_entity_add_dependency_cb(entity)) {
+			trace_drm_sched_job_unschedulable(sched_job, entity->dependency);
 			return NULL;
+		}
 	}
 
 	/* skip jobs from entity that marked guilty */
@@ -579,7 +579,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
 	bool first;
 	ktime_t submit_ts;
 
-	trace_drm_sched_job(sched_job, entity);
+	trace_drm_sched_job_queue(sched_job, entity);
 
 	if (trace_drm_sched_job_add_dep_enabled()) {
 		struct dma_fence *entry;
drivers/gpu/drm/scheduler/sched_main.c +2 -2
index 501eae13acb3..85c2111e5500 100644
@@ -401,7 +401,7 @@ static void drm_sched_job_done(struct drm_sched_job *s_job, int result)
 	atomic_sub(s_job->credits, &sched->credit_count);
 	atomic_dec(sched->score);
 
-	trace_drm_sched_process_job(s_fence);
+	trace_drm_sched_job_done(s_fence);
 
 	dma_fence_get(&s_fence->finished);
 	drm_sched_fence_finished(s_fence, result);
@@ -1221,7 +1221,7 @@ static void drm_sched_run_job_work(struct work_struct *w)
 	atomic_add(sched_job->credits, &sched->credit_count);
 	drm_sched_job_begin(sched_job);
 
-	trace_drm_run_job(sched_job, entity);
+	trace_drm_sched_job_run(sched_job, entity);
 	fence = sched->ops->run_job(sched_job);
 	complete_all(&entity->entity_idle);
 	drm_sched_fence_scheduled(s_fence, fence);
Signature · 1 line
2.43.0
Reviewed-by on v8 7/10
#11 lore raw

Re: [PATCH v8 07/10] drm/sched: cleanup event names

Quoted 89 lines · Pierre-Eric Pelloux-Prayer

All events now start with the same prefix (drm_sched_job_).

drm_sched_job_wait_dep was misleading because it wasn't waiting at all. It's now replaced by trace_drm_sched_job_unschedulable, which is only traced if the job cannot be scheduled. For moot dependencies, nothing is traced.

---
  drivers/gpu/drm/scheduler/gpu_scheduler_trace.h | 8 ++++----
  drivers/gpu/drm/scheduler/sched_entity.c        | 8 ++++----
  drivers/gpu/drm/scheduler/sched_main.c          | 4 ++--
  3 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +4 -4
index 38cdd659a286..4ce53e493fef 100644
@@ -63,17 +63,17 @@ DECLARE_EVENT_CLASS(drm_sched_job,
  		      __entry->job_count, __entry->hw_job_count, __entry->client_id)
  );
 
-DEFINE_EVENT(drm_sched_job, drm_sched_job,
+DEFINE_EVENT(drm_sched_job, drm_sched_job_queue,
  	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
  	    TP_ARGS(sched_job, entity)
  );
 
-DEFINE_EVENT(drm_sched_job, drm_run_job,
+DEFINE_EVENT(drm_sched_job, drm_sched_job_run,
  	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
  	    TP_ARGS(sched_job, entity)
  );
 
-TRACE_EVENT(drm_sched_process_job,
+TRACE_EVENT(drm_sched_job_done,
  	    TP_PROTO(struct drm_sched_fence *fence),
  	    TP_ARGS(fence),
  	    TP_STRUCT__entry(
@@ -112,7 +112,7 @@ TRACE_EVENT(drm_sched_job_add_dep,
  		  __entry->ctx, __entry->seqno)
  );
 
-TRACE_EVENT(drm_sched_job_wait_dep,
+TRACE_EVENT(drm_sched_job_unschedulable,
  	    TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
  	    TP_ARGS(sched_job, fence),
  	    TP_STRUCT__entry(
drivers/gpu/drm/scheduler/sched_entity.c +4 -4
index 047e42cfb129..0bad247f783e 100644
@@ -470,10 +470,10 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)
 
  	while ((entity->dependency =
  			drm_sched_job_dependency(sched_job, entity))) {
-		trace_drm_sched_job_wait_dep(sched_job, entity->dependency);
-
-		if (drm_sched_entity_add_dependency_cb(entity))
+		if (drm_sched_entity_add_dependency_cb(entity)) {
+			trace_drm_sched_job_unschedulable(sched_job, entity->dependency);
  			return NULL;
+		}
  	}
 
  	/* skip jobs from entity that marked guilty */
@@ -579,7 +579,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
  	bool first;
  	ktime_t submit_ts;
 
-	trace_drm_sched_job(sched_job, entity);
+	trace_drm_sched_job_queue(sched_job, entity);
 
  	if (trace_drm_sched_job_add_dep_enabled()) {
  		struct dma_fence *entry;
drivers/gpu/drm/scheduler/sched_main.c +1 -1
index 501eae13acb3..85c2111e5500 100644
@@ -401,7 +401,7 @@ static void drm_sched_job_done(struct drm_sched_job *s_job, int result)
  	atomic_sub(s_job->credits, &sched->credit_count);
  	atomic_dec(sched->score);
 
-	trace_drm_sched_process_job(s_fence);
+	trace_drm_sched_job_done(s_fence);
 
  	dma_fence_get(&s_fence->finished);
  	drm_sched_fence_finished(s_fence, result);

drivers/gpu/drm/scheduler/sched_main.c static void drm_sched_run_job_work(struct work_struct *w) · line 1227

Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c +1 -1
@@ -1221,7 +1221,7 @@ static void drm_sched_run_job_work(struct work_struct *w)
  	atomic_add(sched_job->credits, &sched->credit_count);
  	drm_sched_job_begin(sched_job);
 
-	trace_drm_run_job(sched_job, entity);
+	trace_drm_sched_job_run(sched_job, entity);
  	fence = sched->ops->run_job(sched_job);
  	complete_all(&entity->entity_idle);
  	drm_sched_fence_scheduled(s_fence, fence);

Regards,

Tvrtko

#12 lore raw

PATCH v8 8/10 drm/doc: document some tracepoints as uAPI

In reply to Pierre-Eric Pelloux-Prayer

This commit adds a document section in drm-uapi.rst about tracepoints, and mark the events gpu_scheduler_trace.h as stable uAPI.

The goal is to explicitly state that tools can rely on the fields, formats and semantics of these events.

---
 Documentation/gpu/drm-uapi.rst                | 19 ++++++++++++++++
 .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 22 +++++++++++++++++++
 2 files changed, 41 insertions(+)
Documentation/gpu/drm-uapi.rst +19 -0
index 69f72e71a96e..4863a4deb0ee 100644
@@ -693,3 +693,22 @@ dma-buf interoperability
 
 Please see Documentation/userspace-api/dma-buf-alloc-exchange.rst for
 information on how dma-buf is integrated and exposed within DRM.
+
+
+Trace events
+============
+
+See Documentation/trace/tracepoints.rst for information about using
+Linux Kernel Tracepoints.
+In the DRM subsystem, some events are considered stable uAPI to avoid
+breaking tools (e.g.: GPUVis, umr) relying on them. Stable means that fields
+cannot be removed, nor their formatting updated. Adding new fields is
+possible, under the normal uAPI requirements.
+
+Stable uAPI events
+------------------
+
+From ``drivers/gpu/drm/scheduler/gpu_scheduler_trace.h``
+
+.. kernel-doc::  drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
+   :doc: uAPI trace events
\ No newline at end of file
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +22 -0
index 4ce53e493fef..3c7f6a39cf91 100644
@@ -32,6 +32,28 @@
 #define TRACE_SYSTEM gpu_scheduler
 #define TRACE_INCLUDE_FILE gpu_scheduler_trace
 
+/**
+ * DOC: uAPI trace events
+ *
+ * ``drm_sched_job_queue``, ``drm_sched_job_run``, ``drm_sched_job_add_dep``,
+ * ``drm_sched_job_done`` and ``drm_sched_job_unschedulable`` are considered
+ * stable uAPI.
+ *
+ * Common trace events attributes:
+ *
+ * * ``id``    - this is &drm_sched_job->id. It uniquely idenfies a job
+ *   inside a &struct drm_gpu_scheduler.
+ *
+ * * ``dev``   - the dev_name() of the device running the job.
+ *
+ * * ``ring``  - the hardware ring running the job. Together with ``dev`` it
+ *   uniquely identifies where the job is going to be executed.
+ *
+ * * ``fence`` - the &dma_fence.context and the &dma_fence.seqno of
+ *   &drm_sched_fence.finished
+ *
+ */
+
 DECLARE_EVENT_CLASS(drm_sched_job,
 	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
 	    TP_ARGS(sched_job, entity),
Signature · 1 line
2.43.0
#13 lore raw

PATCH v8 9/10 drm: get rid of drm_sched_job::id

In reply to Pierre-Eric Pelloux-Prayer

Its only purpose was for trace events, but jobs can already be uniquely identified using their fence.

The downside of using the fence is that it's only available after 'drm_sched_job_arm' was called which is true for all trace events that used job.id so they can safely switch to using it.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h      | 18 ++++++------------
 .../gpu/drm/scheduler/gpu_scheduler_trace.h    | 18 ++++++------------
 drivers/gpu/drm/scheduler/sched_main.c         |  1 -
 include/drm/gpu_scheduler.h                    |  3 ---
 4 files changed, 12 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +6 -12
index 383fce40d4dd..a4f394d827bc 100644
@@ -167,7 +167,6 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 	    TP_PROTO(struct amdgpu_job *job),
 	    TP_ARGS(job),
 	    TP_STRUCT__entry(
-			     __field(uint64_t, sched_job_id)
 			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
 			     __field(unsigned int, context)
 			     __field(unsigned int, seqno)
@@ -177,15 +176,14 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 			     ),
 
 	    TP_fast_assign(
-			   __entry->sched_job_id = job->base.id;
 			   __assign_str(timeline);
 			   __entry->context = job->base.s_fence->finished.context;
 			   __entry->seqno = job->base.s_fence->finished.seqno;
 			   __assign_str(ring);
 			   __entry->num_ibs = job->num_ibs;
 			   ),
-	    TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
-		      __entry->sched_job_id, __get_str(timeline), __entry->context,
+	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+		      __get_str(timeline), __entry->context,
 		      __entry->seqno, __get_str(ring), __entry->num_ibs)
 );
 
@@ -193,7 +191,6 @@ TRACE_EVENT(amdgpu_sched_run_job,
 	    TP_PROTO(struct amdgpu_job *job),
 	    TP_ARGS(job),
 	    TP_STRUCT__entry(
-			     __field(uint64_t, sched_job_id)
 			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
 			     __field(unsigned int, context)
 			     __field(unsigned int, seqno)
@@ -202,15 +199,14 @@ TRACE_EVENT(amdgpu_sched_run_job,
 			     ),
 
 	    TP_fast_assign(
-			   __entry->sched_job_id = job->base.id;
 			   __assign_str(timeline);
 			   __entry->context = job->base.s_fence->finished.context;
 			   __entry->seqno = job->base.s_fence->finished.seqno;
 			   __assign_str(ring);
 			   __entry->num_ibs = job->num_ibs;
 			   ),
-	    TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
-		      __entry->sched_job_id, __get_str(timeline), __entry->context,
+	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+		      __get_str(timeline), __entry->context,
 		      __entry->seqno, __get_str(ring), __entry->num_ibs)
 );
 
@@ -519,7 +515,6 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
 	    TP_ARGS(sched_job, fence),
 	    TP_STRUCT__entry(
 			     __string(ring, sched_job->base.sched->name)
-			     __field(uint64_t, id)
 			     __field(struct dma_fence *, fence)
 			     __field(uint64_t, ctx)
 			     __field(unsigned, seqno)
@@ -527,13 +522,12 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
 
 	    TP_fast_assign(
 			   __assign_str(ring);
-			   __entry->id = sched_job->base.id;
 			   __entry->fence = fence;
 			   __entry->ctx = fence->context;
 			   __entry->seqno = fence->seqno;
 			   ),
-	    TP_printk("job ring=%s, id=%llu, need pipe sync to fence=%p, context=%llu, seq=%u",
-		      __get_str(ring), __entry->id,
+	    TP_printk("job ring=%s need pipe sync to fence=%p, context=%llu, seq=%u",
+		      __get_str(ring),
 		      __entry->fence, __entry->ctx,
 		      __entry->seqno)
 );
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +6 -12
index 3c7f6a39cf91..ad03240b2f03 100644
@@ -58,7 +58,6 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
 	    TP_ARGS(sched_job, entity),
 	    TP_STRUCT__entry(
-			     __field(uint64_t, id)
 			     __string(name, sched_job->sched->name)
 			     __field(u32, job_count)
 			     __field(int, hw_job_count)
@@ -69,7 +68,6 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 			     ),
 
 	    TP_fast_assign(
-			   __entry->id = sched_job->id;
 			   __assign_str(name);
 			   __entry->job_count = spsc_queue_count(&entity->job_queue);
 			   __entry->hw_job_count = atomic_read(
@@ -79,8 +77,8 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
 			   __entry->client_id = sched_job->s_fence->drm_client_id;
 			   ),
-	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d, client_id:%llu",
-		      __get_str(dev), __entry->id,
+	    TP_printk("dev=%s, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d, client_id:%llu",
+		      __get_str(dev),
 		      __entry->fence_context, __entry->fence_seqno, __get_str(name),
 		      __entry->job_count, __entry->hw_job_count, __entry->client_id)
 );
@@ -117,7 +115,6 @@ TRACE_EVENT(drm_sched_job_add_dep,
 	TP_STRUCT__entry(
 		    __field(u64, fence_context)
 		    __field(u64, fence_seqno)
-		    __field(u64, id)
 		    __field(u64, ctx)
 		    __field(u64, seqno)
 		    ),
@@ -125,12 +122,11 @@ TRACE_EVENT(drm_sched_job_add_dep,
 	TP_fast_assign(
 		    __entry->fence_context = sched_job->s_fence->finished.context;
 		    __entry->fence_seqno = sched_job->s_fence->finished.seqno;
-		    __entry->id = sched_job->id;
 		    __entry->ctx = fence->context;
 		    __entry->seqno = fence->seqno;
 		    ),
-	TP_printk("fence=%llu:%llu, id=%llu depends on fence=%llu:%llu",
-		  __entry->fence_context, __entry->fence_seqno, __entry->id,
+	TP_printk("fence=%llu:%llu depends on fence=%llu:%llu",
+		  __entry->fence_context, __entry->fence_seqno,
 		  __entry->ctx, __entry->seqno)
 );
 
@@ -140,7 +136,6 @@ TRACE_EVENT(drm_sched_job_unschedulable,
 	    TP_STRUCT__entry(
 			     __field(u64, fence_context)
 			     __field(u64, fence_seqno)
-			     __field(uint64_t, id)
 			     __field(u64, ctx)
 			     __field(u64, seqno)
 			     ),
@@ -148,12 +143,11 @@ TRACE_EVENT(drm_sched_job_unschedulable,
 	    TP_fast_assign(
 			   __entry->fence_context = sched_job->s_fence->finished.context;
 			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
-			   __entry->id = sched_job->id;
 			   __entry->ctx = fence->context;
 			   __entry->seqno = fence->seqno;
 			   ),
-	    TP_printk("fence=%llu:%llu, id=%llu depends on unsignalled fence=%llu:%llu",
-		      __entry->fence_context, __entry->fence_seqno, __entry->id,
+	    TP_printk("fence=%llu:%llu depends on unsignalled fence=%llu:%llu",
+		      __entry->fence_context, __entry->fence_seqno,
 		      __entry->ctx, __entry->seqno)
 );
 
drivers/gpu/drm/scheduler/sched_main.c +0 -1
index 85c2111e5500..85e0ba850746 100644
@@ -848,7 +848,6 @@ void drm_sched_job_arm(struct drm_sched_job *job)
 
 	job->sched = sched;
 	job->s_priority = entity->priority;
-	job->id = atomic64_inc_return(&sched->job_id_count);
 
 	drm_sched_fence_init(job->s_fence, job->entity);
 }
include/drm/gpu_scheduler.h +0 -3
index 032214a49138..ddc24512c281 100644
@@ -326,7 +326,6 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f);
  * @finish_cb: the callback for the finished fence.
  * @credits: the number of credits this job contributes to the scheduler
  * @work: Helper to reschedule job kill to different context.
- * @id: a unique id assigned to each job scheduled on the scheduler.
  * @karma: increment on every hang caused by this job. If this exceeds the hang
  *         limit of the scheduler then the job is marked guilty and will not
  *         be scheduled further.
@@ -339,8 +338,6 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f);
  * to schedule the job.
  */
 struct drm_sched_job {
-	u64				id;
-
 	/**
 	 * @submit_ts:
 	 *
Signature · 1 line
2.43.0
maintainer Reviewed-by on v8 9/10
#14 lore raw

Re: [PATCH v8 09/10] drm: get rid of drm_sched_job::id

Am 20.03.25 um 10:58 schrieb Pierre-Eric Pelloux-Prayer:

Quoted 9 lines

Its only purpose was for trace events, but jobs can already be uniquely identified using their fence.

The downside of using the fence is that it's only available after 'drm_sched_job_arm' was called which is true for all trace events that used job.id so they can safely switch to using it.

Quoted 197 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h      | 18 ++++++------------
 .../gpu/drm/scheduler/gpu_scheduler_trace.h    | 18 ++++++------------
 drivers/gpu/drm/scheduler/sched_main.c         |  1 -
 include/drm/gpu_scheduler.h                    |  3 ---
 4 files changed, 12 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +6 -12
index 383fce40d4dd..a4f394d827bc 100644
@@ -167,7 +167,6 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 	    TP_PROTO(struct amdgpu_job *job),
 	    TP_ARGS(job),
 	    TP_STRUCT__entry(
-			     __field(uint64_t, sched_job_id)
 			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
 			     __field(unsigned int, context)
 			     __field(unsigned int, seqno)
@@ -177,15 +176,14 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 			     ),
 
 	    TP_fast_assign(
-			   __entry->sched_job_id = job->base.id;
 			   __assign_str(timeline);
 			   __entry->context = job->base.s_fence->finished.context;
 			   __entry->seqno = job->base.s_fence->finished.seqno;
 			   __assign_str(ring);
 			   __entry->num_ibs = job->num_ibs;
 			   ),
-	    TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
-		      __entry->sched_job_id, __get_str(timeline), __entry->context,
+	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+		      __get_str(timeline), __entry->context,
 		      __entry->seqno, __get_str(ring), __entry->num_ibs)
 );
 
@@ -193,7 +191,6 @@ TRACE_EVENT(amdgpu_sched_run_job,
 	    TP_PROTO(struct amdgpu_job *job),
 	    TP_ARGS(job),
 	    TP_STRUCT__entry(
-			     __field(uint64_t, sched_job_id)
 			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
 			     __field(unsigned int, context)
 			     __field(unsigned int, seqno)
@@ -202,15 +199,14 @@ TRACE_EVENT(amdgpu_sched_run_job,
 			     ),
 
 	    TP_fast_assign(
-			   __entry->sched_job_id = job->base.id;
 			   __assign_str(timeline);
 			   __entry->context = job->base.s_fence->finished.context;
 			   __entry->seqno = job->base.s_fence->finished.seqno;
 			   __assign_str(ring);
 			   __entry->num_ibs = job->num_ibs;
 			   ),
-	    TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
-		      __entry->sched_job_id, __get_str(timeline), __entry->context,
+	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+		      __get_str(timeline), __entry->context,
 		      __entry->seqno, __get_str(ring), __entry->num_ibs)
 );
 
@@ -519,7 +515,6 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
 	    TP_ARGS(sched_job, fence),
 	    TP_STRUCT__entry(
 			     __string(ring, sched_job->base.sched->name)
-			     __field(uint64_t, id)
 			     __field(struct dma_fence *, fence)
 			     __field(uint64_t, ctx)
 			     __field(unsigned, seqno)
@@ -527,13 +522,12 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
 
 	    TP_fast_assign(
 			   __assign_str(ring);
-			   __entry->id = sched_job->base.id;
 			   __entry->fence = fence;
 			   __entry->ctx = fence->context;
 			   __entry->seqno = fence->seqno;
 			   ),
-	    TP_printk("job ring=%s, id=%llu, need pipe sync to fence=%p, context=%llu, seq=%u",
-		      __get_str(ring), __entry->id,
+	    TP_printk("job ring=%s need pipe sync to fence=%p, context=%llu, seq=%u",
+		      __get_str(ring),
 		      __entry->fence, __entry->ctx,
 		      __entry->seqno)
 );
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +6 -12
index 3c7f6a39cf91..ad03240b2f03 100644
@@ -58,7 +58,6 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
 	    TP_ARGS(sched_job, entity),
 	    TP_STRUCT__entry(
-			     __field(uint64_t, id)
 			     __string(name, sched_job->sched->name)
 			     __field(u32, job_count)
 			     __field(int, hw_job_count)
@@ -69,7 +68,6 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 			     ),
 
 	    TP_fast_assign(
-			   __entry->id = sched_job->id;
 			   __assign_str(name);
 			   __entry->job_count = spsc_queue_count(&entity->job_queue);
 			   __entry->hw_job_count = atomic_read(
@@ -79,8 +77,8 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
 			   __entry->client_id = sched_job->s_fence->drm_client_id;
 			   ),
-	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d, client_id:%llu",
-		      __get_str(dev), __entry->id,
+	    TP_printk("dev=%s, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d, client_id:%llu",
+		      __get_str(dev),
 		      __entry->fence_context, __entry->fence_seqno, __get_str(name),
 		      __entry->job_count, __entry->hw_job_count, __entry->client_id)
 );
@@ -117,7 +115,6 @@ TRACE_EVENT(drm_sched_job_add_dep,
 	TP_STRUCT__entry(
 		    __field(u64, fence_context)
 		    __field(u64, fence_seqno)
-		    __field(u64, id)
 		    __field(u64, ctx)
 		    __field(u64, seqno)
 		    ),
@@ -125,12 +122,11 @@ TRACE_EVENT(drm_sched_job_add_dep,
 	TP_fast_assign(
 		    __entry->fence_context = sched_job->s_fence->finished.context;
 		    __entry->fence_seqno = sched_job->s_fence->finished.seqno;
-		    __entry->id = sched_job->id;
 		    __entry->ctx = fence->context;
 		    __entry->seqno = fence->seqno;
 		    ),
-	TP_printk("fence=%llu:%llu, id=%llu depends on fence=%llu:%llu",
-		  __entry->fence_context, __entry->fence_seqno, __entry->id,
+	TP_printk("fence=%llu:%llu depends on fence=%llu:%llu",
+		  __entry->fence_context, __entry->fence_seqno,
 		  __entry->ctx, __entry->seqno)
 );
 
@@ -140,7 +136,6 @@ TRACE_EVENT(drm_sched_job_unschedulable,
 	    TP_STRUCT__entry(
 			     __field(u64, fence_context)
 			     __field(u64, fence_seqno)
-			     __field(uint64_t, id)
 			     __field(u64, ctx)
 			     __field(u64, seqno)
 			     ),
@@ -148,12 +143,11 @@ TRACE_EVENT(drm_sched_job_unschedulable,
 	    TP_fast_assign(
 			   __entry->fence_context = sched_job->s_fence->finished.context;
 			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
-			   __entry->id = sched_job->id;
 			   __entry->ctx = fence->context;
 			   __entry->seqno = fence->seqno;
 			   ),
-	    TP_printk("fence=%llu:%llu, id=%llu depends on unsignalled fence=%llu:%llu",
-		      __entry->fence_context, __entry->fence_seqno, __entry->id,
+	    TP_printk("fence=%llu:%llu depends on unsignalled fence=%llu:%llu",
+		      __entry->fence_context, __entry->fence_seqno,
 		      __entry->ctx, __entry->seqno)
 );
 
drivers/gpu/drm/scheduler/sched_main.c +0 -1
index 85c2111e5500..85e0ba850746 100644
@@ -848,7 +848,6 @@ void drm_sched_job_arm(struct drm_sched_job *job)
 
 	job->sched = sched;
 	job->s_priority = entity->priority;
-	job->id = atomic64_inc_return(&sched->job_id_count);
 
 	drm_sched_fence_init(job->s_fence, job->entity);
 }
include/drm/gpu_scheduler.h +0 -3
index 032214a49138..ddc24512c281 100644
@@ -326,7 +326,6 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f);
  * @finish_cb: the callback for the finished fence.
  * @credits: the number of credits this job contributes to the scheduler
  * @work: Helper to reschedule job kill to different context.
- * @id: a unique id assigned to each job scheduled on the scheduler.
  * @karma: increment on every hang caused by this job. If this exceeds the hang
  *         limit of the scheduler then the job is marked guilty and will not
  *         be scheduled further.
@@ -339,8 +338,6 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f);
  * to schedule the job.
  */
 struct drm_sched_job {
-	u64				id;
-
 	/**
 	 * @submit_ts:
 	 *
#15 lore raw

Re: [PATCH v8 09/10] drm: get rid of drm_sched_job::id

In reply to Pierre-Eric Pelloux-Prayer
Quoted 6 lines · Pierre-Eric Pelloux-Prayer

Its only purpose was for trace events, but jobs can already be uniquely identified using their fence.

The downside of using the fence is that it's only available after 'drm_sched_job_arm' was called which is true for all trace events that used job.id so they can safely switch to using it.

Perhaps it would make more sense to pull in this patch to before the one declaring tracpoints stable ABI.

Also note that patched declared job->id as stable and this one forgot to remove that.

The rest LGTM.

Regards,

Tvrtko

Quoted 200 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h      | 18 ++++++------------
  .../gpu/drm/scheduler/gpu_scheduler_trace.h    | 18 ++++++------------
  drivers/gpu/drm/scheduler/sched_main.c         |  1 -
  include/drm/gpu_scheduler.h                    |  3 ---
  4 files changed, 12 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +6 -12
index 383fce40d4dd..a4f394d827bc 100644
@@ -167,7 +167,6 @@ TRACE_EVENT(amdgpu_cs_ioctl,
  	    TP_PROTO(struct amdgpu_job *job),
  	    TP_ARGS(job),
  	    TP_STRUCT__entry(
-			     __field(uint64_t, sched_job_id)
  			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
  			     __field(unsigned int, context)
  			     __field(unsigned int, seqno)
@@ -177,15 +176,14 @@ TRACE_EVENT(amdgpu_cs_ioctl,
  			     ),
 
  	    TP_fast_assign(
-			   __entry->sched_job_id = job->base.id;
  			   __assign_str(timeline);
  			   __entry->context = job->base.s_fence->finished.context;
  			   __entry->seqno = job->base.s_fence->finished.seqno;
  			   __assign_str(ring);
  			   __entry->num_ibs = job->num_ibs;
  			   ),
-	    TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
-		      __entry->sched_job_id, __get_str(timeline), __entry->context,
+	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+		      __get_str(timeline), __entry->context,
  		      __entry->seqno, __get_str(ring), __entry->num_ibs)
  );
 
@@ -193,7 +191,6 @@ TRACE_EVENT(amdgpu_sched_run_job,
  	    TP_PROTO(struct amdgpu_job *job),
  	    TP_ARGS(job),
  	    TP_STRUCT__entry(
-			     __field(uint64_t, sched_job_id)
  			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
  			     __field(unsigned int, context)
  			     __field(unsigned int, seqno)
@@ -202,15 +199,14 @@ TRACE_EVENT(amdgpu_sched_run_job,
  			     ),
 
  	    TP_fast_assign(
-			   __entry->sched_job_id = job->base.id;
  			   __assign_str(timeline);
  			   __entry->context = job->base.s_fence->finished.context;
  			   __entry->seqno = job->base.s_fence->finished.seqno;
  			   __assign_str(ring);
  			   __entry->num_ibs = job->num_ibs;
  			   ),
-	    TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
-		      __entry->sched_job_id, __get_str(timeline), __entry->context,
+	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+		      __get_str(timeline), __entry->context,
  		      __entry->seqno, __get_str(ring), __entry->num_ibs)
  );
 
@@ -519,7 +515,6 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
  	    TP_ARGS(sched_job, fence),
  	    TP_STRUCT__entry(
  			     __string(ring, sched_job->base.sched->name)
-			     __field(uint64_t, id)
  			     __field(struct dma_fence *, fence)
  			     __field(uint64_t, ctx)
  			     __field(unsigned, seqno)
@@ -527,13 +522,12 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
 
  	    TP_fast_assign(
  			   __assign_str(ring);
-			   __entry->id = sched_job->base.id;
  			   __entry->fence = fence;
  			   __entry->ctx = fence->context;
  			   __entry->seqno = fence->seqno;
  			   ),
-	    TP_printk("job ring=%s, id=%llu, need pipe sync to fence=%p, context=%llu, seq=%u",
-		      __get_str(ring), __entry->id,
+	    TP_printk("job ring=%s need pipe sync to fence=%p, context=%llu, seq=%u",
+		      __get_str(ring),
  		      __entry->fence, __entry->ctx,
  		      __entry->seqno)
  );
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +6 -12
index 3c7f6a39cf91..ad03240b2f03 100644
@@ -58,7 +58,6 @@ DECLARE_EVENT_CLASS(drm_sched_job,
  	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
  	    TP_ARGS(sched_job, entity),
  	    TP_STRUCT__entry(
-			     __field(uint64_t, id)
  			     __string(name, sched_job->sched->name)
  			     __field(u32, job_count)
  			     __field(int, hw_job_count)
@@ -69,7 +68,6 @@ DECLARE_EVENT_CLASS(drm_sched_job,
  			     ),
 
  	    TP_fast_assign(
-			   __entry->id = sched_job->id;
  			   __assign_str(name);
  			   __entry->job_count = spsc_queue_count(&entity->job_queue);
  			   __entry->hw_job_count = atomic_read(
@@ -79,8 +77,8 @@ DECLARE_EVENT_CLASS(drm_sched_job,
  			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
  			   __entry->client_id = sched_job->s_fence->drm_client_id;
  			   ),
-	    TP_printk("dev=%s, id=%llu, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d, client_id:%llu",
-		      __get_str(dev), __entry->id,
+	    TP_printk("dev=%s, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d, client_id:%llu",
+		      __get_str(dev),
  		      __entry->fence_context, __entry->fence_seqno, __get_str(name),
  		      __entry->job_count, __entry->hw_job_count, __entry->client_id)
  );
@@ -117,7 +115,6 @@ TRACE_EVENT(drm_sched_job_add_dep,
  	TP_STRUCT__entry(
  		    __field(u64, fence_context)
  		    __field(u64, fence_seqno)
-		    __field(u64, id)
  		    __field(u64, ctx)
  		    __field(u64, seqno)
  		    ),
@@ -125,12 +122,11 @@ TRACE_EVENT(drm_sched_job_add_dep,
  	TP_fast_assign(
  		    __entry->fence_context = sched_job->s_fence->finished.context;
  		    __entry->fence_seqno = sched_job->s_fence->finished.seqno;
-		    __entry->id = sched_job->id;
  		    __entry->ctx = fence->context;
  		    __entry->seqno = fence->seqno;
  		    ),
-	TP_printk("fence=%llu:%llu, id=%llu depends on fence=%llu:%llu",
-		  __entry->fence_context, __entry->fence_seqno, __entry->id,
+	TP_printk("fence=%llu:%llu depends on fence=%llu:%llu",
+		  __entry->fence_context, __entry->fence_seqno,
  		  __entry->ctx, __entry->seqno)
  );
 
@@ -140,7 +136,6 @@ TRACE_EVENT(drm_sched_job_unschedulable,
  	    TP_STRUCT__entry(
  			     __field(u64, fence_context)
  			     __field(u64, fence_seqno)
-			     __field(uint64_t, id)
  			     __field(u64, ctx)
  			     __field(u64, seqno)
  			     ),
@@ -148,12 +143,11 @@ TRACE_EVENT(drm_sched_job_unschedulable,
  	    TP_fast_assign(
  			   __entry->fence_context = sched_job->s_fence->finished.context;
  			   __entry->fence_seqno = sched_job->s_fence->finished.seqno;
-			   __entry->id = sched_job->id;
  			   __entry->ctx = fence->context;
  			   __entry->seqno = fence->seqno;
  			   ),
-	    TP_printk("fence=%llu:%llu, id=%llu depends on unsignalled fence=%llu:%llu",
-		      __entry->fence_context, __entry->fence_seqno, __entry->id,
+	    TP_printk("fence=%llu:%llu depends on unsignalled fence=%llu:%llu",
+		      __entry->fence_context, __entry->fence_seqno,
  		      __entry->ctx, __entry->seqno)
  );
 
drivers/gpu/drm/scheduler/sched_main.c +0 -1
index 85c2111e5500..85e0ba850746 100644
@@ -848,7 +848,6 @@ void drm_sched_job_arm(struct drm_sched_job *job)
 
  	job->sched = sched;
  	job->s_priority = entity->priority;
-	job->id = atomic64_inc_return(&sched->job_id_count);
 
  	drm_sched_fence_init(job->s_fence, job->entity);
  }
include/drm/gpu_scheduler.h +0 -3
index 032214a49138..ddc24512c281 100644
@@ -326,7 +326,6 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f);
   * @finish_cb: the callback for the finished fence.
   * @credits: the number of credits this job contributes to the scheduler
   * @work: Helper to reschedule job kill to different context.
- * @id: a unique id assigned to each job scheduled on the scheduler.
   * @karma: increment on every hang caused by this job. If this exceeds the hang
   *         limit of the scheduler then the job is marked guilty and will not
   *         be scheduled further.
@@ -339,8 +338,6 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f);
   * to schedule the job.
   */
  struct drm_sched_job {
-	u64				id;
-
  	/**
  	 * @submit_ts:
  	 *
#16 lore raw

PATCH v8 10/10 drm/amdgpu: update trace format to match gpu_scheduler_trace

In reply to Pierre-Eric Pelloux-Prayer

Log fences using the same format for coherency.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -12
index a4f394d827bc..d302c68c1258 100644
@@ -168,8 +168,8 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 	    TP_ARGS(job),
 	    TP_STRUCT__entry(
 			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
-			     __field(unsigned int, context)
-			     __field(unsigned int, seqno)
+			     __field(u64, context)
+			     __field(u64, seqno)
 			     __field(struct dma_fence *, fence)
 			     __string(ring, to_amdgpu_ring(job->base.sched)->name)
 			     __field(u32, num_ibs)
@@ -182,7 +182,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 			   __assign_str(ring);
 			   __entry->num_ibs = job->num_ibs;
 			   ),
-	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+	    TP_printk("timeline=%s, fence=%llu:%llu, ring_name=%s, num_ibs=%u",
 		      __get_str(timeline), __entry->context,
 		      __entry->seqno, __get_str(ring), __entry->num_ibs)
 );
@@ -192,8 +192,8 @@ TRACE_EVENT(amdgpu_sched_run_job,
 	    TP_ARGS(job),
 	    TP_STRUCT__entry(
 			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
-			     __field(unsigned int, context)
-			     __field(unsigned int, seqno)
+			     __field(u64, context)
+			     __field(u64, seqno)
 			     __string(ring, to_amdgpu_ring(job->base.sched)->name)
 			     __field(u32, num_ibs)
 			     ),
@@ -205,7 +205,7 @@ TRACE_EVENT(amdgpu_sched_run_job,
 			   __assign_str(ring);
 			   __entry->num_ibs = job->num_ibs;
 			   ),
-	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+	    TP_printk("timeline=%s, fence=%llu:%llu, ring_name=%s, num_ibs=%u",
 		      __get_str(timeline), __entry->context,
 		      __entry->seqno, __get_str(ring), __entry->num_ibs)
 );
@@ -516,8 +516,8 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
 	    TP_STRUCT__entry(
 			     __string(ring, sched_job->base.sched->name)
 			     __field(struct dma_fence *, fence)
-			     __field(uint64_t, ctx)
-			     __field(unsigned, seqno)
+			     __field(u64, ctx)
+			     __field(u64, seqno)
 			     ),
 
 	    TP_fast_assign(
@@ -526,10 +526,8 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
 			   __entry->ctx = fence->context;
 			   __entry->seqno = fence->seqno;
 			   ),
-	    TP_printk("job ring=%s need pipe sync to fence=%p, context=%llu, seq=%u",
-		      __get_str(ring),
-		      __entry->fence, __entry->ctx,
-		      __entry->seqno)
+	    TP_printk("job ring=%s need pipe sync to fence=%llu:%llu",
+		      __get_str(ring), __entry->ctx, __entry->seqno)
 );
 
 TRACE_EVENT(amdgpu_reset_reg_dumps,
Signature · 1 line
2.43.0
maintainer Reviewed-by on v8 10/10
#17 lore raw

Re: [PATCH v8 10/10] drm/amdgpu: update trace format to match gpu_scheduler_trace

Am 20.03.25 um 10:58 schrieb Pierre-Eric Pelloux-Prayer:

Quoted 3 lines

Log fences using the same format for coherency.

Oh, good catch! It's like a decade or so that we switched to 64bit sequence numbers :)

Quoted 72 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -12
index a4f394d827bc..d302c68c1258 100644
@@ -168,8 +168,8 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 	    TP_ARGS(job),
 	    TP_STRUCT__entry(
 			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
-			     __field(unsigned int, context)
-			     __field(unsigned int, seqno)
+			     __field(u64, context)
+			     __field(u64, seqno)
 			     __field(struct dma_fence *, fence)
 			     __string(ring, to_amdgpu_ring(job->base.sched)->name)
 			     __field(u32, num_ibs)
@@ -182,7 +182,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 			   __assign_str(ring);
 			   __entry->num_ibs = job->num_ibs;
 			   ),
-	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+	    TP_printk("timeline=%s, fence=%llu:%llu, ring_name=%s, num_ibs=%u",
 		      __get_str(timeline), __entry->context,
 		      __entry->seqno, __get_str(ring), __entry->num_ibs)
 );
@@ -192,8 +192,8 @@ TRACE_EVENT(amdgpu_sched_run_job,
 	    TP_ARGS(job),
 	    TP_STRUCT__entry(
 			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
-			     __field(unsigned int, context)
-			     __field(unsigned int, seqno)
+			     __field(u64, context)
+			     __field(u64, seqno)
 			     __string(ring, to_amdgpu_ring(job->base.sched)->name)
 			     __field(u32, num_ibs)
 			     ),
@@ -205,7 +205,7 @@ TRACE_EVENT(amdgpu_sched_run_job,
 			   __assign_str(ring);
 			   __entry->num_ibs = job->num_ibs;
 			   ),
-	    TP_printk("timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
+	    TP_printk("timeline=%s, fence=%llu:%llu, ring_name=%s, num_ibs=%u",
 		      __get_str(timeline), __entry->context,
 		      __entry->seqno, __get_str(ring), __entry->num_ibs)
 );
@@ -516,8 +516,8 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
 	    TP_STRUCT__entry(
 			     __string(ring, sched_job->base.sched->name)
 			     __field(struct dma_fence *, fence)
-			     __field(uint64_t, ctx)
-			     __field(unsigned, seqno)
+			     __field(u64, ctx)
+			     __field(u64, seqno)
 			     ),
 
 	    TP_fast_assign(
@@ -526,10 +526,8 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
 			   __entry->ctx = fence->context;
 			   __entry->seqno = fence->seqno;
 			   ),
-	    TP_printk("job ring=%s need pipe sync to fence=%p, context=%llu, seq=%u",
-		      __get_str(ring),
-		      __entry->fence, __entry->ctx,
-		      __entry->seqno)
+	    TP_printk("job ring=%s need pipe sync to fence=%llu:%llu",
+		      __get_str(ring), __entry->ctx, __entry->seqno)
 );
 
 TRACE_EVENT(amdgpu_reset_reg_dumps,
#18 lore raw
In reply to Pierre-Eric Pelloux-Prayer

Hi,

I've rebased the series on top of drm-next, applied the minor tweaks suggested by Tvrtko on v8 and the R-b tags. The result can be found on gitlab.fdo:

https://gitlab.freedesktop.org/pepp/linux/-/commits/improve_gpu_scheduler_trace_v9

I believe it's ready to be merged, unless I've missed something?

Thanks,
Pierre-Eric

Le 20/03/2025 à 10:57, Pierre-Eric Pelloux-Prayer a écrit :

Quoted 79 lines

Hi,

The initial goal of this series was to improve the drm and amdgpu trace events to be able to expose more of the inner workings of the scheduler and drivers to developers via tools.

Then, the series evolved to become focused only on gpu_scheduler. The changes around vblank events will be part of a different series, as well as the amdgpu ones.

Moreover Sima suggested to make some trace events stable uAPI, so tools can rely on them long term.

The first patches extend and cleanup the gpu scheduler events, then add a documentation entry in drm-uapi.rst.

The last 2 patches are new in v8. One is based on a suggestion from Tvrtko and gets rid of drm_sched_job::id. The other is a cleanup of amdgpu trace events to use the fence=%llu:%llu format.

The drm_sched_job patches don't affect gpuvis which has code to parse the gpu_scheduler events but these events are not enabled.

Changes since v7:
* uint64_t -> u64
* reworked dependencies tracing (Tvrtko)
* use common name prefix for all events (Tvrtko)
* dropped drm_sched_job::id (Tvrtko)

Useful links:
- userspace tool using the updated events:
https://gitlab.freedesktop.org/tomstdenis/umr/-/merge_requests/37
- v7:
https://lists.freedesktop.org/archives/dri-devel/2025-January/488117.html

Pierre-Eric Pelloux-Prayer (10):
drm/debugfs: output client_id in in drm_clients_info drm/sched: store the drm client_id in drm_sched_fence drm/sched: add device name to the drm_sched_process_job event drm/sched: cleanup gpu_scheduler trace events
drm/sched: trace dependencies for gpu jobs
drm/sched: add the drm_client_id to the drm_sched_run/exec_job events drm/sched: cleanup event names
drm/doc: document some tracepoints as uAPI
drm: get rid of drm_sched_job::id
drm/amdgpu: update trace format to match gpu_scheduler_trace

  Documentation/gpu/drm-uapi.rst                |  19 ++++
  drivers/accel/amdxdna/aie2_ctx.c              |   3 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |   2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c        |   3 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       |   8 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.h       |   3 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h     |  32 ++----
  drivers/gpu/drm/drm_debugfs.c                 |  10 +-
  drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c  |   2 +-
  drivers/gpu/drm/imagination/pvr_job.c         |   2 +-
  drivers/gpu/drm/imagination/pvr_queue.c       |   5 +-
  drivers/gpu/drm/imagination/pvr_queue.h       |   2 +-
  drivers/gpu/drm/lima/lima_gem.c               |   2 +-
  drivers/gpu/drm/lima/lima_sched.c             |   6 +-
  drivers/gpu/drm/lima/lima_sched.h             |   3 +-
  drivers/gpu/drm/msm/msm_gem_submit.c          |   8 +-
  drivers/gpu/drm/nouveau/nouveau_sched.c       |   3 +-
  drivers/gpu/drm/panfrost/panfrost_drv.c       |   2 +-
  drivers/gpu/drm/panthor/panthor_drv.c         |   3 +-
  drivers/gpu/drm/panthor/panthor_mmu.c         |   2 +-
  drivers/gpu/drm/panthor/panthor_sched.c       |   5 +-
  drivers/gpu/drm/panthor/panthor_sched.h       |   3 +-
  .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 103 +++++++++++++-----
  drivers/gpu/drm/scheduler/sched_entity.c      |  16 ++-
  drivers/gpu/drm/scheduler/sched_fence.c       |   4 +-
  drivers/gpu/drm/scheduler/sched_internal.h    |   2 +-
  drivers/gpu/drm/scheduler/sched_main.c        |  11 +-
  drivers/gpu/drm/v3d/v3d_submit.c              |   2 +-
  drivers/gpu/drm/xe/xe_sched_job.c             |   3 +-
  include/drm/gpu_scheduler.h                   |  13 ++-
  30 files changed, 186 insertions(+), 96 deletions(-)
#19 lore raw
Quoted 9 lines · Pierre-Eric Pelloux-Prayer

Hi,

I've rebased the series on top of drm-next, applied the minor tweaks suggested by Tvrtko on v8 and
the R-b tags. The result can be found on gitlab.fdo:

https://gitlab.freedesktop.org/pepp/linux/-/commits/improve_gpu_scheduler_trace_v9

I believe it's ready to be merged, unless I've missed something?

Has slipped my radar for a while, sorry.

I browsed over the series

Can you pro forma send the v9 (with the scheduler maintainers also in the cover letter's CC) with the changelog, please?

Then I'd ACK and someone (probably me?) can take it in.

Thanks
P.

Quoted 87 lines

Thanks,
Pierre-Eric

Le 20/03/2025 à 10:57, Pierre-Eric Pelloux-Prayer a écrit :

Quoted 82 lines

Hi,

The initial goal of this series was to improve the drm and amdgpu trace events to be able to expose more of the inner workings of the scheduler and drivers to developers via tools.

Then, the series evolved to become focused only on gpu_scheduler. The changes around vblank events will be part of a different series, as well as the amdgpu ones.

Moreover Sima suggested to make some trace events stable uAPI, so tools can rely on them long term.

The first patches extend and cleanup the gpu scheduler events, then add a documentation entry in drm-uapi.rst.

The last 2 patches are new in v8. One is based on a suggestion from Tvrtko and gets rid of drm_sched_job::id. The other is a cleanup of amdgpu trace events to use the fence=%llu:%llu format.

The drm_sched_job patches don't affect gpuvis which has code to parse
the gpu_scheduler events but these events are not enabled.

Changes since v7:
* uint64_t -> u64
* reworked dependencies tracing (Tvrtko)
* use common name prefix for all events (Tvrtko)
* dropped drm_sched_job::id (Tvrtko)

Useful links:
- userspace tool using the updated events:
https://gitlab.freedesktop.org/tomstdenis/umr/-/merge_requests/37
- v7:
https://lists.freedesktop.org/archives/dri-devel/2025-January/488117.html

Pierre-Eric Pelloux-Prayer (10):
   drm/debugfs: output client_id in in drm_clients_info drm/sched: store the drm client_id in drm_sched_fence drm/sched: add device name to the drm_sched_process_job event drm/sched: cleanup gpu_scheduler trace events drm/sched: trace dependencies for gpu jobs drm/sched: add the drm_client_id to the drm_sched_run/exec_job events
   drm/sched: cleanup event names
   drm/doc: document some tracepoints as uAPI
   drm: get rid of drm_sched_job::id
   drm/amdgpu: update trace format to match gpu_scheduler_trace

  Documentation/gpu/drm-uapi.rst                |  19 ++++ drivers/accel/amdxdna/aie2_ctx.c              |   3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |   2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c        |   3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       |   8 +- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h       |   3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h     |  32 ++---- drivers/gpu/drm/drm_debugfs.c                 |  10 +- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c  |   2 +- drivers/gpu/drm/imagination/pvr_job.c         |   2 +- drivers/gpu/drm/imagination/pvr_queue.c       |   5 +- drivers/gpu/drm/imagination/pvr_queue.h       |   2 +- drivers/gpu/drm/lima/lima_gem.c               |   2 +- drivers/gpu/drm/lima/lima_sched.c             |   6 +- drivers/gpu/drm/lima/lima_sched.h             |   3 +- drivers/gpu/drm/msm/msm_gem_submit.c          |   8 +- drivers/gpu/drm/nouveau/nouveau_sched.c       |   3 +- drivers/gpu/drm/panfrost/panfrost_drv.c       |   2 +- drivers/gpu/drm/panthor/panthor_drv.c         |   3 +- drivers/gpu/drm/panthor/panthor_mmu.c         |   2 +- drivers/gpu/drm/panthor/panthor_sched.c       |   5 +- drivers/gpu/drm/panthor/panthor_sched.h       |   3 +- .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 103
+++++++++++++-----
  drivers/gpu/drm/scheduler/sched_entity.c      |  16 ++- drivers/gpu/drm/scheduler/sched_fence.c       |   4 +- drivers/gpu/drm/scheduler/sched_internal.h    |   2 +- drivers/gpu/drm/scheduler/sched_main.c        |  11 +- drivers/gpu/drm/v3d/v3d_submit.c              |   2 +- drivers/gpu/drm/xe/xe_sched_job.c             |   3 +- include/drm/gpu_scheduler.h                   |  13 ++-

  30 files changed, 186 insertions(+), 96 deletions(-)