Improve gpu_scheduler trace events + UAPI
Subsystems (19)
v9 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 v8:
* swapped patches 8 & 9
* rebased on drm-next
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
- v8:
https://lists.freedesktop.org/archives/dri-devel/2025-March/496781.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: get rid of drm_sched_job::id
drm/doc: document some tracepoints as uAPI
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 | 100 +++++++++++++----- 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 +- .../gpu/drm/scheduler/tests/mock_scheduler.c | 2 +- drivers/gpu/drm/v3d/v3d_submit.c | 2 +- drivers/gpu/drm/xe/xe_sched_job.c | 3 +- include/drm/gpu_scheduler.h | 13 ++- 31 files changed, 184 insertions(+), 97 deletions(-)
Signature · 1 line
2.43.0
PATCH v9 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
@@ -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
PATCH v9 2/10 drm/sched: store the drm client_id in drm_sched_fence
In reply to Pierre-Eric Pelloux-PrayerThis 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/scheduler/tests/mock_scheduler.c | 2 +- drivers/gpu/drm/v3d/v3d_submit.c | 2 +- drivers/gpu/drm/xe/xe_sched_job.c | 3 ++- include/drm/gpu_scheduler.h | 10 +++++++++- 26 files changed, 62 insertions(+), 34 deletions(-)
drivers/accel/amdxdna/aie2_ctx.c +2 -1
@@ -848,7 +848,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
@@ -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
@@ -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
@@ -204,7 +204,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 ;
@@ -222,7 +223,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,
@@ -232,7 +234,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
@@ -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
@@ -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
@@ -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
@@ -1073,6 +1073,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
@@ -1082,7 +1083,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 ;
@@ -1099,7 +1100,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
@@ -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
@@ -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
@@ -113,7 +113,8 @@ static inline struct lima_sched_pipe *to_lima_pipe(struct drm_gpu_scheduler *schint 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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/scheduler/tests/mock_scheduler.c +1 -1
@@ -35,7 +35,7 @@ drm_mock_sched_entity_new(struct kunit *test, ret =drm_sched_entity_init (&entity->base, priority, &drm_sched,1 , -NULL ); +NULL ,1 );KUNIT_ASSERT_EQ (test, ret,0 ); entity->test = test;
drivers/gpu/drm/v3d/v3d_submit.c +1 -1
@@ -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
@@ -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
@@ -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);
@@ -629,7 +636,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
Re: [PATCH v9 02/10] drm/sched: store the drm client_id in drm_sched_fence
Quoted 34 lines · Pierre-Eric Pelloux-Prayer
This will be used in a later commit to trace the drm
client_idin some of thegpu_schedulertrace events.This requires changing all the users of
drm_sched_job_initto add an extra parameter.The newly added
drm_client_idfield in thedrm_sched_fenceis 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.Reviewed-by Christian König <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer<[email protected]>
---
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/paac | 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 ++
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_internal.h | 2 +- drivers/gpu/drm/scheduler/sched_main.c | 6 ++++--
drivers/gpu/drm/scheduler/tests/mock_scheduler.c| 2 +- drivers/gpu/drm/v3d/v3d_submit.c | 2 +- drivers/gpu/drm/xe/xe_sched_job.c | 3 ++- include/drm/gpu_scheduler.h | 10 +++++++++-26 files changed, 62 insertions(+), 34 deletions(-)
I think last time I asked about what your merge plan for this is, since it touches so many drivers. Should I take that?
Besides one comment below, scheduler bits look fine.
Quoted 450 lines
drivers/accel/amdxdna/aie2_ctx.c +0
-0@@ -848,7 +848,8 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx,struct amdxdna_sched_job *job, goto up_sem; }drivers/accel/amdxdna/aie2_ctx.c +0
-1- ret = drm_sched_job_init(&job->base, &hwctx->priv->entity,1, hwctx);
drivers/accel/amdxdna/aie2_ctx.c +1
-0+ ret = drm_sched_job_init(&job->base, &hwctx->priv->entity,1, hwctx,
drivers/accel/amdxdna/aie2_ctx.c +1
-0+ hwctx->client->filp->client_id);if (ret) {
XDNA_ERR(xdna, "DRM job init failed, ret %d", ret); gotofree_chain;drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0
-0@@ -639,7 +639,7 @@ int amdgpu_amdkfd_submit_ib(struct amdgpu_device *adev, goto err; }drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1
-1- 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 +0
-0@@ -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,drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-1- num_ibs[i], &p->jobs[i]); + num_ibs[i], &p->jobs[i], + p->filp->client_id);if (ret)
gotofree_all_kdata; p->jobs[i]->enforce_isolation = p->adev-Quoted 1 line
enforce_isolation[fpriv->xcp_id];
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -204,7 +204,8 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
int amdgpu_job_alloc(structamdgpu_device*adev, structamdgpu_vm*vm,
structdrm_sched_entity*entity, void *owner,drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-1- 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;drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -222,7 +223,8 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm, if (!entity) return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-1-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(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -232,7 +234,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, { int r;drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-1- 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 +0
-0@@ -90,7 +90,8 @@ static inline struct amdgpu_ring *amdgpu_job_ring(struct amdgpu_job *job)
int amdgpu_job_alloc(structamdgpu_device*adev, structamdgpu_vm*vm,
structdrm_sched_entity*entity, void *owner,drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +2
-1- 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, structdrm_sched_entity*entity, void *owner,
size_tsize, enumamdgpu_ib_pool_typepool_type,drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +0
-0@@ -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],drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +1
-1- 1, submit->ctx); + 1, submit->ctx, file->client_id);if (ret)
gotoerr_submit_put;drivers/gpu/drm/imagination/pvr_job.c +0
-0@@ -446,7 +446,7 @@ create_job(struct pvr_device *pvr_dev, if (err) goto err_put_job;drivers/gpu/drm/imagination/pvr_job.c +1
-1- err =pvr_queue_job_init (job); + err =pvr_queue_job_init (job, pvr_file->file->client_id);if (err)
gotoerr_put_job;drivers/gpu/drm/imagination/pvr_queue.c +0
-0@@ -1073,6 +1073,7 @@ static int pvr_queue_cleanup_fw_context(struct pvr_queue *queue) /*** pvr_queue_job_init() - Initialize queue related fields in a
pvr_jobobject.
* @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 guaranteepvr_queue_job_arm()
* andpvr_queue_job_push()can't fail. We also make sure the context type isdrivers/gpu/drm/imagination/pvr_queue.c +1
-1@@ -1082,7 +1083,7 @@ static int pvr_queue_cleanup_fw_context(structpvr_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 thegeometry job fence. */
u32min_native_dep_count=job->type==DRM_PVR_JOB_TYPE_FRAGMENT? 1 : 0;drivers/gpu/drm/imagination/pvr_queue.c +0
-0@@ -1099,7 +1100,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;drivers/gpu/drm/imagination/pvr_queue.c +0
-1- err = drm_sched_job_init(&job->base, &queue->entity, 1,
THIS_MODULE);drivers/gpu/drm/imagination/pvr_queue.c +1
-0+ 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 +0
-0@@ -143,7 +143,7 @@ struct pvr_queue {
boolpvr_queue_fence_is_ufo_backed(struct dma_fence *f);drivers/gpu/drm/imagination/pvr_queue.h +1
-1-int pvr_queue_job_init (struct pvr_job *job); +int pvr_queue_job_init (struct pvr_job *job,u64 drm_client_id);
voidpvr_queue_job_cleanup(struct pvr_job *job);drivers/gpu/drm/lima/lima_gem.c +0
-0@@ -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,drivers/gpu/drm/lima/lima_gem.c +1
-1- bos, submit->nr_bos, vm); + bos, submit->nr_bos, vm, file->client_id);if (err)
gotoerr_out1;drivers/gpu/drm/lima/lima_sched.c +2
-1@@ -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;drivers/gpu/drm/lima/lima_sched.c +0
-0@@ -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);drivers/gpu/drm/lima/lima_sched.c +0
-1- err = drm_sched_job_init(&task->base, &context->base, 1,vm);
drivers/gpu/drm/lima/lima_sched.c +2
-0+ 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@@ -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(structlima_sched_pipe*pipe,drivers/gpu/drm/msm/msm_gem_submit.c +1
-1@@ -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(structdrm_device *dev, return ERR_PTR(ret); }drivers/gpu/drm/msm/msm_gem_submit.c +0
-1- ret = drm_sched_job_init(&submit->base, queue->entity, 1,queue);
drivers/gpu/drm/msm/msm_gem_submit.c +1
-0+ ret = drm_sched_job_init(&submit->base, queue->entity, 1,queue,
drivers/gpu/drm/msm/msm_gem_submit.c +1
-0+ drm_client_id);if (ret) {
kfree(submit->hw_fence);
kfree(submit);drivers/gpu/drm/msm/msm_gem_submit.c +0
-0@@ -693,7 +694,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, } }drivers/gpu/drm/msm/msm_gem_submit.c +0
-1- submit = submit_create(dev, gpu, queue, args->nr_bos, args-Quoted 1 line
nr_cmds);drivers/gpu/drm/msm/msm_gem_submit.c +1
-0+ submit = submit_create(dev, gpu, queue, args->nr_bos, args-Quoted 1 line
nr_cmds,drivers/gpu/drm/msm/msm_gem_submit.c +1
-0+ file->client_id);if (
IS_ERR(submit)) {
ret =PTR_ERR(submit);
gotoout_post_unlock;drivers/gpu/drm/nouveau/nouveau_sched.c +0
-0@@ -87,7 +87,8 @@ nouveau_job_init(struct nouveau_job *job, }
ret = drm_sched_job_init(&job->base,&sched->entity,drivers/gpu/drm/nouveau/nouveau_sched.c +2
-1- args->credits, NULL); + args->credits,NULL , + job->file_priv->client_id);if (ret)
gotoerr_free_chains;drivers/gpu/drm/panfrost/panfrost_drv.c +0
-0@@ -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],drivers/gpu/drm/panfrost/panfrost_drv.c +1
-1- 1, NULL); + 1, NULL, file->client_id);if (ret)
gotoout_put_job;drivers/gpu/drm/panthor/panthor_drv.c +0
-0@@ -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];
structdrm_sched_job*job;drivers/gpu/drm/panthor/panthor_drv.c +0
-1- job = panthor_job_create(pfile, args->group_handle,qsubmit);
drivers/gpu/drm/panthor/panthor_drv.c +1
-0+ job = panthor_job_create(pfile, args->group_handle,qsubmit,
drivers/gpu/drm/panthor/panthor_drv.c +1
-0+ file->client_id);if (
IS_ERR(job)) {
ret =PTR_ERR(job); gotoout_cleanup_submit_ctx;drivers/gpu/drm/panthor/panthor_mmu.c +0
-0@@ -2516,7 +2516,7 @@ panthor_vm_bind_job_create(struct drm_file *file, kref_init(&job->refcount); job->vm = panthor_vm_get(vm);drivers/gpu/drm/panthor/panthor_mmu.c +1
-1- 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)
gotoerr_put_job;drivers/gpu/drm/panthor/panthor_sched.c +0
-0@@ -3729,7 +3729,8 @@ struct panthor_vm *panthor_job_vm(struct drm_sched_job *sched_job)struct
drm_sched_job*
panthor_job_create(structpanthor_file*pfile,
u16group_handle,drivers/gpu/drm/panthor/panthor_sched.c +2
-1- const struct drm_panthor_queue_submit *qsubmit) + const struct drm_panthor_queue_submit *qsubmit, + u64 drm_client_id){
structpanthor_group_pool*gpool =pfile->groups; structpanthor_job*job;drivers/gpu/drm/panthor/panthor_sched.c +0
-0@@ -3801,7 +3802,7 @@ panthor_job_create(struct panthor_file *pfile,
ret = drm_sched_job_init(&job->base, &job->group->queues[job-Quoted 1 line
queue_idx]->entity,
drivers/gpu/drm/panthor/panthor_sched.c +1
-1- credits, job->group); + credits, job->group,
drm_client_id);
if (ret)
gotoerr_put_job;drivers/gpu/drm/panthor/panthor_sched.h +0
-0@@ -29,7 +29,8 @@ int panthor_group_get_state(struct panthor_file *pfile,struct
drm_sched_job*
panthor_job_create(structpanthor_file*pfile,
u16group_handle,drivers/gpu/drm/panthor/panthor_sched.h +2
-1- 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(structdrm_sched_job*job); structpanthor_vm*panthor_job_vm(structdrm_sched_job*sched_job); voidpanthor_job_put(struct drm_sched_job *job);drivers/gpu/drm/scheduler/sched_fence.c +0
-0@@ -206,7 +206,8 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f) EXPORT_SYMBOL(to_drm_sched_fence);
structdrm_sched_fence*drm_sched_fence_alloc(structdrm_sched_entity*entity,drivers/gpu/drm/scheduler/sched_fence.c +2
-1- void *owner) + void *owner, + u64 drm_client_id){
structdrm_sched_fence*fence = NULL;drivers/gpu/drm/scheduler/sched_fence.c +0
-0@@ -215,6 +216,7 @@ struct drm_sched_fence *drm_sched_fence_alloc(struct drm_sched_entity *entity, return NULL;
fence->owner= owner;drivers/gpu/drm/scheduler/sched_fence.c +1
-0+ fence->drm_client_id = drm_client_id;
spin_lock_init(&fence->lock);
return fence;drivers/gpu/drm/scheduler/sched_internal.h +0
-0@@ -24,7 +24,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity);struct
drm_sched_job*drm_sched_entity_pop_job(structdrm_sched_entity*entity);
structdrm_sched_fence*drm_sched_fence_alloc(structdrm_sched_entity*s_entity,drivers/gpu/drm/scheduler/sched_internal.h +1
-1- void *owner); + void *owner, u64
drm_client_id);
voiddrm_sched_fence_init(struct drm_sched_fence *fence, struct drm_sched_entity *entity); voiddrm_sched_fence_free(struct drm_sched_fence *fence);drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -764,6 +764,7 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs); * @credits: the number of credits this job contributes to the
Quoted 4 lines
schedulers
* credit limit
* @owner: job owner for debugging
+ * @drm_client_id: drm_file.client_id of the owner
For the docu generation to link that properly it must be written as
&struct drm_file.client_id
Besides, if this were an optional parameter, one should document it. I'm not sure if it is, I haven't used these client_id's before.
P.
Quoted 100 lines
*
* Refer todrm_sched_entity_push_job()documentation
* for locking considerations.drivers/gpu/drm/scheduler/sched_main.c +2
-1@@ -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 missingframes
drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -810,7 +812,7 @@ int drm_sched_job_init(struct drm_sched_job *job,
job->entity= entity;
job->credits= credits;drivers/gpu/drm/scheduler/sched_main.c +1
-1- 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/scheduler/tests/mock_scheduler.c +1
-1@@ -35,7 +35,7 @@ drm_mock_sched_entity_new(struct kunit *test, ret = drm_sched_entity_init(&entity->base, priority, &drm_sched, 1, - NULL); + NULL, 1); KUNIT_ASSERT_EQ(test, ret, 0);
entity->test= test;drivers/gpu/drm/v3d/v3d_submit.c +0
-0@@ -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-Quoted 1 line
sched_entity[queue],
drivers/gpu/drm/v3d/v3d_submit.c +1
-1- 1, v3d_priv); + 1, v3d_priv, file_priv->client_id);if (ret)
return ret;drivers/gpu/drm/xe/xe_sched_job.c +0
-0@@ -113,7 +113,8 @@ struct xe_sched_job *xe_sched_job_create(structxe_exec_queue *q, kref_init(&job->refcount); xe_exec_queue_get(job->q);drivers/gpu/drm/xe/xe_sched_job.c +2
-1- 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)
gotoerr_free;include/drm/gpu_scheduler.h +7
-0@@ -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; };
structdrm_sched_fence*to_drm_sched_fence(structdma_fence*f);include/drm/gpu_scheduler.h +0
-0@@ -629,7 +636,8 @@ drm_sched_pick_best(struct drm_gpu_scheduler **sched_list,
int drm_sched_job_init(structdrm_sched_job*job, structdrm_sched_entity*entity,include/drm/gpu_scheduler.h +2
-1- u32 credits, void *owner); + u32 credits, void *owner, + u64 drm_client_id);void
drm_sched_job_arm(struct drm_sched_job *job); voiddrm_sched_entity_push_job(struct drm_sched_job *sched_job); int drm_sched_job_add_dependency(structdrm_sched_job*job,
Re: [PATCH v9 02/10] drm/sched: store the drm client_id in drm_sched_fence
Hi,
Le 14/05/2025 à 14:44, Philipp Stanner a écrit :
Quoted 43 lines · Pierre-Eric Pelloux-Prayer
Quoted 33 lines
This will be used in a later commit to trace the drm
client_idin some of thegpu_schedulertrace events.This requires changing all the users of
drm_sched_job_initto add an extra parameter.The newly added
drm_client_idfield in thedrm_sched_fenceis 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.Reviewed-by Christian König <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer--- 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/paac | 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 ++-Quoted 8 lines
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/scheduler/tests/mock_scheduler.c | 2 +- drivers/gpu/drm/v3d/v3d_submit.c | 2 +- drivers/gpu/drm/xe/xe_sched_job.c | 3 ++- include/drm/gpu_scheduler.h | 10 +++++++++- 26 files changed, 62 insertions(+), 34 deletions(-)
Quoted 2 lines
I think last time I asked about what your merge plan for this is, since it touches so many drivers. Should I take that?
Based on:
https://drm.pages.freedesktop.org/maintainer-tools/committer/committer-drm-misc.html
"drm-misc is for drm core (non-driver) patches, subsystem-wide refactorings, and small trivial patches all over (including drivers)."
I assume it should go through drm-misc.
Quoted 460 lines
Besides one comment below, scheduler bits look fine.
Quoted 450 lines
drivers/accel/amdxdna/aie2_ctx.c +2
-1@@ -848,7 +848,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); gotofree_chain;drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1
-1@@ -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@@ -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-Quoted 1 line
enforce_isolation[fpriv->xcp_id];
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-1@@ -204,7 +204,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;drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-1@@ -222,7 +223,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,drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-1@@ -232,7 +234,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@@ -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_tsize, enumamdgpu_ib_pool_typepool_type,drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +1
-1@@ -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@@ -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 +0
-0@@ -1073,6 +1073,7 @@ static int pvr_queue_cleanup_fw_context(struct pvr_queue *queue) /*** pvr_queue_job_init() - Initialize queue related fields in a
pvr_jobobject.
* @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 guaranteepvr_queue_job_arm()
* andpvr_queue_job_push()can't fail. We also make sure the
context type isdrivers/gpu/drm/imagination/pvr_queue.c +1
-1@@ -1082,7 +1083,7 @@ static int pvr_queue_cleanup_fw_context(structpvr_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 thegeometry job fence. */
u32min_native_dep_count=job->type==DRM_PVR_JOB_TYPE_FRAGMENT? 1 : 0;drivers/gpu/drm/imagination/pvr_queue.c +1
-1@@ -1099,7 +1100,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@@ -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@@ -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@@ -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@@ -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 +3
-2@@ -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(structdrm_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);drivers/gpu/drm/msm/msm_gem_submit.c +2
-1@@ -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);
gotoout_post_unlock;drivers/gpu/drm/nouveau/nouveau_sched.c +2
-1@@ -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@@ -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 +1
-1@@ -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,
drivers/gpu/drm/panthor/panthor_drv.c +1
-0+ 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@@ -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 +2
-1@@ -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;drivers/gpu/drm/panthor/panthor_sched.c +1
-1@@ -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@@ -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 +2
-1@@ -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(structdrm_sched_entity *entity, - void *owner) + void *owner, + u64 drm_client_id) {struct
drm_sched_fence*fence = NULL;drivers/gpu/drm/scheduler/sched_fence.c +1
-0@@ -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@@ -24,7 +24,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity); struct drm_sched_job *drm_sched_entity_pop_job(structdrm_sched_entity *entity); struct drm_sched_fence *drm_sched_fence_alloc(structdrm_sched_entity *s_entity, - void *owner); + void *owner, u64
drm_client_id);
voiddrm_sched_fence_init(struct drm_sched_fence *fence, struct drm_sched_entity *entity); voiddrm_sched_fence_free(struct drm_sched_fence *fence);drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -764,6 +764,7 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs); * @credits: the number of credits this job contributes to theQuoted 4 lines
schedulers
* credit limit
* @owner: job owner for debugging
+ * @drm_client_id: drm_file.client_id of the ownerFor the docu generation to link that properly it must be written as
Quoted 1 line
&struct drm_file.client_id
Noted.
Quoted 3 lines
Besides, if this were an optional parameter, one should document it. I'm not sure if it is, I haven't used these client_id's before.
Passing an invalid client_id would only cause the trace events to print the invalid client_id.
Thanks,
Pierre-Eric
Quoted 103 lines
P.
Quoted 100 lines
*
* Refer todrm_sched_entity_push_job()documentation
* for locking considerations.drivers/gpu/drm/scheduler/sched_main.c +2
-1@@ -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 missingframes
drivers/gpu/drm/scheduler/sched_main.c +1
-1@@ -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/scheduler/tests/mock_scheduler.c +1
-1@@ -35,7 +35,7 @@ drm_mock_sched_entity_new(struct kunit *test, ret = drm_sched_entity_init(&entity->base, priority, &drm_sched, 1, - NULL); + NULL, 1); KUNIT_ASSERT_EQ(test, ret, 0); entity->test = test;drivers/gpu/drm/v3d/v3d_submit.c +1
-1@@ -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@@ -113,7 +113,8 @@ struct xe_sched_job *xe_sched_job_create(structxe_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@@ -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);@@ -629,7 +636,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,
Re: [PATCH v9 02/10] drm/sched: store the drm client_id in drm_sched_fence
Le 15/05/2025 à 08:53, Pierre-Eric Pelloux-Prayer a écrit :
Quoted 49 lines
Hi,
Le 14/05/2025 à 14:44, Philipp Stanner a écrit :
Quoted 43 lines · Pierre-Eric Pelloux-Prayer
Quoted 34 lines
This will be used in a later commit to trace the drm
client_idin some of thegpu_schedulertrace events.This requires changing all the users of
drm_sched_job_initto add an extra parameter.The newly added
drm_client_idfield in thedrm_sched_fenceis 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.Reviewed-by Christian König <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer<[email protected]>
---
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/paac | 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 ++Quoted 7 lines
drivers/gpu/drm/scheduler/sched_internal.h | 2 +- drivers/gpu/drm/scheduler/sched_main.c | 6 ++++--
drivers/gpu/drm/scheduler/tests/mock_scheduler.c| 2 +- drivers/gpu/drm/v3d/v3d_submit.c | 2 +- drivers/gpu/drm/xe/xe_sched_job.c | 3 ++- include/drm/gpu_scheduler.h | 10 +++++++++-26 files changed, 62 insertions(+), 34 deletions(-)Quoted 2 lines
I think last time I asked about what your merge plan for this is, since it touches so many drivers. Should I take that?
Quoted 8 lines
Based on:
https://drm.pages.freedesktop.org/maintainer-tools/committer/committer-drm-misc.html
"drm-misc is for drm core (non-driver) patches, subsystem-wide refactorings, and small trivial patches all over (including drivers)."
I assume it should go through drm-misc.
I've addressed your comments and pushed an updated branch to https://gitlab.freedesktop.org/pepp/linux/-/commits/improve_gpu_scheduler_trace_v10
Any chance to get this merged soon?
Thanks,
Pierre-Eric
Quoted 529 lines
Quoted 421 lines
Besides one comment below, scheduler bits look fine.
Quoted 409 lines
drivers/accel/amdxdna/aie2_ctx.c +2
-1@@ -848,7 +848,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); gotofree_chain;drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1
-1@@ -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@@ -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-
Quoted 1 line
enforce_isolation[fpriv->xcp_id];
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -204,7 +204,8 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)int amdgpu_job_alloc(struct
amdgpu_device*adev, structamdgpu_vm*vm,
structdrm_sched_entity*entity, void *owner, - unsigned intnum_ibs, structamdgpu_job**job) + unsigned intnum_ibs, structamdgpu_job**job, + u64drm_client_id)
{
if (num_ibs== 0)
return-EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +3
-2@@ -222,7 +223,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,@@ -232,7 +234,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 +0
-0@@ -90,7 +90,8 @@ static inline struct amdgpu_ring *amdgpu_job_ring(struct amdgpu_job *job)int amdgpu_job_alloc(struct
amdgpu_device*adev, structamdgpu_vm*vm,
structdrm_sched_entity*entity, void *owner, - unsigned intnum_ibs, structamdgpu_job**job); + unsigned intnum_ibs, structamdgpu_job**job, + u64drm_client_id);
int amdgpu_job_alloc_with_ib(structamdgpu_device*adev, structdrm_sched_entity*entity, void *owner,
size_tsize, enumamdgpu_ib_pool_typepool_type,drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +1
-1@@ -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@@ -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 +0
-0@@ -1073,6 +1073,7 @@ static int pvr_queue_cleanup_fw_context(struct pvr_queue *queue) /*** pvr_queue_job_init() - Initialize queue related fields in a
pvr_jobobject.
* @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 guaranteepvr_queue_job_arm()
* andpvr_queue_job_push()can't fail. We also make sure the context type isdrivers/gpu/drm/imagination/pvr_queue.c +1
-1@@ -1082,7 +1083,7 @@ static int pvr_queue_cleanup_fw_context(structpvr_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 thegeometry job fence. */
u32min_native_dep_count=job->type==DRM_PVR_JOB_TYPE_FRAGMENT? 1 : 0;drivers/gpu/drm/imagination/pvr_queue.c +1
-1@@ -1099,7 +1100,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@@ -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 +0
-0@@ -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)
gotoerr_out1;drivers/gpu/drm/lima/lima_sched.c +4
-2@@ -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@@ -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 +3
-2@@ -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(structdrm_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);drivers/gpu/drm/msm/msm_gem_submit.c +2
-1@@ -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);
gotoout_post_unlock;drivers/gpu/drm/nouveau/nouveau_sched.c +2
-1@@ -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@@ -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 +0
-0@@ -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];
structdrm_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);
gotoout_cleanup_submit_ctx;drivers/gpu/drm/panthor/panthor_mmu.c +1
-1@@ -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 +0
-0@@ -3729,7 +3729,8 @@ struct panthor_vm *panthor_job_vm(struct drm_sched_job *sched_job)struct
drm_sched_job*
panthor_job_create(structpanthor_file*pfile, u16group_handle,
- const structdrm_panthor_queue_submit*qsubmit) + const structdrm_panthor_queue_submit*qsubmit, + u64drm_client_id)
{
structpanthor_group_pool*gpool =pfile->groups; structpanthor_job*job;drivers/gpu/drm/panthor/panthor_sched.c +0
-0@@ -3801,7 +3802,7 @@ panthor_job_create(struct panthor_file *pfile, ret = drm_sched_job_init(&job->base,&job->group->queues[job-
Quoted 1 line
queue_idx]->entity,
- credits,
job->group);
+ credits,job->group,drm_client_id);
if (ret)
gotoerr_put_job;drivers/gpu/drm/panthor/panthor_sched.h +0
-0@@ -29,7 +29,8 @@ int panthor_group_get_state(struct panthor_file *pfile,struct
drm_sched_job*
panthor_job_create(structpanthor_file*pfile,
u16group_handle,
- const structdrm_panthor_queue_submit*qsubmit); + const structdrm_panthor_queue_submit*qsubmit, + u64drm_client_id);
structdrm_sched_job*panthor_job_get(structdrm_sched_job*job); structpanthor_vm*panthor_job_vm(structdrm_sched_job*sched_job); voidpanthor_job_put(struct drm_sched_job *job);drivers/gpu/drm/scheduler/sched_fence.c +0
-0@@ -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(structdrm_sched_entity*entity,
- void *owner)
+ void *owner,
+ u64drm_client_id) {
structdrm_sched_fence*fence = NULL;drivers/gpu/drm/scheduler/sched_fence.c +1
-0@@ -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 +0
-0@@ -24,7 +24,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity);struct
drm_sched_job*drm_sched_entity_pop_job(structdrm_sched_entity*entity);
structdrm_sched_fence*drm_sched_fence_alloc(structdrm_sched_entity*s_entity,
- void *owner);
+ void *owner, u64drm_client_id);
voiddrm_sched_fence_init(struct drm_sched_fence *fence, struct drm_sched_entity *entity); voiddrm_sched_fence_free(struct drm_sched_fence *fence);drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -764,6 +764,7 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs); * @credits: the number of credits this job contributes to theQuoted 4 lines
schedulers
* credit limit
* @owner: job owner for debugging
+ * @drm_client_id: drm_file.client_id of the ownerFor the docu generation to link that properly it must be written as
Quoted 1 line
&struct drm_file.client_id
Noted.
Quoted 3 lines
Besides, if this were an optional parameter, one should document it. I'm not sure if it is, I haven't used these client_id's before.
Passing an invalid
client_idwould only cause the trace events to print the invalidclient_id.Thanks,
Pierre-EricQuoted 94 lines
P.
Quoted 91 lines
*
* Refer todrm_sched_entity_push_job()documentation
* for locking considerations.drivers/gpu/drm/scheduler/sched_main.c +2
-1@@ -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 missingframes
drivers/gpu/drm/scheduler/sched_main.c +1
-1@@ -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/scheduler/tests/mock_scheduler.c +1
-1@@ -35,7 +35,7 @@ drm_mock_sched_entity_new(struct kunit *test, ret = drm_sched_entity_init(&entity->base, priority, &drm_sched, 1, - NULL); + NULL, 1); KUNIT_ASSERT_EQ(test, ret, 0); entity->test = test;drivers/gpu/drm/v3d/v3d_submit.c +0
-0@@ -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-
Quoted 1 line
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@@ -113,7 +113,8 @@ struct xe_sched_job *xe_sched_job_create(structxe_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@@ -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);@@ -629,7 +636,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,
Re: [PATCH v9 02/10] drm/sched: store the drm client_id in drm_sched_fence
Quoted 70 lines · Pierre-Eric Pelloux-Prayer
Le 15/05/2025 à 08:53, Pierre-Eric Pelloux-Prayer a écrit :
Quoted 67 lines
Hi,
Le 14/05/2025 à 14:44, Philipp Stanner a écrit :
Quoted 52 lines
Quoted 41 lines · Pierre-Eric Pelloux-Prayer
This will be used in a later commit to trace the drm
client_idin
some of thegpu_schedulertrace events.This requires changing all the users of
drm_sched_job_initto add an extra parameter.The newly added
drm_client_idfield in thedrm_sched_fenceis 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.Reviewed-by Christian König <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer<[email protected]>
---
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/paac | 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 ++Quoted 8 lines
drivers/gpu/drm/scheduler/sched_internal.h | 2 +- drivers/gpu/drm/scheduler/sched_main.c | 6 ++++--
drivers/gpu/drm/scheduler/tests/mock_scheduler.c| 2 +- drivers/gpu/drm/v3d/v3d_submit.c | 2 +- drivers/gpu/drm/xe/xe_sched_job.c | 3 ++- include/drm/gpu_scheduler.h | 10
+++++++++-26 files changed, 62 insertions(+), 34 deletions(-)Quoted 3 lines
I think last time I asked about what your merge plan for this is, since
it touches so many drivers. Should I take that?Based on:
https://drm.pages.freedesktop.org/maintainer-tools/committer/committer-drm-misc.html
"drm-misc is for drm core (non-driver) patches, subsystem-wide refactorings,
and small trivial patches all over (including drivers)."
Quoted 6 lines
Quoted 1 line
I assume it should go through drm-misc.
I've addressed your comments and pushed an updated branch to
https://gitlab.freedesktop.org/pepp/linux/-/commits/improve_gpu_scheduler_trace_v10Any chance to get this merged soon?
I took a look. Looks good!
Be so kind and provide that branch as a v10 so we can conform to the process. Then I can take them, do some basic smoke tests tomorrow and then we're good to go. That should now all be good, you've got the reviews and it has settled.
Thx
P.
Quoted 576 lines
Thanks,
Pierre-EricQuoted 570 lines
Quoted 454 lines
Besides one comment below, scheduler bits look fine.
Quoted 440 lines
drivers/accel/amdxdna/aie2_ctx.c +2
-1@@ -848,7 +848,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); gotofree_chain;drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0
-0@@ -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@@ -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-
Quoted 1 line
enforce_isolation[fpriv->xcp_id];
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -204,7 +204,8 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)int amdgpu_job_alloc(struct
amdgpu_device*adev, structamdgpu_vm
*vm,
structdrm_sched_entity*entity, void *owner, - unsigned intnum_ibs, structamdgpu_job**job) + unsigned intnum_ibs, structamdgpu_job**job, + u64drm_client_id)
{
if (num_ibs== 0)
return-EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-1@@ -222,7 +223,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,drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -232,7 +234,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 +0
-0@@ -90,7 +90,8 @@ static inline struct amdgpu_ring *amdgpu_job_ring(struct amdgpu_job *job)int amdgpu_job_alloc(struct
amdgpu_device*adev, structamdgpu_vm
*vm,
structdrm_sched_entity*entity, void *owner, - unsigned intnum_ibs, structamdgpu_job**job); + unsigned intnum_ibs, structamdgpu_job**job, + u64drm_client_id);
int amdgpu_job_alloc_with_ib(structamdgpu_device*adev, structdrm_sched_entity*entity, void *owner,
size_tsize, enumamdgpu_ib_pool_typepool_type,drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +0
-0@@ -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)
gotoerr_submit_put;drivers/gpu/drm/imagination/pvr_job.c +1
-1@@ -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 +0
-0@@ -1073,6 +1073,7 @@ static intpvr_queue_cleanup_fw_context(struct
pvr_queue*queue)
/**
*pvr_queue_job_init()- Initialize queue related fields in apvr_jobobject.
* @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 guaranteepvr_queue_job_arm()
* andpvr_queue_job_push()can't fail. We also make sure the context type isdrivers/gpu/drm/imagination/pvr_queue.c +0
-0@@ -1082,7 +1083,7 @@ static intpvr_queue_cleanup_fw_context(struct
pvr_queue*queue)
* * 0 on success, or
* * An error code if something failed.
*/drivers/gpu/drm/imagination/pvr_queue.c +1
-1-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. */
u32min_native_dep_count=job->type==DRM_PVR_JOB_TYPE_FRAGMENT? 1 : 0;drivers/gpu/drm/imagination/pvr_queue.c +1
-1@@ -1099,7 +1100,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@@ -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 +0
-0@@ -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)
gotoerr_out1;drivers/gpu/drm/lima/lima_sched.c +2
-1@@ -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@@ -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 +0
-0@@ -30,7 +30,7 @@static struct
msm_gem_submit*submit_create(structdrm_device*dev,
structmsm_gpu*gpu,
structmsm_gpu_submitqueue*queue,uint32_tnr_bos, -uint32_tnr_cmds)
+uint32_tnr_cmds, u64drm_client_id)
{
staticatomic_tident =ATOMIC_INIT(0);
structmsm_gem_submit*submit;drivers/gpu/drm/msm/msm_gem_submit.c +2
-1@@ -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);drivers/gpu/drm/msm/msm_gem_submit.c +0
-1@@ -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-
Quoted 1 line
nr_cmds);+ submit = submit_create(dev, gpu, queue,
args->nr_bos, args-Quoted 1 line
nr_cmds,+
file->client_id);
if (IS_ERR(submit)) {
ret =PTR_ERR(submit);
gotoout_post_unlock;drivers/gpu/drm/nouveau/nouveau_sched.c +2
-1@@ -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@@ -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 +0
-0@@ -989,7 +989,8 @@ static intpanthor_ioctl_group_submit(struct
drm_device*ddev, void *data,
const structdrm_panthor_queue_submit*qsubmit = &jobs_args[i];
structdrm_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);
gotoout_cleanup_submit_ctx;drivers/gpu/drm/panthor/panthor_mmu.c +0
-0@@ -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)
gotoerr_put_job;drivers/gpu/drm/panthor/panthor_sched.c +0
-0@@ -3729,7 +3729,8 @@ struct panthor_vm *panthor_job_vm(struct drm_sched_job *sched_job)struct
drm_sched_job*
panthor_job_create(structpanthor_file*pfile, u16group_handle,
- const structdrm_panthor_queue_submit*qsubmit) + const structdrm_panthor_queue_submit*qsubmit, + u64drm_client_id)
{
structpanthor_group_pool*gpool =pfile->groups; structpanthor_job*job;drivers/gpu/drm/panthor/panthor_sched.c +0
-0@@ -3801,7 +3802,7 @@ panthor_job_create(struct panthor_file *pfile, ret = drm_sched_job_init(&job->base,&job->group->queues[job-
Quoted 1 line
queue_idx]->entity,
- credits,
job->group);
+ credits,job->group,drm_client_id);
if (ret)
gotoerr_put_job;drivers/gpu/drm/panthor/panthor_sched.h +0
-0@@ -29,7 +29,8 @@ int panthor_group_get_state(struct
panthor_file
*pfile,
structdrm_sched_job*
panthor_job_create(structpanthor_file*pfile, u16group_handle,
- const structdrm_panthor_queue_submit*qsubmit); + const structdrm_panthor_queue_submit*qsubmit, + u64drm_client_id);
structdrm_sched_job*panthor_job_get(structdrm_sched_job*job);
structpanthor_vm*panthor_job_vm(structdrm_sched_job*sched_job);
voidpanthor_job_put(struct drm_sched_job *job);drivers/gpu/drm/scheduler/sched_fence.c +0
-0@@ -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(structdrm_sched_entity*entity,
- void *owner)
+ void *owner,
+ u64drm_client_id) {
structdrm_sched_fence*fence = NULL;drivers/gpu/drm/scheduler/sched_fence.c +1
-0@@ -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 +0
-0@@ -24,7 +24,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity);struct
drm_sched_job*drm_sched_entity_pop_job(structdrm_sched_entity*entity);
structdrm_sched_fence*drm_sched_fence_alloc(structdrm_sched_entity*s_entity,
- void *owner);
+ void *owner, u64drm_client_id);
voiddrm_sched_fence_init(struct drm_sched_fence *fence, struct drm_sched_entity *entity); voiddrm_sched_fence_free(struct drm_sched_fence *fence);drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -764,6 +764,7 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs); * @credits: the number of credits this job contributes toQuoted 5 lines
the
schedulers
* credit limit
* @owner: job owner for debugging
+ * @drm_client_id: drm_file.client_id of the ownerFor the docu generation to link that properly it must be written as
Quoted 1 line
&struct drm_file.client_id
Noted.
Quoted 4 lines
Besides, if this were an optional parameter, one should document it.
I'm not sure if it is, I haven't used these client_id's before.Passing an invalid
client_idwould only cause the trace events to print the invalidclient_id.Thanks,
Pierre-EricQuoted 100 lines
P.
Quoted 97 lines
*
* Refer todrm_sched_entity_push_job()documentation
* for locking considerations.drivers/gpu/drm/scheduler/sched_main.c +2
-1@@ -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 missingframes
drivers/gpu/drm/scheduler/sched_main.c +1
-1@@ -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/scheduler/tests/mock_scheduler.c +1
-1@@ -35,7 +35,7 @@ drm_mock_sched_entity_new(struct kunit *test, ret = drm_sched_entity_init(&entity->base, priority, &drm_sched, 1, - NULL); + NULL, 1); KUNIT_ASSERT_EQ(test, ret, 0); entity->test = test;drivers/gpu/drm/v3d/v3d_submit.c +0
-0@@ -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-Quoted 1 line
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@@ -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 +7
-0@@ -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(structdma_fence*f);include/drm/gpu_scheduler.h +0
-0@@ -629,7 +636,8 @@ drm_sched_pick_best(struct
drm_gpu_scheduler
**sched_list,
int drm_sched_job_init(structdrm_sched_job*job, structdrm_sched_entity*entity,
- u32 credits, void *owner);
+ u32 credits, void *owner,
+ u64drm_client_id);
voiddrm_sched_job_arm(struct drm_sched_job *job); voiddrm_sched_entity_push_job(struct drm_sched_job *sched_job);
int drm_sched_job_add_dependency(structdrm_sched_job*job,
PATCH v9 3/10 drm/sched: add device name to the drm_sched_process_job event
In reply to Pierre-Eric Pelloux-PrayerSince 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
@@ -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
Danilo Krummrich
maintainerRe: [PATCH v9 03/10] drm/sched: add device name to the drm_sched_process_job event
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h DECLARE_EVENT_CLASS(drm_sched_job, · line 45
Quoted 9 lines · Pierre-Eric Pelloux-Prayer
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1
-0@@ -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))
Using the sched_job->sched pointer here and in other trace events implies that the trace event must not be called before the sched_job->sched has been set, i.e. in drm_sched_job_arm().
Please document this for the corresponding trace events.
Re: [PATCH v9 03/10] drm/sched: add device name to the drm_sched_process_job event
Le 19/05/2025 à 17:34, Danilo Krummrich a écrit :
Quoted 15 lines · Pierre-Eric Pelloux-Prayer
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h DECLARE_EVENT_CLASS(drm_sched_job, · line 45
Quoted 9 lines
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1
-0@@ -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))Using the
sched_job->schedpointer here and in other trace events implies that the trace event must not be called before thesched_job->schedhas been set, i.e. indrm_sched_job_arm().
Quoted 1 line
Please document this for the corresponding trace events.
This is not a new requirement as sched and s_fence were already used by the trace events.
Still it's a good idea to document this, so I'll update the comment added in the documentation patch.
Thanks,
Pierre-Eric
PATCH v9 4/10 drm/sched: cleanup gpu_scheduler trace events
In reply to Pierre-Eric Pelloux-PrayerA 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 | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +23 -21
@@ -36,28 +36,28 @@ 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 +75,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
PATCH v9 5/10 drm/sched: trace dependencies for gpu jobs
In reply to Pierre-Eric Pelloux-PrayerWe 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 | 23 +++++++++++++++++++ drivers/gpu/drm/scheduler/sched_entity.c | 8 +++++++ 2 files changed, 31 insertions(+)
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +23 -0
@@ -87,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
@@ -587,6 +587,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
Re: [PATCH v9 05/10] drm/sched: trace dependencies for gpu jobs
nit: title: s/gpu/GPU
We also mostly start with an upper case letter after the :, but JFYI, it's not a big deal.
P.
Quoted 82 lines · Pierre-Eric Pelloux-Prayer
We can't trace dependencies from
drm_sched_job_add_dependencybecause when it's called the job's fence is not available yet.So instead each dependency is traced individually when
drm_sched_entity_push_jobis 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).Signed-off-by: Pierre-Eric Pelloux-Prayer
<[email protected]>Reviewed-by Tvrtko Ursulin <[email protected]>---
.../gpu/drm/scheduler/gpu_scheduler_trace.h | 23
+++++++++++++++++++
drivers/gpu/drm/scheduler/sched_entity.c | 8 +++++++2 files changed, 31 insertions(+)drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-0@@ -87,6 +87,29 @@ TRACE_EVENT(drm_sched_process_job, __entry->fence_context, __entry->fence_seqno) );drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +2
-0+TRACE_EVENT(drm_sched_job_add_dep, + TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence*fence),
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +11
-0+ 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-Quoted 1 line
finished.context;
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1
-0+ __entry->fence_seqno = sched_job->s_fence-Quoted 1 line
finished.seqno;
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +5
-0+ __entry->id = sched_job->id; + __entry->ctx = fence->context; + __entry->seqno = fence->seqno; + ), + TP_printk("fence=%llu:%llu, id=%llu depends onfence=%llu:%llu",
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1
-0+ __entry->fence_context, __entry->fence_seqno,
__entry->id,drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +3
-0+ __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 +0
-0@@ -587,6 +587,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 +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);
drivers/gpu/drm/scheduler/sched_entity.c +1
-0+ }
atomic_inc(entity->rq->sched->score);WRITE_ONCE(entity->last_user, current->group_leader);
PATCH v9 6/10 drm/sched: add the drm_client_id to the drm_sched_run/exec_job events
In reply to Pierre-Eric Pelloux-PrayerFor 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
@@ -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
PATCH v9 7/10 drm/sched: cleanup event names
In reply to Pierre-Eric Pelloux-PrayerAll 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
@@ -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
@@ -477,10 +477,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 */
@@ -586,7 +586,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
@@ -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);
@@ -1231,7 +1231,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);/* * The run_job() callback must by definition return a fence whose * refcount has been incremented for the scheduler already.
Signature · 1 line
2.43.0
PATCH v9 8/10 drm: get rid of drm_sched_job::id
In reply to Pierre-Eric Pelloux-PrayerIts 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
@@ -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) );
@@ -551,7 +547,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)
@@ -559,13 +554,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
@@ -36,7 +36,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)
@@ -47,7 +46,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(
@@ -57,8 +55,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) );
@@ -95,7 +93,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) ),
@@ -103,12 +100,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) );
@@ -118,7 +114,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) ),
@@ -126,12 +121,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
@@ -852,7 +852,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
@@ -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
Re: [PATCH v9 08/10] drm: get rid of drm_sched_job::id
Quoted 207 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.Suggested-by Tvrtko Ursulin <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>Reviewed-by Christian König <[email protected]>--- 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@@ -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) );@@ -551,7 +547,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)@@ -559,13 +554,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@@ -36,7 +36,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)@@ -47,7 +46,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(@@ -57,8 +55,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) );@@ -95,7 +93,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) ),@@ -103,12 +100,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) );@@ -118,7 +114,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) ),@@ -126,12 +121,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@@ -852,7 +852,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@@ -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: *
Re: [PATCH v9 08/10] drm: get rid of drm_sched_job::id
In reply to Pierre-Eric Pelloux-PrayerQuoted 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.
nit: in the title you use double colon :: as a namespace separator. In the kernel docu style only . (as here above) or -> are used.
Commit title should be consistent with that.
Other than that, nice clean up.
P.
Quoted 247 lines
Suggested-by Tvrtko Ursulin <[email protected]>Signed-off-by Pierre-Eric Pelloux-PrayerReviewed-by Christian König <[email protected]>---
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 +0
-0@@ -167,7 +167,6 @@ TRACE_EVENT(amdgpu_cs_ioctl, TP_PROTO(struct amdgpu_job *job), TP_ARGS(job),TP_STRUCT__entry(
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- __field(uint64_t, sched_job_id)
__string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))__field(unsigned int, context)__field(unsigned int, seqno)drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-0@@ -177,15 +176,14 @@ TRACE_EVENT(amdgpu_cs_ioctl, ),
TP_fast_assign(drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- __entry->sched_job_id = job->base.id;
__assign_str(timeline);__entry->context= job->base.s_fence-Quoted 1 line
finished.context;
__entry->seqno= job->base.s_fence-Quoted 1 line
finished.seqno;
__assign_str(ring);__entry->num_ibs=job->num_ibs; ),drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- TP_printk("sched_job=%llu, timeline=%s, context=%u,seqno=%u, ring_name=%s, num_ibs=%u",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- __entry->sched_job_id, __get_str(timeline),
__entry->context,drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1
-0+ TP_printk("timeline=%s, context=%u, seqno=%u,ring_name=%s, num_ibs=%u",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1
-0+ __get_str(timeline), __entry->context,
__entry->seqno,__get_str(ring), __entry-Quoted 1 line
num_ibs));
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-0@@ -193,7 +191,6 @@ TRACE_EVENT(amdgpu_sched_run_job, TP_PROTO(struct amdgpu_job *job), TP_ARGS(job),TP_STRUCT__entry(
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- __field(uint64_t, sched_job_id)
__string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))__field(unsigned int, context)__field(unsigned int, seqno)drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-0@@ -202,15 +199,14 @@ TRACE_EVENT(amdgpu_sched_run_job, ),
TP_fast_assign(drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- __entry->sched_job_id = job->base.id;
__assign_str(timeline);__entry->context= job->base.s_fence-Quoted 1 line
finished.context;
__entry->seqno= job->base.s_fence-Quoted 1 line
finished.seqno;
__assign_str(ring);__entry->num_ibs=job->num_ibs; ),drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- TP_printk("sched_job=%llu, timeline=%s, context=%u,seqno=%u, ring_name=%s, num_ibs=%u",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- __entry->sched_job_id, __get_str(timeline),
__entry->context,drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1
-0+ TP_printk("timeline=%s, context=%u, seqno=%u,ring_name=%s, num_ibs=%u",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1
-0+ __get_str(timeline), __entry->context,
__entry->seqno,__get_str(ring), __entry-Quoted 1 line
num_ibs));
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-0@@ -551,7 +547,6 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, TP_ARGS(sched_job, fence),TP_STRUCT__entry(
__string(ring, sched_job->base.sched-Quoted 1 line
name)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- __field(uint64_t, id)
__field(struct dma_fence *, fence)__field(uint64_t, ctx)__field(unsigned, seqno)drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-0@@ -559,13 +554,12 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
TP_fast_assign(
__assign_str(ring);drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- __entry->id = sched_job->base.id;
__entry->fence= fence;__entry->ctx=fence->context;__entry->seqno=fence->seqno; ),drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0
-1- TP_printk("job ring=%s, id=%llu, need pipe sync tofence=%p, context=%llu, seq=%u",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1
-1- __get_str(ring), __entry->id, + TP_printk("job ring=%s need pipe sync to fence=%p,context=%llu, seq=%u",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1
-0+ __get_str(ring),
__entry->fence,__entry->ctx,__entry->seqno)
);drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-0@@ -36,7 +36,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(drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-1- __field(uint64_t, id)
__string(name, sched_job->sched->name)__field(u32, job_count)__field(int, hw_job_count)drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-0@@ -47,7 +46,6 @@ DECLARE_EVENT_CLASS(drm_sched_job, ),
TP_fast_assign(drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-1- __entry->id = sched_job->id;
__assign_str(name);__entry->job_count=spsc_queue_count(&entity->job_queue);__entry->hw_job_count= atomic_read(drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-0@@ -57,8 +55,8 @@ DECLARE_EVENT_CLASS(drm_sched_job,
__entry->fence_seqno= sched_job-Quoted 1 line
s_fence->finished.seqno;
__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, client_id:%llu",
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1
-1- __get_str(dev), __entry->id, + TP_printk("dev=%s, fence=%llu:%llu, ring=%s, jobcount:%u, hw job count:%d, client_id:%llu",
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1
-0+ __get_str(dev),
__entry->fence_context,__entry->fence_seqno,__get_str(name),
__entry->job_count,__entry->hw_job_count,__entry->client_id)
);drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-0@@ -95,7 +93,6 @@ TRACE_EVENT(drm_sched_job_add_dep,TP_STRUCT__entry(
__field(u64, fence_context)
__field(u64, fence_seqno)drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-1- __field(u64, id)
__field(u64, ctx)
__field(u64, seqno)
),drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-0@@ -103,12 +100,11 @@ TRACE_EVENT(drm_sched_job_add_dep,TP_fast_assign(
__entry->fence_context= sched_job->s_fence-Quoted 1 line
finished.context;
__entry->fence_seqno= sched_job->s_fence-Quoted 1 line
finished.seqno;
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-1- __entry->id = sched_job->id;
__entry->ctx=fence->context;__entry->seqno=fence->seqno; ),drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-1- TP_printk("fence=%llu:%llu, id=%llu depends onfence=%llu:%llu",
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-1- __entry->fence_context, __entry->fence_seqno,
__entry->id,drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +2
-0+ TP_printk("fence=%llu:%llu depends on fence=%llu:%llu", + __entry->fence_context, __entry->fence_seqno,
__entry->ctx,__entry->seqno)
);drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-0@@ -118,7 +114,6 @@ TRACE_EVENT(drm_sched_job_unschedulable,TP_STRUCT__entry(
__field(u64, fence_context)__field(u64, fence_seqno)drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-1- __field(uint64_t, id)
__field(u64, ctx)
__field(u64, seqno)
),drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-0@@ -126,12 +121,11 @@ TRACE_EVENT(drm_sched_job_unschedulable,TP_fast_assign(
__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 +0
-1- __entry->id = sched_job->id;
__entry->ctx=fence->context;__entry->seqno=fence->seqno; ),drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-1- TP_printk("fence=%llu:%llu, id=%llu depends onunsignalled fence=%llu:%llu",
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-1- __entry->fence_context, __entry->fence_seqno,
__entry->id,drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1
-0+ TP_printk("fence=%llu:%llu depends on unsignalledfence=%llu:%llu",
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +1
-0+ __entry->fence_context, __entry->fence_seqno,
__entry->ctx,__entry->seqno) );drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -852,7 +852,6 @@ void drm_sched_job_arm(struct drm_sched_job *job)
job->sched= sched;
job->s_priority=entity->priority;drivers/gpu/drm/scheduler/sched_main.c +0
-1- job->id =atomic64_inc_return (&sched->job_id_count);
drm_sched_fence_init(job->s_fence, job->entity); }include/drm/gpu_scheduler.h +0
-0@@ -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 thescheduler
* @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.include/drm/gpu_scheduler.h +0
-2@@ -339,8 +338,6 @@ struct drm_sched_fence *to_drm_sched_fence(structdma_fence *f); * to schedule the job. */ struct drm_sched_job { - u64 id; - /*** @submit_ts: *
PATCH v9 9/10 drm/doc: document some tracepoints as uAPI
In reply to Pierre-Eric Pelloux-PrayerThis 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 | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+)
Documentation/gpu/drm-uapi.rst +19 -0
@@ -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
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h +19 -0
@@ -32,6 +32,25 @@#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: +* +* * ``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
Re: [PATCH v9 09/10] drm/doc: document some tracepoints as uAPI
Quoted 74 lines · Pierre-Eric Pelloux-Prayer
This commit adds a document section in
drm-uapi.rstabout tracepoints,
and mark the eventsgpu_scheduler_trace.has stable uAPI.The goal is to explicitly state that tools can rely on the fields, formats and semantics of these events.
Acked-by Lucas Stach <[email protected]>Acked-by Maíra Canal <[email protected]>Reviewed-by Christian König <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer<[email protected]>
---
Documentation/gpu/drm-uapi.rst | 19
+++++++++++++++++++
.../gpu/drm/scheduler/gpu_scheduler_trace.h | 19
+++++++++++++++++++2 files changed, 38 insertions(+)Documentation/gpu/drm- renamed from Documentation/gpu/drm-uapi.rst +0
-0
uapi.rst
index69f72e71a96e..4863a4deb0ee100644Documentation/gpu/drm-uapi.rst +0
-0@@ -693,3 +693,22 @@ dma-buf interoperability
Please seeDocumentation/userspace-api/dma-buf-alloc-exchange.rstfor
information on how dma-buf is integrated and exposed within DRM.Documentation/gpu/drm-uapi.rst +8
-0+ + +Trace events +============ + +See Documentation/trace/tracepoints.rst for information about using +Linux Kernel Tracepoints. +In the DRM subsystem, some events are considered stable uAPI toavoid
+breaking tools (e.g.: GPUVis, umr) relying on them. Stable means that fields
+cannot be removed, nor their formatting updated. Adding new fields isDocumentation/gpu/drm-uapi.rst +9
-0+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 eventsdrivers/gpu/drm/scheduler/gpu_scheduler_trace.h +0
-0@@ -32,6 +32,25 @@ #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:
+ *
+ * * ``dev`` - thedev_name()of the device running the job.
+ *
Quoted 8 lines
+ * * ``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
+ *
+ */
For my understanding, why do you use the double apostrophes here?
Also, the linking for the docu afair here two requires you to write
&struct dma_fence.seqno
If I am not mistaken
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#highlights-and-cross-references
P.
Quoted 5 lines
+
DECLARE_EVENT_CLASS(drm_sched_job,TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
TP_ARGS(sched_job, entity),
Re: [PATCH v9 09/10] drm/doc: document some tracepoints as uAPI
Hi,
Le 14/05/2025 à 14:53, Philipp Stanner a écrit :
Quoted 77 lines · Pierre-Eric Pelloux-Prayer
Quoted 76 lines
This commit adds a document section in
drm-uapi.rstabout tracepoints,
and mark the eventsgpu_scheduler_trace.has stable uAPI.The goal is to explicitly state that tools can rely on the fields, formats and semantics of these events.
Acked-by Lucas Stach <[email protected]>Acked-by Maíra Canal <[email protected]>Reviewed-by Christian König <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer--- Documentation/gpu/drm-uapi.rst | 19 +++++++++++++++++++ .../gpu/drm/scheduler/gpu_scheduler_trace.h | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+)Documentation/gpu/drm- renamed from Documentation/gpu/drm-uapi.rst +0
-0
uapi.rst
index69f72e71a96e..4863a4deb0ee100644Documentation/gpu/drm-uapi.rst +0
-0@@ -693,3 +693,22 @@ dma-buf interoperability Please see Documentation/userspace-api/dma-buf-alloc-exchange.rstfor
information on how dma-buf is integrated and exposed within DRM.Documentation/gpu/drm-uapi.rst +8
-0+ + +Trace events +============ + +See Documentation/trace/tracepoints.rst for information about using +Linux Kernel Tracepoints. +In the DRM subsystem, some events are considered stable uAPI toavoid
+breaking tools (e.g.: GPUVis, umr) relying on them. Stable means that fields
+cannot be removed, nor their formatting updated. Adding new fields isDocumentation/gpu/drm-uapi.rst +9
-0+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 eventsdrivers/gpu/drm/scheduler/gpu_scheduler_trace.h +5
-0@@ -32,6 +32,25 @@ #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:
+ *
+ * * ``dev`` - thedev_name()of the device running the job.
+ *
+ * * ``ring`` - the hardware ring running the job. Together with ``dev`` it
Quoted 8 lines
Quoted 6 lines
+ * 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
+ *
+ */For my understanding, why do you use the double apostrophes here?
To get similar formatting to function arguments and make the output a bit nicer to read.
Quoted 8 lines
Also, the linking for the docu afair here two requires you to write
&struct dma_fence.seqno
If I am not mistaken
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#highlights-and-cross-references
Indeed, thanks. I fixed this.
Pierre-Eric
Quoted 9 lines
P.
Quoted 5 lines
+
DECLARE_EVENT_CLASS(drm_sched_job, TP_PROTO(structdrm_sched_job*sched_job, structdrm_sched_entity*entity),
TP_ARGS(sched_job, entity),
PATCH v9 10/10 drm/amdgpu: update trace format to match gpu_scheduler_trace
In reply to Pierre-Eric Pelloux-PrayerLog 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
@@ -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) );
@@ -548,8 +548,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(
@@ -558,10 +558,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
Re: [PATCH v9 10/10] drm/amdgpu: update trace format to match gpu_scheduler_trace
Quoted 76 lines · Pierre-Eric Pelloux-Prayer
Log fences using the same format for coherency.
Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>Reviewed-by Christian König <[email protected]>--- 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@@ -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) );@@ -548,8 +548,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(@@ -558,10 +558,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,
Hi Philipp,
Did you get a chance to take a look at the latest revision of this series?
Thanks,
Pierre-Eric
Le 24/04/2025 à 10:38, Pierre-Eric Pelloux-Prayer a écrit :
Quoted 84 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_jobpatches don't affect gpuvis which has code to parse thegpu_schedulerevents but these events are not enabled.Changes since v8:
* swapped patches 8 & 9
* rebased on drm-nextChanges since v7:
*uint64_t-> u64
* reworked dependencies tracing (Tvrtko)
* use common name prefix for all events (Tvrtko)
* droppeddrm_sched_job::id(Tvrtko)Useful links:
- userspace tool using the updated events:
https://gitlab.freedesktop.org/tomstdenis/umr/-/merge_requests/37
- v8:
https://lists.freedesktop.org/archives/dri-devel/2025-March/496781.htmlPierre-Eric Pelloux-Prayer (10):
drm/debugfs: outputclient_idin indrm_clients_infodrm/sched: store the drmclient_idindrm_sched_fencedrm/sched: add device name to thedrm_sched_process_jobevent drm/sched: cleanupgpu_schedulertrace events
drm/sched: trace dependencies for gpu jobs
drm/sched: add thedrm_client_idto the drm_sched_run/exec_job events drm/sched: cleanup event names
drm: get rid ofdrm_sched_job::id
drm/doc: document some tracepoints as uAPI
drm/amdgpu: update trace format to matchgpu_scheduler_traceDocumentation/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 | 100 +++++++++++++----- 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 +- .../gpu/drm/scheduler/tests/mock_scheduler.c | 2 +- drivers/gpu/drm/v3d/v3d_submit.c | 2 +- drivers/gpu/drm/xe/xe_sched_job.c | 3 +- include/drm/gpu_scheduler.h | 13 ++- 31 files changed, 184 insertions(+), 97 deletions(-)