drm/scheduler: Change scheduled fence track
Subsystems (4)
PATCH 1/2 drm/scheduler: Change scheduled fence track
Update the timestamp of scheduled fence on HW
completion of the previous fences
This allow more accurate tracking of the fence
execution in HW
--- drivers/gpu/drm/scheduler/sched_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +9 -2
@@ -515,7 +515,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)EXPORT_SYMBOL (drm_sched_resubmit_jobs);/** -* drm_sched_resubmit_jobs_ext - helper to relunch certain number of jobs from mirror ring list +* drm_sched_resubmit_jobs_ext - helper to relunch certain number of jobs from pending list * * @sched: scheduler instance * @max: job numbers to relaunch
@@ -671,7 +671,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)static struct drm_sched_job *drm_sched_get_cleanup_job (struct drm_gpu_scheduler *sched) { -struct drm_sched_job *job; +struct drm_sched_job *job, *next;/* * Don't destroy jobs while the timeout worker is running OR thread
@@ -690,6 +690,13 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)if (job &&dma_fence_is_signaled (&job->s_fence->finished)) {/* remove job from pending_list */ list_del_init (&job->list); +/* account for the next fence in the queue */ + next =list_first_entry_or_null (&sched->pending_list, + struct drm_sched_job, list); +if (next) { + next->s_fence->scheduled.timestamp = + job->s_fence->finished.timestamp; + } }else { job =NULL ;/* queue timeout for next job */
Signature · 6 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amdgpu: Add show_fdinfo() interface
Tracking devices, process info and fence info using /proc/pid/fdinfo
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 61 ++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 95 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h | 43 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 24 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 + 10 files changed, 239 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h
drivers/gpu/drm/amd/amdgpu/Makefile +2 -0
@@ -58,6 +58,8 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \ amdgpu_fw_attestation.o amdgpu_securedisplay.o +amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o + amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o # add asic specific block
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -107,6 +107,7 @@#include "amdgpu_gfxhub.h" #include "amdgpu_df.h" #include "amdgpu_smuio.h" +#include "amdgpu_fdinfo.h" #define MAX_GPU_INSTANCE 16
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +61 -0
64 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +4 -1
@@ -87,5 +87,8 @@ void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr);void amdgpu_ctx_mgr_entity_fini (struct amdgpu_ctx_mgr *mgr);long amdgpu_ctx_mgr_entity_flush (struct amdgpu_ctx_mgr *mgr,long timeout);void amdgpu_ctx_mgr_fini (struct amdgpu_ctx_mgr *mgr); - +ktime_t amdgpu_ctx_mgr_fence_usage (struct amdgpu_ctx_mgr *mgr,uint32_t hwip, +uint32_t idx,uint64_t *elapsed); +void amdgpu_ctx_fence_time (struct amdgpu_ctx *ctx,struct amdgpu_ctx_entity *centity, +ktime_t *total,ktime_t *max);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -1
@@ -42,7 +42,7 @@#include "amdgpu_irq.h" #include "amdgpu_dma_buf.h" #include "amdgpu_sched.h" - +#include "amdgpu_fdinfo.h" #include "amdgpu_amdkfd.h" #include "amdgpu_ras.h"
@@ -1691,6 +1691,9 @@ static const struct file_operations amdgpu_driver_kms_fops = {#ifdef CONFIG_COMPAT .compat_ioctl = amdgpu_kms_compat_ioctl,#endif +#ifdef CONFIG_PROC_FS + .show_fdinfo = amdgpu_show_fdinfo +#endif };int amdgpu_file_to_fpriv (struct file *filp,struct amdgpu_fpriv **fpriv)
drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c new file +95 -0
95 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h new file +43 -0
43 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -0
@@ -41,6 +41,7 @@#include "amdgpu_gem.h" #include "amdgpu_display.h" #include "amdgpu_ras.h" +#include "amdgpu_fdinfo.h" void amdgpu_unregister_gpu_instance (struct amdgpu_device *adev) {
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +24 -0
@@ -25,6 +25,7 @@* Alex Deucher * Jerome Glisse */ +#include <linux/dma-fence-array.h> #include <linux/interval_tree_generic.h> #include <linux/idr.h>
@@ -321,6 +322,7 @@ static void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base, base->vm = vm; base->bo = bo; base->next =NULL ; +INIT_LIST_HEAD (&base->bo_head);INIT_LIST_HEAD (&base->vm_status);if (!bo)
@@ -328,6 +330,7 @@ static void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base, base->next = bo->vm_bo; bo->vm_bo = base; +list_add (&base->bo_head, &vm->bo_list);if (bo->tbo.base.resv != vm->root.base.bo->tbo.base.resv)return ;
@@ -2540,6 +2543,7 @@ void amdgpu_vm_bo_rmv(struct amdgpu_device *adev,spin_lock (&vm->invalidated_lock);list_del (&bo_va->base.vm_status); +list_del (&bo_va->base.bo_head);spin_unlock (&vm->invalidated_lock);list_for_each_entry_safe (mapping, next, &bo_va->valids, list) {
@@ -2799,6 +2803,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,spin_lock_init (&vm->invalidated_lock);INIT_LIST_HEAD (&vm->freed);INIT_LIST_HEAD (&vm->done); +INIT_LIST_HEAD (&vm->bo_list);/* create scheduler entities for page table updates */ r = drm_sched_entity_init(&vm->immediate, DRM_SCHED_PRIORITY_NORMAL,
@@ -3266,6 +3271,25 @@ void amdgpu_vm_get_task_info(struct amdgpu_device *adev, u32 pasid,spin_unlock_irqrestore (&adev->vm_manager.pasid_lock, flags); } +void amdgpu_vm_get_memory (struct amdgpu_vm *vm,uint64_t *vram_mem, +uint64_t *gtt_mem) +{ +struct amdgpu_vm_bo_base *base = &vm->root.base; + +list_for_each_entry (base, &vm->bo_list, bo_head){ +struct amdgpu_bo *bo =amdgpu_bo_ref (base->bo); +if (!bo) +continue ; +if (amdgpu_mem_type_to_domain (bo->tbo.mem.mem_type) == +AMDGPU_GEM_DOMAIN_VRAM ) + *vram_mem +=amdgpu_bo_size (bo); +if (amdgpu_mem_type_to_domain (bo->tbo.mem.mem_type) == +AMDGPU_GEM_DOMAIN_GTT ) + *gtt_mem +=amdgpu_bo_size (bo); +amdgpu_bo_unref (&bo); + } + +}/** * amdgpu_vm_set_task_info - Sets VMs task info. *
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +4 -0
@@ -150,6 +150,7 @@ struct amdgpu_vm_bo_base {/* protected by spinlock */ struct list_head vm_status; +struct list_head bo_head;/* protected by the BO being reserved */ bool moved; };
@@ -274,6 +275,7 @@ struct amdgpu_vm {struct list_head invalidated;spinlock_t invalidated_lock; +struct list_head bo_list;/* BO mappings freed, but not yet updated in the PT */ struct list_head freed;
@@ -447,6 +449,8 @@ void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev, struct amdgpu_vm *vm);void amdgpu_vm_del_from_lru_notify (struct ttm_buffer_object *bo); +void amdgpu_vm_get_memory (struct amdgpu_vm *vm,uint64_t *vram_mem, +uint64_t *gtt_mem);#if defined(CONFIG_DEBUG_FS )void amdgpu_debugfs_vm_bo_info (struct amdgpu_vm *vm,struct seq_file *m);#endif
Signature · 6 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 16.04.21 um 07:04 schrieb Roy Sun:
Quoted 8 lines
Update the timestamp of scheduled fence on HW
completion of the previous fencesThis allow more accurate tracking of the fence
execution in HWSigned-off-by David M Nieto <[email protected]>Signed-off-by Roy Sun <[email protected]>
Nirmoy if you are idle again could you give that a testing round? I don't expect it to cause trouble, just want to double check that we haven't forgotten taking a lock or stuff like that.
Thanks,
Christian.
Quoted 30 lines
--- drivers/gpu/drm/scheduler/sched_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/gpu/drm/scheduler/sched_main.c +2
-2@@ -515,7 +515,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)EXPORT_SYMBOL (drm_sched_resubmit_jobs);/** -* drm_sched_resubmit_jobs_ext - helper to relunch certain number of jobs from mirror ring list +* drm_sched_resubmit_jobs_ext - helper to relunch certain number of jobs from pending list * * @sched: scheduler instance * @max: job numbers to relaunch @@ -671,7 +671,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)static struct drm_sched_job *drm_sched_get_cleanup_job (struct drm_gpu_scheduler *sched) { -struct drm_sched_job *job; +struct drm_sched_job *job, *next;/* * Don't destroy jobs while the timeout worker is running OR thread @@ -690,6 +690,13 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)if (job &&dma_fence_is_signaled (&job->s_fence->finished)) {/* remove job from pending_list */ list_del_init (&job->list);
drivers/gpu/drm/scheduler/sched_main.c drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) · line 702
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_main.c +7
-0+/* account for the next fence in the queue */ + next =list_first_entry_or_null (&sched->pending_list, + struct drm_sched_job, list); +if (next) { + next->s_fence->scheduled.timestamp = + job->s_fence->finished.timestamp; + } }else { job =NULL ;/* queue timeout for next job */
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 7 lines · Christian König
Am 16.04.21 um 07:04 schrieb Roy Sun:
Quoted 6 lines
Update the timestamp of scheduled fence on HW
completion of the previous fencesThis allow more accurate tracking of the fence
execution in HW
Quoted 7 lines
Quoted 2 lines
Signed-off-by David M Nieto <[email protected]>Signed-off-by Roy Sun <[email protected]>Nirmoy if you are idle again could you give that a testing round? I don't expect it to cause trouble, just want to double check that we haven't forgotten taking a lock or stuff like that.
Looks good, Tested-by: Nirmoy Das <[email protected]>. One minor typo below:
Quoted 7 lines
Thanks,
Christian.Quoted 4 lines
---
drivers/gpu/drm/scheduler/sched_main.c| 11 +++++++++--1 file changed, 9 insertions(+), 2 deletions(-)
Quoted 12 lines
Quoted 9 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-1@@ -515,7 +515,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched) EXPORT_SYMBOL(drm_sched_resubmit_jobs); /** -* drm_sched_resubmit_jobs_ext - helper to relunch certain number of Quoted 3 lines
jobs from mirror ring list
+ *drm_sched_resubmit_jobs_ext- helper to relunch certain number of jobs from pending list
relunch -> relaunch
Regards,
Nirmoy
Quoted 19 lines
Quoted 19 lines
*
* @sched: scheduler instance
* @max: job numbers to relaunchdrivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -671,7 +671,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)static struct
drm_sched_job*drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched){
- structdrm_sched_job*job;
+ structdrm_sched_job*job, *next;
/*
* Don't destroy jobs while the timeout worker is running OR threaddrivers/gpu/drm/scheduler/sched_main.c +2
-0@@ -690,6 +690,13 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) if (job && dma_fence_is_signaled(&job->s_fence->finished)) { /* remove job from pending_list */ list_del_init(&job->list); + /* account for the next fence in the queue */ + next = list_first_entry_or_null(&sched->pending_list,
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c +5
-0+ struct drm_sched_job, list); + if (next) { + next->s_fence->scheduled.timestamp = + job->s_fence->finished.timestamp; + } } else { job = NULL;/* queue timeout for next job */
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx