dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/sched: avoid killing parent entity on child SIGKILL v3
@ 2025-10-15 14:01 Christian König
  2025-10-16 12:31 ` Philipp Stanner
  2025-10-17  6:18 ` Philipp Stanner
  0 siblings, 2 replies; 9+ messages in thread
From: Christian König @ 2025-10-15 14:01 UTC (permalink / raw)
  To: phasta, alexdeucher, dakr, matthew.brost, dri-devel

From: David Rosca <david.rosca@amd.com>

The DRM scheduler tracks who last uses an entity and when that process
is killed blocks all further submissions to that entity.

The problem is that we didn't track who initially created an entity, so
when a process accidently leaked its file descriptor to a child and
that child got killed, we killed the parent's entities.

Avoid that and instead initialize the entities last user on entity
creation. This also allows to drop the extra NULL check.

v2: still use cmpxchg
v3: improve the commit message

Signed-off-by: David Rosca <david.rosca@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4568
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
CC: stable@vger.kernel.org
---
 drivers/gpu/drm/scheduler/sched_entity.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index 5a4697f636f2..3e2f83dc3f24 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -70,6 +70,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
 	entity->guilty = guilty;
 	entity->num_sched_list = num_sched_list;
 	entity->priority = priority;
+	entity->last_user = current->group_leader;
 	/*
 	 * It's perfectly valid to initialize an entity without having a valid
 	 * scheduler attached. It's just not valid to use the scheduler before it
@@ -302,7 +303,7 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout)
 
 	/* For a killed process disallow further enqueueing of jobs. */
 	last_user = cmpxchg(&entity->last_user, current->group_leader, NULL);
-	if ((!last_user || last_user == current->group_leader) &&
+	if (last_user == current->group_leader &&
 	    (current->flags & PF_EXITING) && (current->exit_code == SIGKILL))
 		drm_sched_entity_kill(entity);
 
-- 
2.43.0


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

end of thread, other threads:[~2025-10-29 13:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 14:01 [PATCH] drm/sched: avoid killing parent entity on child SIGKILL v3 Christian König
2025-10-16 12:31 ` Philipp Stanner
2025-10-16 13:11   ` Christian König
2025-10-16 17:20     ` Philipp Stanner
2025-10-16 17:31       ` Christian König
2025-10-17  6:18 ` Philipp Stanner
2025-10-28 13:07   ` Alex Deucher
2025-10-28 13:13     ` Philipp Stanner
2025-10-29 13:57       ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox