drm/scheduler: only kill entity if last user is killed
Subsystems (3)
PATCH 1/1 drm/scheduler: only kill entity if last user is killed
Note which task is using the entity and only kill it if the last user of the entity is killed. This should prevent problems when entities are leaked to child processes.
--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 6 +++++- include/drm/gpu_scheduler.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/scheduler/gpu_scheduler.c +5 -1
@@ -275,6 +275,7 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,long drm_sched_entity_flush (struct drm_sched_entity *entity,long timeout) {struct drm_gpu_scheduler *sched; +struct task_struct *last_user;long ret = timeout; sched = entity->rq->sched;
@@ -295,7 +296,9 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout)/* For killed process disable any more IBs enqueue right now */ -if ((current->flags &PF_EXITING ) && (current->exit_code ==SIGKILL )) + last_user =cmpxchg (&entity->last_user, current->group_leader,NULL ); +if ((!last_user || last_user == current->group_leader) && + (current->flags &PF_EXITING ) && (current->exit_code ==SIGKILL ))drm_sched_entity_set_rq (entity,NULL );return ret;
@@ -541,6 +544,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job,trace_drm_sched_job (sched_job, entity); +WRITE_ONCE (entity->last_user, current->group_leader); first =spsc_queue_push (&entity->job_queue, &sched_job->queue_node);/* first job wakes up scheduler */
include/drm/gpu_scheduler.h +1 -0
@@ -85,6 +85,7 @@ struct drm_sched_entity {struct dma_fence_cb cb;atomic_t *guilty;struct dma_fence *last_scheduled; +struct task_struct *last_user; };/**
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180726114554.3873-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
Huang Rui
Reviewed-byQuoted 5 lines · Christian König
Note which task is using the entity and only kill it if the last user of the entity is killed. This should prevent problems when entities are leaked to child processes.
Signed-off-by Christian König <[email protected]>
I am not very familiar with scheduler yet. From code logic, it looks fine for me.
Quoted 55 lines
--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 6 +++++- include/drm/gpu_scheduler.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)drivers/gpu/drm/scheduler/gpu_scheduler.c +5
-1@@ -275,6 +275,7 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,long drm_sched_entity_flush (struct drm_sched_entity *entity,long timeout) {struct drm_gpu_scheduler *sched; +struct task_struct *last_user;long ret = timeout; sched = entity->rq->sched;@@ -295,7 +296,9 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout)/* For killed process disable any more IBs enqueue right now */ -if ((current->flags &PF_EXITING ) && (current->exit_code ==SIGKILL )) + last_user =cmpxchg (&entity->last_user, current->group_leader,NULL ); +if ((!last_user || last_user == current->group_leader) && + (current->flags &PF_EXITING ) && (current->exit_code ==SIGKILL ))drm_sched_entity_set_rq (entity,NULL );return ret;@@ -541,6 +544,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job,trace_drm_sched_job (sched_job, entity); +WRITE_ONCE (entity->last_user, current->group_leader); first =spsc_queue_push (&entity->job_queue, &sched_job->queue_node);/* first job wakes up scheduler */ include/drm/gpu_scheduler.h +1
-0@@ -85,6 +85,7 @@ struct drm_sched_entity {struct dma_fence_cb cb;atomic_t *guilty;struct dma_fence *last_scheduled; +struct task_struct *last_user; };/** Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 55 lines · Christian König
Note which task is using the entity and only kill it if the last user of the entity is killed. This should prevent problems when entities are leaked to
child processes.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 6 +++++- include/drm/gpu_scheduler.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)drivers/gpu/drm/scheduler/gpu_scheduler.c +1
-0@@ -275,6 +275,7 @@ static void drm_sched_entity_kill_jobs_cb(structdma_fence *f, long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) { struct drm_gpu_scheduler *sched; +struct task_struct *last_user;long ret = timeout;sched = entity->rq->sched;drivers/gpu/drm/scheduler/gpu_scheduler.c +3
-1@@ -295,7 +296,9 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout)/* For killed process disable any more IBs enqueue right now */ -if ((current->flags &PF_EXITING ) && (current->exit_code == SIGKILL)) + last_user =cmpxchg (&entity->last_user, current->group_leader,NULL ); + if ((!last_user || last_user == current->group_leader) && + (current->flags & PF_EXITING) && (current->exit_code ==SIGKILL))
drm_sched_entity_set_rq(entity, NULL); return ret;drivers/gpu/drm/scheduler/gpu_scheduler.c +1
-0@@ -541,6 +544,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job,trace_drm_sched_job (sched_job, entity); +WRITE_ONCE (entity->last_user, current->group_leader); first =spsc_queue_push (&entity->job_queue, &sched_job->queue_node);/* first job wakes up scheduler */include/drm/gpu_scheduler.h +0
-0
include/drm/gpu_scheduler.h struct drm_sched_entity { · line 89
Quoted 5 lines
include/drm/gpu_scheduler.h +1
-0@@ -85,6 +85,7 @@ struct drm_sched_entity {struct dma_fence_cb cb;atomic_t *guilty;struct dma_fence *last_scheduled; +struct task_struct *last_user;
Please add a line regarding this field in the kernel doc comments.
Regards,
Nayan
Quoted 11 lines
include/drm/gpu_scheduler.h +0
-0};/**
--
2.14.1_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx