All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/scheduler: only kill entity if last user is killed v2
@ 2018-07-30 11:03 Christian König
  2018-07-30 11:03 ` [PATCH 2/2] drm/scheduler: stop setting rq to NULL Christian König
  2018-07-30 13:34 ` [PATCH 1/2] drm/scheduler: only kill entity if last user is killed v2 Nayan Deshmukh
  0 siblings, 2 replies; 26+ messages in thread
From: Christian König @ 2018-07-30 11:03 UTC (permalink / raw)
  To: dri-devel; +Cc: nayan26deshmukh

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.

v2: add missing kernel doc

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/scheduler/gpu_scheduler.c | 6 +++++-
 include/drm/gpu_scheduler.h               | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c
index 3f2fc5e8242a..f563e4fbb4b6 100644
--- a/drivers/gpu/drm/scheduler/gpu_scheduler.c
+++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c
@@ -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 */
diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
index 091b9afcd184..21c648b0b2a1 100644
--- a/include/drm/gpu_scheduler.h
+++ b/include/drm/gpu_scheduler.h
@@ -66,6 +66,7 @@ enum drm_sched_priority {
  * @guilty: points to ctx's guilty.
  * @fini_status: contains the exit status in case the process was signalled.
  * @last_scheduled: points to the finished fence of the last scheduled job.
+ * @last_user: last group leader pushing a job into the entity.
  *
  * Entities will emit jobs in order to their corresponding hardware
  * ring, and the scheduler will alternate between entities based on
@@ -85,6 +86,7 @@ struct drm_sched_entity {
 	struct dma_fence_cb		cb;
 	atomic_t			*guilty;
 	struct dma_fence                *last_scheduled;
+	struct task_struct		*last_user;
 };
 
 /**
-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2018-08-10 13:16 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-30 11:03 [PATCH 1/2] drm/scheduler: only kill entity if last user is killed v2 Christian König
2018-07-30 11:03 ` [PATCH 2/2] drm/scheduler: stop setting rq to NULL Christian König
2018-07-30 13:30   ` Nayan Deshmukh
2018-07-30 20:51     ` Andrey Grodzovsky
2018-07-31  6:50       ` Christian König
2018-07-31 14:16         ` Andrey Grodzovsky
2018-08-01 22:25   ` Andrey Grodzovsky
2018-08-02  6:42     ` Christian König
2018-08-02  6:47       ` Nayan Deshmukh
2018-08-02  7:26         ` Christian König
2018-08-02 14:11         ` Andrey Grodzovsky
2018-08-03 14:06           ` Christian König
2018-08-03 14:54             ` Andrey Grodzovsky
2018-08-03 16:42               ` Christian König
2018-08-03 18:41                 ` Andrey Grodzovsky
2018-08-06  8:14                   ` Christian König
2018-08-09 17:39                     ` Andrey Grodzovsky
2018-08-10 13:16                       ` Christian König
2018-08-02  6:43     ` Nayan Deshmukh
2018-08-02 14:38       ` Andrey Grodzovsky
2018-08-03 12:12         ` Nayan Deshmukh
2018-08-03 13:47           ` Andrey Grodzovsky
2018-08-03 13:58             ` Nayan Deshmukh
2018-07-30 13:34 ` [PATCH 1/2] drm/scheduler: only kill entity if last user is killed v2 Nayan Deshmukh
2018-07-30 20:42   ` Andrey Grodzovsky
2018-07-31  9:11     ` Nayan Deshmukh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.