Make scheduling of the same index, the same
Subsystems (7)
cover Make scheduling of the same index, the same
The first patch renames priority MIN to LOW.
The second patch makes the "priority" of the same run-queue index in any two schedulers, the same.
This series sits on top on this fix
https://patchwork.freedesktop.org/patch/568723/ which I sent yesterday.
Luben Tuikov (2):
drm/sched: Rename priority MIN to LOW drm/sched: Reverse run-queue priority enumeration
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +- drivers/gpu/drm/scheduler/sched_entity.c | 7 ++++--- drivers/gpu/drm/scheduler/sched_main.c | 15 +++++++-------- include/drm/gpu_scheduler.h | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-)
base-commit: e4d983acffff270ccee417445a69b9ed198658b1
prerequisite-patch-id: d0fec7c91768937b5e22ce9508017e5b9d462000
Signature · 1 line
2.43.0
PATCH 1/2 drm/sched: Rename priority MIN to LOW
Rename DRM_SCHED_PRIORITY_MIN to DRM_SCHED_PRIORITY_LOW.
This mirrors DRM_SCHED_PRIORITY_HIGH, for a list of DRM scheduler priorities in ascending order,
DRM_SCHED_PRIORITY_LOW,
DRM_SCHED_PRIORITY_NORMAL,
DRM_SCHED_PRIORITY_HIGH,
DRM_SCHED_PRIORITY_KERNEL.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +- drivers/gpu/drm/scheduler/sched_entity.c | 2 +- drivers/gpu/drm/scheduler/sched_main.c | 10 +++++----- include/drm/gpu_scheduler.h | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +2 -2
@@ -73,10 +73,10 @@ amdgpu_ctx_to_drm_sched_prio(int32_t ctx_prio)return DRM_SCHED_PRIORITY_NORMAL ;case AMDGPU_CTX_PRIORITY_VERY_LOW : -return DRM_SCHED_PRIORITY_MIN ; +return DRM_SCHED_PRIORITY_LOW ;case AMDGPU_CTX_PRIORITY_LOW : -return DRM_SCHED_PRIORITY_MIN ; +return DRM_SCHED_PRIORITY_LOW ;case AMDGPU_CTX_PRIORITY_NORMAL :return DRM_SCHED_PRIORITY_NORMAL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
@@ -325,7 +325,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched)int i;/* Signal all jobs not yet scheduled */ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_MIN ; i--) { +for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);list_for_each_entry (s_entity, &rq->entities, list) {
drivers/gpu/drm/msm/msm_gpu.h +1 -1
@@ -347,7 +347,7 @@ struct msm_gpu_perfcntr {* DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some * cases, so we don't use it (no need for kernel generated jobs). */ -#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_MIN) +#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_LOW)/** * struct msm_file_private - per-drm_file context
drivers/gpu/drm/scheduler/sched_entity.c +1 -1
@@ -88,7 +88,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,drm_err (sched_list[0 ],"entity with out-of-bounds priority:%u num_rqs:%u\n" , entity->priority, sched_list[0 ]->num_rqs); entity->priority =max_t (s32, (s32 ) sched_list[0 ]->num_rqs -1 , - (s32 )DRM_SCHED_PRIORITY_MIN ); + (s32 )DRM_SCHED_PRIORITY_LOW ); } entity->rq = sched_list[0 ]->sched_rq[entity->priority]; }
drivers/gpu/drm/scheduler/sched_main.c +5 -5
@@ -1052,7 +1052,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)int i;/* Kernel run queue has higher priority than normal run queue*/ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_MIN ; i--) { +for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { entity = drm_sched_policy ==DRM_SCHED_POLICY_FIFO ?drm_sched_rq_select_entity_fifo (sched, sched->sched_rq[i]) :drm_sched_rq_select_entity_rr (sched, sched->sched_rq[i]);
@@ -1291,7 +1291,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,if (!sched->sched_rq) goto Out_free; sched->num_rqs = num_rqs; -for (i =DRM_SCHED_PRIORITY_MIN ; i < sched->num_rqs; i++) { +for (i =DRM_SCHED_PRIORITY_LOW ; i < sched->num_rqs; i++) { sched->sched_rq[i] =kzalloc (sizeof (*sched->sched_rq[i]),GFP_KERNEL );if (!sched->sched_rq[i]) goto Out_unroll;
@@ -1312,7 +1312,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, sched->ready = true;return 0 ; Out_unroll: -for (--i ; i >=DRM_SCHED_PRIORITY_MIN ; i--) +for (--i ; i >=DRM_SCHED_PRIORITY_LOW ; i--)kfree (sched->sched_rq[i]); Out_free:kfree (sched->sched_rq);
@@ -1338,7 +1338,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)drm_sched_wqueue_stop (sched); -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_MIN ; i--) { +for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);
@@ -1390,7 +1390,7 @@ void drm_sched_increase_karma(struct drm_sched_job *bad)if (bad->s_priority !=DRM_SCHED_PRIORITY_KERNEL ) {atomic_inc (&bad->karma); -for (i =DRM_SCHED_PRIORITY_MIN ; +for (i =DRM_SCHED_PRIORITY_LOW ; i <min_t (typeof (sched->num_rqs), sched->num_rqs,DRM_SCHED_PRIORITY_KERNEL ); i++) {struct drm_sched_rq *rq = sched->sched_rq[i];
include/drm/gpu_scheduler.h +1 -1
@@ -63,7 +63,7 @@ struct drm_file;* to an array, and as such should start at 0. */ enum drm_sched_priority { -DRM_SCHED_PRIORITY_MIN , +DRM_SCHED_PRIORITY_LOW ,DRM_SCHED_PRIORITY_NORMAL ,DRM_SCHED_PRIORITY_HIGH ,DRM_SCHED_PRIORITY_KERNEL ,
Signature · 1 line
2.43.0
Re: [PATCH 1/2] drm/sched: Rename priority MIN to LOW
Am 24.11.23 um 06:27 schrieb Luben Tuikov:
Quoted 9 lines
Rename
DRM_SCHED_PRIORITY_MINtoDRM_SCHED_PRIORITY_LOW.This mirrors
DRM_SCHED_PRIORITY_HIGH, for a list of DRM scheduler priorities in ascending order,
DRM_SCHED_PRIORITY_LOW,
DRM_SCHED_PRIORITY_NORMAL,
DRM_SCHED_PRIORITY_HIGH,
DRM_SCHED_PRIORITY_KERNEL.
Quoted 10 lines
Cc Rob Clark <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Alex Deucher <[email protected]>Cc Christian König <[email protected]>Signed-off-by Luben Tuikov <[email protected]>
Quoted 127 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +- drivers/gpu/drm/scheduler/sched_entity.c | 2 +- drivers/gpu/drm/scheduler/sched_main.c | 10 +++++----- include/drm/gpu_scheduler.h | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +2
-2@@ -73,10 +73,10 @@ amdgpu_ctx_to_drm_sched_prio(int32_t ctx_prio)return DRM_SCHED_PRIORITY_NORMAL ;case AMDGPU_CTX_PRIORITY_VERY_LOW : -return DRM_SCHED_PRIORITY_MIN ; +return DRM_SCHED_PRIORITY_LOW ;case AMDGPU_CTX_PRIORITY_LOW : -return DRM_SCHED_PRIORITY_MIN ; +return DRM_SCHED_PRIORITY_LOW ;case AMDGPU_CTX_PRIORITY_NORMAL :return DRM_SCHED_PRIORITY_NORMAL ;drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-1@@ -325,7 +325,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched)int i;/* Signal all jobs not yet scheduled */ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_MIN ; i--) { +for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);list_for_each_entry (s_entity, &rq->entities, list) {drivers/gpu/drm/msm/msm_gpu.h +1
-1@@ -347,7 +347,7 @@ struct msm_gpu_perfcntr {* DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some * cases, so we don't use it (no need for kernel generated jobs). */ -#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_MIN) +#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_LOW)/** * struct msm_file_private - per-drm_file context drivers/gpu/drm/scheduler/sched_entity.c +1
-1@@ -88,7 +88,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,drm_err (sched_list[0 ],"entity with out-of-bounds priority:%u num_rqs:%u\n" , entity->priority, sched_list[0 ]->num_rqs); entity->priority =max_t (s32, (s32 ) sched_list[0 ]->num_rqs -1 , - (s32 )DRM_SCHED_PRIORITY_MIN ); + (s32 )DRM_SCHED_PRIORITY_LOW ); } entity->rq = sched_list[0 ]->sched_rq[entity->priority]; }drivers/gpu/drm/scheduler/sched_main.c +5
-5@@ -1052,7 +1052,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)int i;/* Kernel run queue has higher priority than normal run queue*/ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_MIN ; i--) { +for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { entity = drm_sched_policy ==DRM_SCHED_POLICY_FIFO ?drm_sched_rq_select_entity_fifo (sched, sched->sched_rq[i]) :drm_sched_rq_select_entity_rr (sched, sched->sched_rq[i]);@@ -1291,7 +1291,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,if (!sched->sched_rq) goto Out_free; sched->num_rqs = num_rqs; -for (i =DRM_SCHED_PRIORITY_MIN ; i < sched->num_rqs; i++) { +for (i =DRM_SCHED_PRIORITY_LOW ; i < sched->num_rqs; i++) { sched->sched_rq[i] =kzalloc (sizeof (*sched->sched_rq[i]),GFP_KERNEL );if (!sched->sched_rq[i]) goto Out_unroll;@@ -1312,7 +1312,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, sched->ready = true;return 0 ; Out_unroll: -for (--i ; i >=DRM_SCHED_PRIORITY_MIN ; i--) +for (--i ; i >=DRM_SCHED_PRIORITY_LOW ; i--)kfree (sched->sched_rq[i]); Out_free:kfree (sched->sched_rq);@@ -1338,7 +1338,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)drm_sched_wqueue_stop (sched); -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_MIN ; i--) { +for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);@@ -1390,7 +1390,7 @@ void drm_sched_increase_karma(struct drm_sched_job *bad)if (bad->s_priority !=DRM_SCHED_PRIORITY_KERNEL ) {atomic_inc (&bad->karma); -for (i =DRM_SCHED_PRIORITY_MIN ; +for (i =DRM_SCHED_PRIORITY_LOW ; i <min_t (typeof (sched->num_rqs), sched->num_rqs,DRM_SCHED_PRIORITY_KERNEL ); i++) {struct drm_sched_rq *rq = sched->sched_rq[i];include/drm/gpu_scheduler.h +1
-1@@ -63,7 +63,7 @@ struct drm_file;* to an array, and as such should start at 0. */ enum drm_sched_priority { -DRM_SCHED_PRIORITY_MIN , +DRM_SCHED_PRIORITY_LOW ,DRM_SCHED_PRIORITY_NORMAL ,DRM_SCHED_PRIORITY_HIGH ,DRM_SCHED_PRIORITY_KERNEL ,
Christian König
maintainerRe: [PATCH 1/2] drm/sched: Rename priority MIN to LOW
Hi Luben,
Am 24.11.23 um 08:57 schrieb Christian König:
Quoted 21 lines
Am 24.11.23 um 06:27 schrieb Luben Tuikov:
Quoted 9 lines
Rename
DRM_SCHED_PRIORITY_MINtoDRM_SCHED_PRIORITY_LOW.This mirrors
DRM_SCHED_PRIORITY_HIGH, for a list of DRM scheduler priorities in ascending order,
DRM_SCHED_PRIORITY_LOW,
DRM_SCHED_PRIORITY_NORMAL,
DRM_SCHED_PRIORITY_HIGH,
DRM_SCHED_PRIORITY_KERNEL.Quoted 10 lines
Cc Rob Clark <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Alex Deucher <[email protected]>Cc Christian König <[email protected]>Signed-off-by Luben Tuikov <[email protected]>
Quoted 1 line
Reviewed-by Christian König <[email protected]>
Looks like you missed one usage in Nouveau:
drivers/gpu/drm/nouveau/nouveau_sched.c:21:41: error: ‘DRM_SCHED_PRIORITY_MIN’ undeclared here (not in a function); did you mean ‘DRM_SCHED_PRIORITY_LOW’? 21 | NOUVEAU_SCHED_PRIORITY_SINGLE = DRM_SCHED_PRIORITY_MIN,
| ^~~~~~~~~~~~~~~~~~~~~~
| DRM_SCHED_PRIORITY_LOW
This now results in a build error on drm-misc-next.
Christian.
Quoted 128 lines
Quoted 127 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +-drivers/gpu/drm/scheduler/sched_entity.c| 2 +- drivers/gpu/drm/scheduler/sched_main.c | 10 +++++----- include/drm/gpu_scheduler.h | 2 +-6 files changed, 11 insertions(+), 11 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0
-0@@ -73,10 +73,10 @@ amdgpu_ctx_to_drm_sched_prio(int32_t ctx_prio) return DRM_SCHED_PRIORITY_NORMAL;case
AMDGPU_CTX_PRIORITY_VERY_LOW:
- returnDRM_SCHED_PRIORITY_MIN;
+ returnDRM_SCHED_PRIORITY_LOW; caseAMDGPU_CTX_PRIORITY_LOW:
- returnDRM_SCHED_PRIORITY_MIN;
+ returnDRM_SCHED_PRIORITY_LOW; caseAMDGPU_CTX_PRIORITY_NORMAL:
returnDRM_SCHED_PRIORITY_NORMAL;drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-1@@ -325,7 +325,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched) int i; /* Signal all jobs not yet scheduled */ - for (i = sched->num_rqs - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) { + for (i = sched->num_rqs - 1; i >= DRM_SCHED_PRIORITY_LOW; i--) { struct drm_sched_rq *rq = sched->sched_rq[i]; spin_lock(&rq->lock); list_for_each_entry(s_entity, &rq->entities, list) {drivers/gpu/drm/msm/msm_gpu.h +1
-1@@ -347,7 +347,7 @@ struct msm_gpu_perfcntr {* DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some * cases, so we don't use it (no need for kernel generated jobs). */ -#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_MIN) +#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_LOW) /*** struct
msm_file_private- per-drm_file contextdrivers/gpu/drm/scheduler/sched_entity.c +1
-1@@ -88,7 +88,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, drm_err(sched_list[0], "entity with out-of-bounds priority:%u num_rqs:%u\n", entity->priority, sched_list[0]->num_rqs); entity->priority = max_t(s32, (s32) sched_list[0]->num_rqs - 1, - (s32) DRM_SCHED_PRIORITY_MIN); + (s32) DRM_SCHED_PRIORITY_LOW); } entity->rq = sched_list[0]->sched_rq[entity->priority];}
drivers/gpu/drm/scheduler/sched_main.c +1
-1@@ -1052,7 +1052,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched) int i; /* Kernel run queue has higher priority than normal run queue*/ - for (i = sched->num_rqs - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) { + for (i = sched->num_rqs - 1; i >= DRM_SCHED_PRIORITY_LOW; i--) {entity =
drm_sched_policy==DRM_SCHED_POLICY_FIFO?drm_sched_rq_select_entity_fifo(sched, sched->sched_rq[i]):
drm_sched_rq_select_entity_rr(sched, sched->sched_rq[i]);drivers/gpu/drm/scheduler/sched_main.c +1
-1@@ -1291,7 +1291,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, if (!sched->sched_rq) goto Out_free; sched->num_rqs = num_rqs; - for (i = DRM_SCHED_PRIORITY_MIN; i < sched->num_rqs; i++) { + for (i = DRM_SCHED_PRIORITY_LOW; i < sched->num_rqs; i++) { sched->sched_rq[i] = kzalloc(sizeof(*sched->sched_rq[i]), GFP_KERNEL); if (!sched->sched_rq[i])goto
Out_unroll;drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -1312,7 +1312,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, sched->ready = true; return 0;
Out_unroll:
- for (--i ; i >=DRM_SCHED_PRIORITY_MIN; i--) + for (--i ; i >=DRM_SCHED_PRIORITY_LOW; i--)kfree(sched->sched_rq[i]);Out_free:
kfree(sched->sched_rq);drivers/gpu/drm/scheduler/sched_main.c +2
-0@@ -1338,7 +1338,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched) drm_sched_wqueue_stop(sched); - for (i = sched->num_rqs - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) { + for (i = sched->num_rqs - 1; i >= DRM_SCHED_PRIORITY_LOW; i--) { struct drm_sched_rq *rq = sched->sched_rq[i]; spin_lock(&rq->lock);@@ -1390,7 +1390,7 @@ void drm_sched_increase_karma(struct drm_sched_job *bad) if (bad->s_priority != DRM_SCHED_PRIORITY_KERNEL) { atomic_inc(&bad->karma); - for (i = DRM_SCHED_PRIORITY_MIN; + for (i = DRM_SCHED_PRIORITY_LOW; i < min_t(typeof(sched->num_rqs), sched->num_rqs, DRM_SCHED_PRIORITY_KERNEL); i++) {struct
drm_sched_rq*rq = sched->sched_rq[i];include/drm/gpu_scheduler.h +1
-1@@ -63,7 +63,7 @@ struct drm_file;* to an array, and as such should start at 0. */ enum drm_sched_priority { - DRM_SCHED_PRIORITY_MIN, + DRM_SCHED_PRIORITY_LOW, DRM_SCHED_PRIORITY_NORMAL, DRM_SCHED_PRIORITY_HIGH, DRM_SCHED_PRIORITY_KERNEL,
Re: [PATCH 1/2] drm/sched: Rename priority MIN to LOW
Quoted 29 lines · Christian König
Hi Luben,
Am 24.11.23 um 08:57 schrieb Christian König:
Quoted 22 lines
Am 24.11.23 um 06:27 schrieb Luben Tuikov:
Quoted 10 lines
Rename
DRM_SCHED_PRIORITY_MINtoDRM_SCHED_PRIORITY_LOW.This mirrors
DRM_SCHED_PRIORITY_HIGH, for a list of DRM scheduler priorities
in ascending order,
DRM_SCHED_PRIORITY_LOW,
DRM_SCHED_PRIORITY_NORMAL,
DRM_SCHED_PRIORITY_HIGH,
DRM_SCHED_PRIORITY_KERNEL.Quoted 10 lines
Cc Rob Clark <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Alex Deucher <[email protected]>Cc Christian König <[email protected]>Signed-off-by Luben Tuikov <[email protected]>Quoted 1 line
Reviewed-by Christian König <[email protected]>Looks like you missed one usage in Nouveau:
Quoted 8 lines
drivers/gpu/drm/nouveau/nouveau_sched.c:21:41: error:
‘DRM_SCHED_PRIORITY_MIN’ undeclared here (not in a function); did you mean ‘DRM_SCHED_PRIORITY_LOW’?
21 |NOUVEAU_SCHED_PRIORITY_SINGLE=DRM_SCHED_PRIORITY_MIN, | ^~~~~~~~~~~~~~~~~~~~~~
|DRM_SCHED_PRIORITY_LOWThis now results in a build error on drm-misc-next.
I'm waiting for someone to R-B the fix I posted two days ago:
https://lore.kernel.org/r/[email protected]
Signature · 2 lines
Regards, Luben
Christian König
maintainerRe: [PATCH 1/2] drm/sched: Rename priority MIN to LOW
Am 27.11.23 um 15:13 schrieb Luben Tuikov:
Quoted 35 lines · Christian König
Quoted 34 lines
Hi Luben,
Am 24.11.23 um 08:57 schrieb Christian König:
Quoted 21 lines
Am 24.11.23 um 06:27 schrieb Luben Tuikov:
Quoted 10 lines
Rename
DRM_SCHED_PRIORITY_MINtoDRM_SCHED_PRIORITY_LOW.This mirrors
DRM_SCHED_PRIORITY_HIGH, for a list of DRM scheduler priorities
in ascending order,
DRM_SCHED_PRIORITY_LOW,
DRM_SCHED_PRIORITY_NORMAL,
DRM_SCHED_PRIORITY_HIGH,
DRM_SCHED_PRIORITY_KERNEL.Quoted 10 lines
Cc Rob Clark <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Alex Deucher <[email protected]>Cc Christian König <[email protected]>Signed-off-by Luben Tuikov <[email protected]>Quoted 1 line
Reviewed-by Christian König <[email protected]>Looks like you missed one usage in Nouveau:
drivers/gpu/drm/nouveau/nouveau_sched.c:21:41: error:
‘DRM_SCHED_PRIORITY_MIN’ undeclared here (not in a function); did you mean ‘DRM_SCHED_PRIORITY_LOW’?
21 |NOUVEAU_SCHED_PRIORITY_SINGLE=DRM_SCHED_PRIORITY_MIN, | ^~~~~~~~~~~~~~~~~~~~~~
|DRM_SCHED_PRIORITY_LOW
Quoted 3 lines
Quoted 1 line
This now results in a build error on drm-misc-next.
I'm waiting for someone to R-B the fix I posted two days ago:
https://lore.kernel.org/r/[email protected]
There must be something wrong with the dri-devel mailing list (or my gmail, but I doubt so). I don't see this mail in my inbox anywhere.
Feel free to add my rb and push it.
Thanks,
Christian.
Re: [PATCH 1/2] drm/sched: Rename priority MIN to LOW
Quoted 36 lines · Christian König
Am 27.11.23 um 15:13 schrieb Luben Tuikov:
Quoted 35 lines · Christian König
Quoted 34 lines
Hi Luben,
Am 24.11.23 um 08:57 schrieb Christian König:
Quoted 21 lines
Am 24.11.23 um 06:27 schrieb Luben Tuikov:
Quoted 10 lines
Rename
DRM_SCHED_PRIORITY_MINtoDRM_SCHED_PRIORITY_LOW.This mirrors
DRM_SCHED_PRIORITY_HIGH, for a list of DRM scheduler priorities
in ascending order,
DRM_SCHED_PRIORITY_LOW,
DRM_SCHED_PRIORITY_NORMAL,
DRM_SCHED_PRIORITY_HIGH,
DRM_SCHED_PRIORITY_KERNEL.Quoted 10 lines
Cc Rob Clark <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Alex Deucher <[email protected]>Cc Christian König <[email protected]>Signed-off-by Luben Tuikov <[email protected]>Quoted 1 line
Reviewed-by Christian König <[email protected]>Looks like you missed one usage in Nouveau:
drivers/gpu/drm/nouveau/nouveau_sched.c:21:41: error:
‘DRM_SCHED_PRIORITY_MIN’ undeclared here (not in a function); did you mean ‘DRM_SCHED_PRIORITY_LOW’?
21 |NOUVEAU_SCHED_PRIORITY_SINGLE=DRM_SCHED_PRIORITY_MIN, | ^~~~~~~~~~~~~~~~~~~~~~
|DRM_SCHED_PRIORITY_LOW
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
This now results in a build error on drm-misc-next.
I'm waiting for someone to R-B the fix I posted two days ago:
https://lore.kernel.org/r/[email protected]There must be something wrong with the dri-devel mailing list (or my gmail, but I doubt so). I don't see this mail in my inbox anywhere.
Feel free to add my rb and push it.
Done.
Thanks.
Signature · 2 lines
Regards, Luben
PATCH 2/2 drm/sched: Reverse run-queue priority enumeration
In reply to Luben TuikovReverse run-queue priority enumeration such that the higest priority is now 0, and for each consecutive integer the prioirty diminishes.
Run-queues correspond to priorities. To an external observer a scheduler created with a single run-queue, and another created with DRM_SCHED_PRIORITY_COUNT number of run-queues, should always schedule sched->sched_rq[0] with the same "priority", as that index run-queue exists in both schedulers, i.e. a scheduler with one run-queue or many. This patch makes it so.
In other words, the "priority" of sched->sched_rq[n], n >= 0, is the same for any scheduler created with any allowable number of run-queues (priorities), 0 to DRM_SCHED_PRIORITY_COUNT.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +- drivers/gpu/drm/scheduler/sched_entity.c | 7 ++++--- drivers/gpu/drm/scheduler/sched_main.c | 15 +++++++-------- include/drm/gpu_scheduler.h | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
@@ -325,7 +325,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched)int i;/* Signal all jobs not yet scheduled */ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);list_for_each_entry (s_entity, &rq->entities, list) {
drivers/gpu/drm/msm/msm_gpu.h +1 -1
@@ -347,7 +347,7 @@ struct msm_gpu_perfcntr {* DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some * cases, so we don't use it (no need for kernel generated jobs). */ -#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_LOW) +#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_LOW - DRM_SCHED_PRIORITY_HIGH)/** * struct msm_file_private - per-drm_file context
drivers/gpu/drm/scheduler/sched_entity.c +4 -3
@@ -81,14 +81,15 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,*/ pr_warn ("%s: called with uninitialized scheduler\n" , __func__); }else if (num_sched_list) { -/* The "priority" of an entity cannot exceed the number -* of run-queues of a scheduler. +/* The "priority" of an entity cannot exceed the number of +* run-queues of a scheduler. Choose the lowest priority +* available. */ if (entity->priority >= sched_list[0 ]->num_rqs) {drm_err (sched_list[0 ],"entity with out-of-bounds priority:%u num_rqs:%u\n" , entity->priority, sched_list[0 ]->num_rqs); entity->priority =max_t (s32, (s32 ) sched_list[0 ]->num_rqs -1 , - (s32 )DRM_SCHED_PRIORITY_LOW ); + (s32 )DRM_SCHED_PRIORITY_KERNEL ); } entity->rq = sched_list[0 ]->sched_rq[entity->priority]; }
drivers/gpu/drm/scheduler/sched_main.c +7 -8
@@ -1051,8 +1051,9 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)struct drm_sched_entity *entity;int i; -/* Kernel run queue has higher priority than normal run queue*/ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { +/* Start with the highest priority. +*/ +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) { entity = drm_sched_policy ==DRM_SCHED_POLICY_FIFO ?drm_sched_rq_select_entity_fifo (sched, sched->sched_rq[i]) :drm_sched_rq_select_entity_rr (sched, sched->sched_rq[i]);
@@ -1291,7 +1292,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,if (!sched->sched_rq) goto Out_free; sched->num_rqs = num_rqs; -for (i =DRM_SCHED_PRIORITY_LOW ; i < sched->num_rqs; i++) { +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) { sched->sched_rq[i] =kzalloc (sizeof (*sched->sched_rq[i]),GFP_KERNEL );if (!sched->sched_rq[i]) goto Out_unroll;
@@ -1312,7 +1313,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, sched->ready = true;return 0 ; Out_unroll: -for (--i ; i >=DRM_SCHED_PRIORITY_LOW ; i--) +for (--i ; i >=DRM_SCHED_PRIORITY_KERNEL ; i--)kfree (sched->sched_rq[i]); Out_free:kfree (sched->sched_rq);
@@ -1338,7 +1339,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)drm_sched_wqueue_stop (sched); -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);
@@ -1390,9 +1391,7 @@ void drm_sched_increase_karma(struct drm_sched_job *bad)if (bad->s_priority !=DRM_SCHED_PRIORITY_KERNEL ) {atomic_inc (&bad->karma); -for (i =DRM_SCHED_PRIORITY_LOW ; - i <min_t (typeof (sched->num_rqs), sched->num_rqs,DRM_SCHED_PRIORITY_KERNEL ); - i++) { +for (i =DRM_SCHED_PRIORITY_HIGH ; i < sched->num_rqs; i++) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);
include/drm/gpu_scheduler.h +3 -3
@@ -63,10 +63,10 @@ struct drm_file;* to an array, and as such should start at 0. */ enum drm_sched_priority { -DRM_SCHED_PRIORITY_LOW , -DRM_SCHED_PRIORITY_NORMAL , -DRM_SCHED_PRIORITY_HIGH ,DRM_SCHED_PRIORITY_KERNEL , +DRM_SCHED_PRIORITY_HIGH , +DRM_SCHED_PRIORITY_NORMAL , +DRM_SCHED_PRIORITY_LOW ,DRM_SCHED_PRIORITY_COUNT };
Signature · 1 line
2.43.0
Christian König
maintainerRe: [PATCH 2/2] drm/sched: Reverse run-queue priority enumeration
Am 24.11.23 um 06:27 schrieb Luben Tuikov:
Quoted 68 lines
Reverse run-queue priority enumeration such that the higest priority is now 0, and for each consecutive integer the prioirty diminishes.
Run-queues correspond to priorities. To an external observer a scheduler created with a single run-queue, and another created with
DRM_SCHED_PRIORITY_COUNTnumber of run-queues, should always schedule sched->sched_rq[0] with the same "priority", as that index run-queue exists in both schedulers, i.e. a scheduler with one run-queue or many. This patch makes it so.In other words, the "priority" of sched->sched_rq[n], n >= 0, is the same for any scheduler created with any allowable number of run-queues (priorities), 0 to
DRM_SCHED_PRIORITY_COUNT.Cc Rob Clark <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Alex Deucher <[email protected]>Cc Christian König <[email protected]>Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +- drivers/gpu/drm/scheduler/sched_entity.c | 7 ++++--- drivers/gpu/drm/scheduler/sched_main.c | 15 +++++++-------- include/drm/gpu_scheduler.h | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-1@@ -325,7 +325,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched)int i;/* Signal all jobs not yet scheduled */ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);list_for_each_entry (s_entity, &rq->entities, list) {drivers/gpu/drm/msm/msm_gpu.h +1
-1@@ -347,7 +347,7 @@ struct msm_gpu_perfcntr {* DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some * cases, so we don't use it (no need for kernel generated jobs). */ -#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_LOW) +#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_LOW - DRM_SCHED_PRIORITY_HIGH)/** * struct msm_file_private - per-drm_file context drivers/gpu/drm/scheduler/sched_entity.c +0
-2@@ -81,14 +81,15 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,*/ pr_warn ("%s: called with uninitialized scheduler\n" , __func__); }else if (num_sched_list) { -/* The "priority" of an entity cannot exceed the number -* of run-queues of a scheduler.
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 92
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +4
-1+/* The "priority" of an entity cannot exceed the number of +* run-queues of a scheduler. Choose the lowest priority +* available. */ if (entity->priority >= sched_list[0 ]->num_rqs) {drm_err (sched_list[0 ],"entity with out-of-bounds priority:%u num_rqs:%u\n" , entity->priority, sched_list[0 ]->num_rqs); entity->priority =max_t (s32, (s32 ) sched_list[0 ]->num_rqs -1 , - (s32 )DRM_SCHED_PRIORITY_LOW ); + (s32 )DRM_SCHED_PRIORITY_KERNEL );
That seems to be a no-op. You basically say max_T(.., num_rqs - 1, 0), this will always be num_rqs - 1
Apart from that looks good to me.
Christian.
Quoted 75 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0} entity->rq = sched_list[0 ]->sched_rq[entity->priority]; }drivers/gpu/drm/scheduler/sched_main.c +7
-8@@ -1051,8 +1051,9 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)struct drm_sched_entity *entity;int i; -/* Kernel run queue has higher priority than normal run queue*/ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { +/* Start with the highest priority. +*/ +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) { entity = drm_sched_policy ==DRM_SCHED_POLICY_FIFO ?drm_sched_rq_select_entity_fifo (sched, sched->sched_rq[i]) :drm_sched_rq_select_entity_rr (sched, sched->sched_rq[i]);@@ -1291,7 +1292,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,if (!sched->sched_rq) goto Out_free; sched->num_rqs = num_rqs; -for (i =DRM_SCHED_PRIORITY_LOW ; i < sched->num_rqs; i++) { +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) { sched->sched_rq[i] =kzalloc (sizeof (*sched->sched_rq[i]),GFP_KERNEL );if (!sched->sched_rq[i]) goto Out_unroll;@@ -1312,7 +1313,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, sched->ready = true;return 0 ; Out_unroll: -for (--i ; i >=DRM_SCHED_PRIORITY_LOW ; i--) +for (--i ; i >=DRM_SCHED_PRIORITY_KERNEL ; i--)kfree (sched->sched_rq[i]); Out_free:kfree (sched->sched_rq);@@ -1338,7 +1339,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)drm_sched_wqueue_stop (sched); -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);@@ -1390,9 +1391,7 @@ void drm_sched_increase_karma(struct drm_sched_job *bad)if (bad->s_priority !=DRM_SCHED_PRIORITY_KERNEL ) {atomic_inc (&bad->karma); -for (i =DRM_SCHED_PRIORITY_LOW ; - i <min_t (typeof (sched->num_rqs), sched->num_rqs,DRM_SCHED_PRIORITY_KERNEL ); - i++) { +for (i =DRM_SCHED_PRIORITY_HIGH ; i < sched->num_rqs; i++) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);include/drm/gpu_scheduler.h +3
-3@@ -63,10 +63,10 @@ struct drm_file;* to an array, and as such should start at 0. */ enum drm_sched_priority { -DRM_SCHED_PRIORITY_LOW , -DRM_SCHED_PRIORITY_NORMAL , -DRM_SCHED_PRIORITY_HIGH ,DRM_SCHED_PRIORITY_KERNEL , +DRM_SCHED_PRIORITY_HIGH , +DRM_SCHED_PRIORITY_NORMAL , +DRM_SCHED_PRIORITY_LOW ,DRM_SCHED_PRIORITY_COUNT };
Re: [PATCH 2/2] drm/sched: Reverse run-queue priority enumeration
Quoted 74 lines · Christian König
Am 24.11.23 um 06:27 schrieb Luben Tuikov:
Quoted 73 lines
Reverse run-queue priority enumeration such that the higest priority is now 0, and for each consecutive integer the prioirty diminishes.
Run-queues correspond to priorities. To an external observer a scheduler created with a single run-queue, and another created with
DRM_SCHED_PRIORITY_COUNTnumber of run-queues, should always schedule sched->sched_rq[0] with the same "priority", as that index run-queue exists in both schedulers, i.e. a scheduler with one run-queue or many. This patch makes it so.In other words, the "priority" of sched->sched_rq[n], n >= 0, is the same for any scheduler created with any allowable number of run-queues (priorities), 0 to
DRM_SCHED_PRIORITY_COUNT.Cc Rob Clark <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Alex Deucher <[email protected]>Cc Christian König <[email protected]>Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +- drivers/gpu/drm/scheduler/sched_entity.c | 7 ++++--- drivers/gpu/drm/scheduler/sched_main.c | 15 +++++++-------- include/drm/gpu_scheduler.h | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-1@@ -325,7 +325,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched)int i;/* Signal all jobs not yet scheduled */ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);list_for_each_entry (s_entity, &rq->entities, list) {drivers/gpu/drm/msm/msm_gpu.h +1
-1@@ -347,7 +347,7 @@ struct msm_gpu_perfcntr {* DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some * cases, so we don't use it (no need for kernel generated jobs). */ -#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_LOW) +#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_LOW - DRM_SCHED_PRIORITY_HIGH)/** * struct msm_file_private - per-drm_file context drivers/gpu/drm/scheduler/sched_entity.c +3
-2@@ -81,14 +81,15 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,*/ pr_warn ("%s: called with uninitialized scheduler\n" , __func__); }else if (num_sched_list) { -/* The "priority" of an entity cannot exceed the number -* of run-queues of a scheduler. +/* The "priority" of an entity cannot exceed the number of +* run-queues of a scheduler. Choose the lowest priority +* available. */ if (entity->priority >= sched_list[0 ]->num_rqs) {
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 92
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-1drm_err (sched_list[0 ],"entity with out-of-bounds priority:%u num_rqs:%u\n" , entity->priority, sched_list[0 ]->num_rqs); entity->priority =max_t (s32, (s32 ) sched_list[0 ]->num_rqs -1 , - (s32 )DRM_SCHED_PRIORITY_LOW ); + (s32 )DRM_SCHED_PRIORITY_KERNEL );That seems to be a no-op. You basically say
max_T(.., num_rqs - 1, 0), this will always benum_rqs- 1
This protects against num_rqs being equal to 0, in which case we select KERNEL (0).
This comes from "[PATCH] drm/sched: Fix bounds limiting when given a malformed entity" which I sent yesterday (Message-ID: <[email protected]>).
Could you R-B that patch too?
Quoted 2 lines
Apart from that looks good to me.
Okay, could you R-B this patch then.
Signature · 2 lines
Regards, Luben
Christian König
maintainerRe: [PATCH 2/2] drm/sched: Reverse run-queue priority enumeration
Am 24.11.23 um 09:22 schrieb Luben Tuikov:
Quoted 82 lines · Christian König
Quoted 73 lines
Am 24.11.23 um 06:27 schrieb Luben Tuikov:
Quoted 72 lines
Reverse run-queue priority enumeration such that the higest priority is now 0, and for each consecutive integer the prioirty diminishes.
Run-queues correspond to priorities. To an external observer a scheduler created with a single run-queue, and another created with
DRM_SCHED_PRIORITY_COUNTnumber of run-queues, should always schedule sched->sched_rq[0] with the same "priority", as that index run-queue exists in both schedulers, i.e. a scheduler with one run-queue or many. This patch makes it so.In other words, the "priority" of sched->sched_rq[n], n >= 0, is the same for any scheduler created with any allowable number of run-queues (priorities), 0 to
DRM_SCHED_PRIORITY_COUNT.Cc Rob Clark <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Alex Deucher <[email protected]>Cc Christian König <[email protected]>Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +- drivers/gpu/drm/scheduler/sched_entity.c | 7 ++++--- drivers/gpu/drm/scheduler/sched_main.c | 15 +++++++-------- include/drm/gpu_scheduler.h | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-1@@ -325,7 +325,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched)int i;/* Signal all jobs not yet scheduled */ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);list_for_each_entry (s_entity, &rq->entities, list) {drivers/gpu/drm/msm/msm_gpu.h +1
-1@@ -347,7 +347,7 @@ struct msm_gpu_perfcntr {* DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some * cases, so we don't use it (no need for kernel generated jobs). */ -#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_LOW) +#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_LOW - DRM_SCHED_PRIORITY_HIGH)/** * struct msm_file_private - per-drm_file context drivers/gpu/drm/scheduler/sched_entity.c +3
-2@@ -81,14 +81,15 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,*/ pr_warn ("%s: called with uninitialized scheduler\n" , __func__); }else if (num_sched_list) { -/* The "priority" of an entity cannot exceed the number -* of run-queues of a scheduler. +/* The "priority" of an entity cannot exceed the number of +* run-queues of a scheduler. Choose the lowest priority +* available. */ Quoted 8 lines
drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 92
Quoted 6 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-1if (entity->priority >= sched_list[0 ]->num_rqs) {drm_err (sched_list[0 ],"entity with out-of-bounds priority:%u num_rqs:%u\n" , entity->priority, sched_list[0 ]->num_rqs); entity->priority =max_t (s32, (s32 ) sched_list[0 ]->num_rqs -1 , - (s32 )DRM_SCHED_PRIORITY_LOW ); + (s32 )DRM_SCHED_PRIORITY_KERNEL );That seems to be a no-op. You basically say
max_T(.., num_rqs - 1, 0), this will always benum_rqs- 1
Quoted 1 line
This protects against
num_rqsbeing equal to 0, in which case we select KERNEL (0).
Ah! That's also why convert it to signed! I was already wondering why you do this.
Quoted 3 lines
This comes from "[PATCH] drm/sched: Fix bounds limiting when given a malformed entity" which I sent yesterday (Message-ID: <[email protected]>).
I can't find that one in my inbox anywhere, but was able to find it in patchwork.
Quoted 1 line
Could you R-B that patch too?
I would add a comment cause the intention of max_t(s32 is really not obvious here.
With that done feel free to add my rb to both patches.
Regards,
Christian.
Quoted 3 lines
Quoted 2 lines
Apart from that looks good to me.
Okay, could you R-B this patch then.
Re: [PATCH 2/2] drm/sched: Reverse run-queue priority enumeration
Quoted 83 lines · Christian König
Am 24.11.23 um 09:22 schrieb Luben Tuikov:
Quoted 82 lines · Christian König
Quoted 81 lines
Am 24.11.23 um 06:27 schrieb Luben Tuikov:
Quoted 68 lines
Reverse run-queue priority enumeration such that the higest priority is now 0, and for each consecutive integer the prioirty diminishes.
Run-queues correspond to priorities. To an external observer a scheduler created with a single run-queue, and another created with
DRM_SCHED_PRIORITY_COUNTnumber of run-queues, should always schedule sched->sched_rq[0] with the same "priority", as that index run-queue exists in both schedulers, i.e. a scheduler with one run-queue or many. This patch makes it so.In other words, the "priority" of sched->sched_rq[n], n >= 0, is the same for any scheduler created with any allowable number of run-queues (priorities), 0 to
DRM_SCHED_PRIORITY_COUNT.Cc Rob Clark <[email protected]>Cc Abhinav Kumar <[email protected]>Cc Dmitry Baryshkov <[email protected]>Cc Danilo Krummrich <[email protected]>Cc Alex Deucher <[email protected]>Cc Christian König <[email protected]>Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +- drivers/gpu/drm/scheduler/sched_entity.c | 7 ++++--- drivers/gpu/drm/scheduler/sched_main.c | 15 +++++++-------- include/drm/gpu_scheduler.h | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-1@@ -325,7 +325,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched)int i;/* Signal all jobs not yet scheduled */ -for (i = sched->num_rqs -1 ; i >=DRM_SCHED_PRIORITY_LOW ; i--) { +for (i =DRM_SCHED_PRIORITY_KERNEL ; i < sched->num_rqs; i++) {struct drm_sched_rq *rq = sched->sched_rq[i];spin_lock (&rq->lock);list_for_each_entry (s_entity, &rq->entities, list) {drivers/gpu/drm/msm/msm_gpu.h +1
-1@@ -347,7 +347,7 @@ struct msm_gpu_perfcntr {* DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some * cases, so we don't use it (no need for kernel generated jobs). */ -#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_LOW) +#define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_LOW - DRM_SCHED_PRIORITY_HIGH)/** * struct msm_file_private - per-drm_file context drivers/gpu/drm/scheduler/sched_entity.c +0
-2@@ -81,14 +81,15 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,*/ pr_warn ("%s: called with uninitialized scheduler\n" , __func__); }else if (num_sched_list) { -/* The "priority" of an entity cannot exceed the number -* of run-queues of a scheduler. drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 92
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_entity.c +4
-1+/* The "priority" of an entity cannot exceed the number of +* run-queues of a scheduler. Choose the lowest priority +* available. */ if (entity->priority >= sched_list[0 ]->num_rqs) {drm_err (sched_list[0 ],"entity with out-of-bounds priority:%u num_rqs:%u\n" , entity->priority, sched_list[0 ]->num_rqs); entity->priority =max_t (s32, (s32 ) sched_list[0 ]->num_rqs -1 , - (s32 )DRM_SCHED_PRIORITY_LOW ); + (s32 )DRM_SCHED_PRIORITY_KERNEL );That seems to be a no-op. You basically say
max_T(.., num_rqs - 1, 0), this will always benum_rqs- 1
Quoted 4 lines
Quoted 1 line
This protects against
num_rqsbeing equal to 0, in which case we select KERNEL (0).Ah! That's also why convert it to signed! I was already wondering why you do this.
I thought it was clear since we're doing,
num_rqs - 1
and there's no guarantee that the result would be non-negative even if the variable num_rqs was non-negative. But I've added an explanation of what's going on here.
Quoted 6 lines
Quoted 3 lines
This comes from "[PATCH] drm/sched: Fix bounds limiting when given a malformed entity" which I sent yesterday (Message-ID: <[email protected]>).
I can't find that one in my inbox anywhere, but was able to find it in patchwork.
Did you check your gmail?
Quoted 6 lines
Quoted 1 line
Could you R-B that patch too?
I would add a comment cause the intention of max_t(s32 is really not obvious here.
With that done feel free to add my rb to both patches.
Done.
Signature · 2 lines
Regards, Luben