Skip to contentSkip to conversation

Documentation: drm: Add entry for removing spsc_queue to TODO list

PATCH Applied Philipp Stanner 3 participants 3 messages May 29 – Jun 3

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

PATCH 1/1 Documentation: drm: Add entry for removing spsc_queue to TODO list

drm_sched contains a lockless queue (spsc_queue) that seems to be useless and potentially unsound.

Add a TODO list entry for replacing spsc_queue with a locked list.

---
 Documentation/gpu/todo.rst | 41 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
Documentation/gpu/todo.rst +41 -0
index cdddf8db35f5..87e082b0eb48 100644
@@ -948,6 +948,47 @@ Contact: Philipp Stanner <[email protected]>
 
 Level: Intermediate
 
+Replace the lockless queue with a locked list
+---------------------------------------------
+
+drm_sched is the only user in the entire kernel of a special lockless queue, the
+spsc_queue. This queue utilizes:
+
+- preempt_disable()
+- atomic instructions
+- memory barriers
+- ACCESS_ONCE()
+
+whereas a conventional spinlock utilizes:
+
+- preempt_disable()
+- 1 atomic instruction for taking / releasing the lock
+- memory barriers
+
+Moreover, drm_sched_entity_push_job(), the only user of spsc_queue_push(), has
+to take a lock in some situations anyways and calls to it are often serialized
+with a driver lock.
+
+It is, thus, highly questionable whether the lockless queue grants any advantage
+at all. Considering that its internals are not well documented and its correctness
+is not formally proven, it seems desirable to replace the queue with a mere list
+or hlist that is protected by a spinlock.
+
+Tasks:
+
+- Replace the spsc_queue in drm/sched (and those who might access the scheduler's
+  internal queue) with a spinlock + (h)list.
+- Ideally, check with some micro benchmarks and real world tests (preferably
+  with amdgpu) for relevant performance regressions.
+- Remove the spsc_queue from the kernel altogether.
+
+Contact:
+
+- Philipp Stanner <[email protected]>
+- Christian König <[email protected]>
+
+Level: Beginner
+
 Outside DRM
 ===========
 
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Philipp Stanner

drm_sched contains a lockless queue (spsc_queue) that seems to be useless and potentially unsound.

Add a TODO list entry for replacing spsc_queue with a locked list.

Quoted 56 lines
---
 Documentation/gpu/todo.rst | 41 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
Documentation/gpu/todo.rst +41 -0
index cdddf8db35f5..87e082b0eb48 100644
@@ -948,6 +948,47 @@ Contact: Philipp Stanner <[email protected]>
 
 Level: Intermediate
 
+Replace the lockless queue with a locked list
+---------------------------------------------
+
+drm_sched is the only user in the entire kernel of a special lockless queue, the
+spsc_queue. This queue utilizes:
+
+- preempt_disable()
+- atomic instructions
+- memory barriers
+- ACCESS_ONCE()
+
+whereas a conventional spinlock utilizes:
+
+- preempt_disable()
+- 1 atomic instruction for taking / releasing the lock
+- memory barriers
+
+Moreover, drm_sched_entity_push_job(), the only user of spsc_queue_push(), has
+to take a lock in some situations anyways and calls to it are often serialized
+with a driver lock.
+
+It is, thus, highly questionable whether the lockless queue grants any advantage
+at all. Considering that its internals are not well documented and its correctness
+is not formally proven, it seems desirable to replace the queue with a mere list
+or hlist that is protected by a spinlock.
+
+Tasks:
+
+- Replace the spsc_queue in drm/sched (and those who might access the scheduler's
+  internal queue) with a spinlock + (h)list.
+- Ideally, check with some micro benchmarks and real world tests (preferably
+  with amdgpu) for relevant performance regressions.
+- Remove the spsc_queue from the kernel altogether.
+
+Contact:
+
+- Philipp Stanner <[email protected]>
+- Christian König <[email protected]>
+
+Level: Beginner
+
 Outside DRM
 ===========
 
#2 lore raw
Quoted 11 lines · Christian König
Quoted 6 lines · Philipp Stanner

drm_sched contains a lockless queue (spsc_queue) that seems to be useless and potentially unsound.

Add a TODO list entry for replacing spsc_queue with a locked list.

Pushed to drm-misc-next

Thx
P.

Quoted 57 lines
Quoted 57 lines

---
 Documentation/gpu/todo.rst | 41 ++++++++++++++++++++++++++++++++++++++

 1 file changed, 41 insertions(+)
Documentation/gpu/todo.rst +0 -0
index cdddf8db35f5..87e082b0eb48 100644
@@ -948,6 +948,47 @@ Contact: Philipp Stanner <[email protected]>


 Level: Intermediate

Documentation/gpu/todo.rst +41 -0
+Replace the lockless queue with a locked list
+---------------------------------------------
+
+drm_sched is the only user in the entire kernel of a special lockless queue, the
+spsc_queue. This queue utilizes:
+
+- preempt_disable()
+- atomic instructions
+- memory barriers
+- ACCESS_ONCE()
+
+whereas a conventional spinlock utilizes:
+
+- preempt_disable()
+- 1 atomic instruction for taking / releasing the lock
+- memory barriers
+
+Moreover, drm_sched_entity_push_job(), the only user of spsc_queue_push(), has
+to take a lock in some situations anyways and calls to it are often serialized
+with a driver lock.
+
+It is, thus, highly questionable whether the lockless queue grants any advantage
+at all. Considering that its internals are not well documented and its correctness
+is not formally proven, it seems desirable to replace the queue with a mere list
+or hlist that is protected by a spinlock.
+
+Tasks:
+
+- Replace the spsc_queue in drm/sched (and those who might access the scheduler's
+  internal queue) with a spinlock + (h)list.
+- Ideally, check with some micro benchmarks and real world tests (preferably
+  with amdgpu) for relevant performance regressions.
+- Remove the spsc_queue from the kernel altogether.
+
+Contact:
+
+- Philipp Stanner <[email protected]>
+- Christian König <[email protected]>
+
+Level: Beginner
+

 Outside DRM
 ===========