<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 26, 2018 at 5:16 PM Christian König <<a href="mailto:ckoenig.leichtzumerken@gmail.com">ckoenig.leichtzumerken@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Note which task is using the entity and only kill it if the last user of<br>
the entity is killed. This should prevent problems when entities are leaked to<br>
child processes.<br>
<br>
Signed-off-by: Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank">christian.koenig@amd.com</a>><br>
---<br>
drivers/gpu/drm/scheduler/gpu_scheduler.c | 6 +++++-<br>
include/drm/gpu_scheduler.h | 1 +<br>
2 files changed, 6 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c<br>
index 3f2fc5e8242a..f563e4fbb4b6 100644<br>
--- a/drivers/gpu/drm/scheduler/gpu_scheduler.c<br>
+++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c<br>
@@ -275,6 +275,7 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,<br>
long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout)<br>
{<br>
struct drm_gpu_scheduler *sched;<br>
+ struct task_struct *last_user;<br>
long ret = timeout;<br>
<br>
sched = entity->rq->sched;<br>
@@ -295,7 +296,9 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout)<br>
<br>
<br>
/* For killed process disable any more IBs enqueue right now */<br>
- if ((current->flags & PF_EXITING) && (current->exit_code == SIGKILL))<br>
+ last_user = cmpxchg(&entity->last_user, current->group_leader, NULL);<br>
+ if ((!last_user || last_user == current->group_leader) &&<br>
+ (current->flags & PF_EXITING) && (current->exit_code == SIGKILL))<br>
drm_sched_entity_set_rq(entity, NULL);<br>
<br>
return ret;<br>
@@ -541,6 +544,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job,<br>
<br>
trace_drm_sched_job(sched_job, entity);<br>
<br>
+ WRITE_ONCE(entity->last_user, current->group_leader);<br>
first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node);<br>
<br>
/* first job wakes up scheduler */<br>
diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h<br>
index 091b9afcd184..64016446a103 100644<br>
--- a/include/drm/gpu_scheduler.h<br>
+++ b/include/drm/gpu_scheduler.h<br>
@@ -85,6 +85,7 @@ struct drm_sched_entity {<br>
struct dma_fence_cb cb;<br>
atomic_t *guilty;<br>
struct dma_fence *last_scheduled;<br>
+ struct task_struct *last_user;<br></blockquote><div>Please add a line regarding this field in the kernel doc comments. <br><br></div><div>Regards,<br></div><div>Nayan<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
};<br>
<br>
/**<br>
-- <br>
2.14.1<br>
<br>
_______________________________________________<br>
dri-devel mailing list<br>
<a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
</blockquote></div></div>