Skip to contentSkip to conversation

drm/sched: Avoid infinite waits in the drm_sched_entity_destroy() path

PATCH In review Boris Brezillon 2 participants 3 messages Oct 2, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/sched: Avoid infinite waits in the drm_sched_entity_destroy() path

If we don't initialize the entity to idle and the entity is never scheduled before being destroyed we end up with an infinite wait in the destroy path.

v2:
- Add Steven's R-b

---
This is something I noticed while debugging another issue on panfrost causing the scheduler to be in a weird state where new entities were no longer scheduled. This was causing all userspace threads trying to close their DRM fd to be blocked in kernel space waiting for this "entity is idle" event. I don't know if that fix is legitimate (now that we fixed the other bug we don't seem to end up in that state anymore), but I thought I'd share it anyway.

---
 drivers/gpu/drm/scheduler/sched_entity.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/scheduler/sched_entity.c +3 -0
index 146380118962..f8ec277a6aa8 100644
@@ -73,6 +73,9 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
 
 	init_completion(&entity->entity_idle);
 
+	/* We start in an idle state. */
+	complete(&entity->entity_idle);
+
 	spin_lock_init(&entity->rq_lock);
 	spsc_queue_init(&entity->job_queue);
 
Signature · 6 lines
2.26.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 1/1
#1 lore raw

Am 02.10.20 um 08:55 schrieb Boris Brezillon:

Quoted 3 lines

If we don't initialize the entity to idle and the entity is never scheduled before being destroyed we end up with an infinite wait in the destroy path.

Good catch, of hand I would say that this is valid.

Quoted 6 lines

v2:
- Add Steven's R-b

Should I pick it up for drm-misc-next? (Or maybe even -fixes?).

Thanks,
Christian.

Quoted 17 lines

---
This is something I noticed while debugging another issue on panfrost causing the scheduler to be in a weird state where new entities were no longer scheduled. This was causing all userspace threads trying to close their DRM fd to be blocked in kernel space waiting for this "entity is idle" event. I don't know if that fix is legitimate (now that we fixed the other bug we don't seem to end up in that state anymore), but I thought I'd share it anyway.

---
  drivers/gpu/drm/scheduler/sched_entity.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/scheduler/sched_entity.c +0 -0
index 146380118962..f8ec277a6aa8 100644

drivers/gpu/drm/scheduler/sched_entity.c int drm_sched_entity_init(struct drm_sched_entity *entity, · line 81

Quoted 9 lines
drivers/gpu/drm/scheduler/sched_entity.c +3 -0
@@ -73,6 +73,9 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
 
  	init_completion(&entity->entity_idle);
 
+	/* We start in an idle state. */
+	complete(&entity->entity_idle);
+
  	spin_lock_init(&entity->rq_lock);
  	spsc_queue_init(&entity->job_queue);
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 11 lines · On Fri, 2 Oct 2020 10:31:31 +0200 Christian König <[email protected]>…

Am 02.10.20 um 08:55 schrieb Boris Brezillon:

Quoted 3 lines

If we don't initialize the entity to idle and the entity is never scheduled before being destroyed we end up with an infinite wait in the destroy path.

Good catch, of hand I would say that this is valid.

Quoted 4 lines

v2:
- Add Steven's R-b

Quoted 6 lines
Quoted 2 lines

Should I pick it up for drm-misc-next? (Or maybe even -fixes?).

Sure.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel