mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Use user-defined workqueue lockdep map for drm sched
@ 2024-07-31  0:31 Matthew Brost
  2024-07-31  0:31 ` [PATCH v2 1/5] workqueue: Split alloc_workqueue into internal function and lockdep init Matthew Brost
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Matthew Brost @ 2024-07-31  0:31 UTC (permalink / raw)
  To: intel-xe, dri-devel, linux-kernel
  Cc: tj, jiangshanlai, christian.koenig, ltuikov89, daniel

By default, each DRM scheduler instance creates an ordered workqueue for
submission, and each workqueue creation allocates a new lockdep map.
This becomes problematic when a DRM scheduler is created for every user
queue (e.g., in DRM drivers with firmware schedulers like Xe) due to the
limited number of available lockdep maps. With numerous user queues
being created and destroyed, lockdep may run out of maps, leading to
lockdep being disabled. Xe mitigated this by creating a pool of
workqueues for DRM scheduler use. However, this approach also encounters
issues if the driver is unloaded and reloaded multiple times or if many
VFs are probed.

To address this, we propose creating a single lockdep map for all DRM
scheduler workqueues, which will also resolve issues for other DRM
drivers that create a DRM scheduler per user queue.

This solution has been tested by unloading and reloading the Xe driver.
Before this series, around 30 driver reloads would result in lockdep
being turned off. After implementing the series, the driver can be
unloaded and reloaded hundreds of times without issues.

v2:
 - Split workqueue changes into multiple patches
 - Add alloc_workqueue_lockdep_map (Tejun)
 - Don't RFC

Matt

Matthew Brost (5):
  workqueue: Split alloc_workqueue into internal function and lockdep
    init
  workqueue: Change workqueue lockdep map to pointer
  workqueue: Add interface for user-defined workqueue lockdep map
  drm/sched: Use drm sched lockdep map for submit_wq
  drm/xe: Drop GuC submit_wq pool

 drivers/gpu/drm/scheduler/sched_main.c | 11 ++++
 drivers/gpu/drm/xe/xe_guc_submit.c     | 60 +--------------------
 drivers/gpu/drm/xe/xe_guc_types.h      |  7 ---
 include/linux/workqueue.h              | 25 +++++++++
 kernel/workqueue.c                     | 75 ++++++++++++++++++++------
 5 files changed, 97 insertions(+), 81 deletions(-)

-- 
2.34.1


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

* [PATCH v2 1/5] workqueue: Split alloc_workqueue into internal function and lockdep init
  2024-07-31  0:31 [PATCH v2 0/5] Use user-defined workqueue lockdep map for drm sched Matthew Brost
@ 2024-07-31  0:31 ` Matthew Brost
  2024-07-31  0:31 ` [PATCH v2 2/5] workqueue: Change workqueue lockdep map to pointer Matthew Brost
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Matthew Brost @ 2024-07-31  0:31 UTC (permalink / raw)
  To: intel-xe, dri-devel, linux-kernel
  Cc: tj, jiangshanlai, christian.koenig, ltuikov89, daniel

Will help enable user-defined lockdep maps for workqueues.

Cc: Tejun Heo <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 kernel/workqueue.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 3fbaecfc88c2..c9bdd6a23a2b 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5657,9 +5657,9 @@ static void wq_adjust_max_active(struct workqueue_struct *wq)
 }
 
 __printf(1, 4)
-struct workqueue_struct *alloc_workqueue(const char *fmt,
-					 unsigned int flags,
-					 int max_active, ...)
+static struct workqueue_struct *__alloc_workqueue(const char *fmt,
+						  unsigned int flags,
+						  int max_active, ...)
 {
 	va_list args;
 	struct workqueue_struct *wq;
@@ -5725,12 +5725,11 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 	INIT_LIST_HEAD(&wq->flusher_overflow);
 	INIT_LIST_HEAD(&wq->maydays);
 
-	wq_init_lockdep(wq);
 	INIT_LIST_HEAD(&wq->list);
 
 	if (flags & WQ_UNBOUND) {
 		if (alloc_node_nr_active(wq->node_nr_active) < 0)
-			goto err_unreg_lockdep;
+			goto err_free_wq;
 	}
 
 	if (alloc_and_link_pwqs(wq) < 0)
@@ -5762,9 +5761,6 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 err_free_node_nr_active:
 	if (wq->flags & WQ_UNBOUND)
 		free_node_nr_active(wq->node_nr_active);
-err_unreg_lockdep:
-	wq_unregister_lockdep(wq);
-	wq_free_lockdep(wq);
 err_free_wq:
 	free_workqueue_attrs(wq->unbound_attrs);
 	kfree(wq);
@@ -5773,6 +5769,25 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 	destroy_workqueue(wq);
 	return NULL;
 }
+
+__printf(1, 4)
+struct workqueue_struct *alloc_workqueue(const char *fmt,
+					 unsigned int flags,
+					 int max_active, ...)
+{
+	struct workqueue_struct *wq;
+	va_list args;
+
+	va_start(args, max_active);
+	wq = __alloc_workqueue(fmt, flags, max_active, args);
+	va_end(args);
+	if (!wq)
+		return NULL;
+
+	wq_init_lockdep(wq);
+
+	return wq;
+}
 EXPORT_SYMBOL_GPL(alloc_workqueue);
 
 static bool pwq_busy(struct pool_workqueue *pwq)
-- 
2.34.1


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

* [PATCH v2 2/5] workqueue: Change workqueue lockdep map to pointer
  2024-07-31  0:31 [PATCH v2 0/5] Use user-defined workqueue lockdep map for drm sched Matthew Brost
  2024-07-31  0:31 ` [PATCH v2 1/5] workqueue: Split alloc_workqueue into internal function and lockdep init Matthew Brost
@ 2024-07-31  0:31 ` Matthew Brost
  2024-07-31  0:31 ` [PATCH v2 3/5] workqueue: Add interface for user-defined workqueue lockdep map Matthew Brost
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Matthew Brost @ 2024-07-31  0:31 UTC (permalink / raw)
  To: intel-xe, dri-devel, linux-kernel
  Cc: tj, jiangshanlai, christian.koenig, ltuikov89, daniel

Will help enable user-defined lockdep maps for workqueues.

Cc: Tejun Heo <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 kernel/workqueue.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index c9bdd6a23a2b..b3fa4d044f69 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -366,7 +366,8 @@ struct workqueue_struct {
 #ifdef CONFIG_LOCKDEP
 	char			*lock_name;
 	struct lock_class_key	key;
-	struct lockdep_map	lockdep_map;
+	struct lockdep_map	__lockdep_map;
+	struct lockdep_map	*lockdep_map;
 #endif
 	char			name[WQ_NAME_LEN]; /* I: workqueue name */
 
@@ -3220,7 +3221,7 @@ __acquires(&pool->lock)
 	lockdep_start_depth = lockdep_depth(current);
 	/* see drain_dead_softirq_workfn() */
 	if (!bh_draining)
-		lock_map_acquire(&pwq->wq->lockdep_map);
+		lock_map_acquire(pwq->wq->lockdep_map);
 	lock_map_acquire(&lockdep_map);
 	/*
 	 * Strictly speaking we should mark the invariant state without holding
@@ -3254,7 +3255,7 @@ __acquires(&pool->lock)
 	pwq->stats[PWQ_STAT_COMPLETED]++;
 	lock_map_release(&lockdep_map);
 	if (!bh_draining)
-		lock_map_release(&pwq->wq->lockdep_map);
+		lock_map_release(pwq->wq->lockdep_map);
 
 	if (unlikely((worker->task && in_atomic()) ||
 		     lockdep_depth(current) != lockdep_start_depth ||
@@ -3892,8 +3893,8 @@ static void touch_wq_lockdep_map(struct workqueue_struct *wq)
 	if (wq->flags & WQ_BH)
 		local_bh_disable();
 
-	lock_map_acquire(&wq->lockdep_map);
-	lock_map_release(&wq->lockdep_map);
+	lock_map_acquire(wq->lockdep_map);
+	lock_map_release(wq->lockdep_map);
 
 	if (wq->flags & WQ_BH)
 		local_bh_enable();
@@ -3927,7 +3928,7 @@ void __flush_workqueue(struct workqueue_struct *wq)
 	struct wq_flusher this_flusher = {
 		.list = LIST_HEAD_INIT(this_flusher.list),
 		.flush_color = -1,
-		.done = COMPLETION_INITIALIZER_ONSTACK_MAP(this_flusher.done, wq->lockdep_map),
+		.done = COMPLETION_INITIALIZER_ONSTACK_MAP(this_flusher.done, (*wq->lockdep_map)),
 	};
 	int next_color;
 
@@ -4788,7 +4789,8 @@ static void wq_init_lockdep(struct workqueue_struct *wq)
 		lock_name = wq->name;
 
 	wq->lock_name = lock_name;
-	lockdep_init_map(&wq->lockdep_map, lock_name, &wq->key, 0);
+	wq->lockdep_map = &wq->__lockdep_map;
+	lockdep_init_map(wq->lockdep_map, lock_name, &wq->key, 0);
 }
 
 static void wq_unregister_lockdep(struct workqueue_struct *wq)
-- 
2.34.1


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

* [PATCH v2 3/5] workqueue: Add interface for user-defined workqueue lockdep map
  2024-07-31  0:31 [PATCH v2 0/5] Use user-defined workqueue lockdep map for drm sched Matthew Brost
  2024-07-31  0:31 ` [PATCH v2 1/5] workqueue: Split alloc_workqueue into internal function and lockdep init Matthew Brost
  2024-07-31  0:31 ` [PATCH v2 2/5] workqueue: Change workqueue lockdep map to pointer Matthew Brost
@ 2024-07-31  0:31 ` Matthew Brost
  2024-07-31  0:36   ` Tejun Heo
  2024-07-31  0:31 ` [PATCH v2 4/5] drm/sched: Use drm sched lockdep map for submit_wq Matthew Brost
  2024-07-31  0:31 ` [PATCH v2 5/5] drm/xe: Drop GuC submit_wq pool Matthew Brost
  4 siblings, 1 reply; 8+ messages in thread
From: Matthew Brost @ 2024-07-31  0:31 UTC (permalink / raw)
  To: intel-xe, dri-devel, linux-kernel
  Cc: tj, jiangshanlai, christian.koenig, ltuikov89, daniel

Add an interface for a user-defined workqueue lockdep map, which is
helpful when multiple workqueues are created for the same purpose. This
also helps avoid leaking lockdep maps on each workqueue creation.

Implement a new internal workqueue flag, __WQ_USER_OWNED_LOCKDEP, to
indicate that the user will set up the workqueue lockdep map using the
new function alloc_workqueue_lockdep_map. Also add helper macro
alloc_ordered_workqueue_lockdep_map.

v2:
 - Add alloc_workqueue_lockdep_map (Tejun)

Cc: Tejun Heo <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 include/linux/workqueue.h | 25 +++++++++++++++++++++++++
 kernel/workqueue.c        | 28 ++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index d9968bfc8eac..1707870ef7c5 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -406,6 +406,7 @@ enum wq_flags {
 	__WQ_DRAINING		= 1 << 16, /* internal: workqueue is draining */
 	__WQ_ORDERED		= 1 << 17, /* internal: workqueue is ordered */
 	__WQ_LEGACY		= 1 << 18, /* internal: create*_workqueue() */
+	__WQ_USER_OWNED_LOCKDEP	= 1 << 19, /* internal: workqueue has user owned lockdep map */
 
 	/* BH wq only allows the following flags */
 	__WQ_BH_ALLOWS		= WQ_BH | WQ_HIGHPRI,
@@ -507,6 +508,30 @@ void workqueue_softirq_dead(unsigned int cpu);
 __printf(1, 4) struct workqueue_struct *
 alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);
 
+#ifdef CONFIG_LOCKDEP
+/**
+ * alloc_workqueue_lockdep_map - allocate a workqueue with user-defined lockdep_map
+ * @fmt: printf format for the name of the workqueue
+ * @flags: WQ_* flags
+ * @max_active: max in-flight work items, 0 for default
+ * @lockdep_map: user-defined lockdep_map
+ * @...: args for @fmt
+ *
+ * Same as alloc_workqueue but with the a user-defined lockdep_map. Useful for
+ * workqueues created with the same purpose and to avoid leaking a lockdep_map
+ * on each workqueue creation.
+ *
+ * RETURNS:
+ * Pointer to the allocated workqueue on success, %NULL on failure.
+ */
+__printf(1, 5) struct workqueue_struct *
+alloc_workqueue_lockdep_map(const char *fmt, unsigned int flags, int max_active,
+			    struct lockdep_map *lockdep_map, ...);
+
+#define alloc_ordered_workqueue_lockdep_map(fmt, flags, lockdep_map, args...)	\
+	alloc_workqueue_lockdep_map(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, lockdep_map, ##args)
+#endif
+
 /**
  * alloc_ordered_workqueue - allocate an ordered workqueue
  * @fmt: printf format for the name of the workqueue
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index b3fa4d044f69..e1361dedbe06 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4795,11 +4795,17 @@ static void wq_init_lockdep(struct workqueue_struct *wq)
 
 static void wq_unregister_lockdep(struct workqueue_struct *wq)
 {
+	if (wq->flags & __WQ_USER_OWNED_LOCKDEP)
+		return;
+
 	lockdep_unregister_key(&wq->key);
 }
 
 static void wq_free_lockdep(struct workqueue_struct *wq)
 {
+	if (wq->flags & __WQ_USER_OWNED_LOCKDEP)
+		return;
+
 	if (wq->lock_name != wq->name)
 		kfree(wq->lock_name);
 }
@@ -5792,6 +5798,28 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 }
 EXPORT_SYMBOL_GPL(alloc_workqueue);
 
+#ifdef CONFIG_LOCKDEP
+__printf(1, 5)
+struct workqueue_struct *
+alloc_workqueue_lockdep_map(const char *fmt, unsigned int flags,
+			    int max_active, struct lockdep_map *lockdep_map, ...)
+{
+	struct workqueue_struct *wq;
+	va_list args;
+
+	va_start(args, lockdep_map);
+	wq = __alloc_workqueue(fmt, flags | __WQ_USER_OWNED_LOCKDEP, max_active, args);
+	va_end(args);
+	if (!wq)
+		return NULL;
+
+	wq->lockdep_map = lockdep_map;
+
+	return wq;
+}
+EXPORT_SYMBOL_GPL(alloc_workqueue_lockdep_map);
+#endif
+
 static bool pwq_busy(struct pool_workqueue *pwq)
 {
 	int i;
-- 
2.34.1


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

* [PATCH v2 4/5] drm/sched: Use drm sched lockdep map for submit_wq
  2024-07-31  0:31 [PATCH v2 0/5] Use user-defined workqueue lockdep map for drm sched Matthew Brost
                   ` (2 preceding siblings ...)
  2024-07-31  0:31 ` [PATCH v2 3/5] workqueue: Add interface for user-defined workqueue lockdep map Matthew Brost
@ 2024-07-31  0:31 ` Matthew Brost
  2024-07-31  0:31 ` [PATCH v2 5/5] drm/xe: Drop GuC submit_wq pool Matthew Brost
  4 siblings, 0 replies; 8+ messages in thread
From: Matthew Brost @ 2024-07-31  0:31 UTC (permalink / raw)
  To: intel-xe, dri-devel, linux-kernel
  Cc: tj, jiangshanlai, christian.koenig, ltuikov89, daniel

Avoid leaking a lockdep map on each drm sched creation and destruction
by using a single lockdep map for all drm sched allocated submit_wq.

v2:
 - Use alloc_ordered_workqueue_lockdep_map (Tejun)

Cc: Luben Tuikov <ltuikov89@gmail.com>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/scheduler/sched_main.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index ab53ab486fe6..cf79d348cb32 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -87,6 +87,12 @@
 #define CREATE_TRACE_POINTS
 #include "gpu_scheduler_trace.h"
 
+#ifdef CONFIG_LOCKDEP
+static struct lockdep_map drm_sched_lockdep_map = {
+	.name = "drm_sched_lockdep_map"
+};
+#endif
+
 #define to_drm_sched_job(sched_job)		\
 		container_of((sched_job), struct drm_sched_job, queue_node)
 
@@ -1272,7 +1278,12 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
 		sched->submit_wq = submit_wq;
 		sched->own_submit_wq = false;
 	} else {
+#ifdef CONFIG_LOCKDEP
+		sched->submit_wq = alloc_ordered_workqueue_lockdep_map(name, 0,
+								       &drm_sched_lockdep_map);
+#else
 		sched->submit_wq = alloc_ordered_workqueue(name, 0);
+#endif
 		if (!sched->submit_wq)
 			return -ENOMEM;
 
-- 
2.34.1


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

* [PATCH v2 5/5] drm/xe: Drop GuC submit_wq pool
  2024-07-31  0:31 [PATCH v2 0/5] Use user-defined workqueue lockdep map for drm sched Matthew Brost
                   ` (3 preceding siblings ...)
  2024-07-31  0:31 ` [PATCH v2 4/5] drm/sched: Use drm sched lockdep map for submit_wq Matthew Brost
@ 2024-07-31  0:31 ` Matthew Brost
  4 siblings, 0 replies; 8+ messages in thread
From: Matthew Brost @ 2024-07-31  0:31 UTC (permalink / raw)
  To: intel-xe, dri-devel, linux-kernel
  Cc: tj, jiangshanlai, christian.koenig, ltuikov89, daniel

Now that drm sched uses a single lockdep map for all submit_wq, drop the
GuC submit_wq pool hack.

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_guc_submit.c | 60 +-----------------------------
 drivers/gpu/drm/xe/xe_guc_types.h  |  7 ----
 2 files changed, 1 insertion(+), 66 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 460808507947..882cef3a10dc 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -224,64 +224,11 @@ static bool exec_queue_killed_or_banned_or_wedged(struct xe_exec_queue *q)
 		 EXEC_QUEUE_STATE_BANNED));
 }
 
-#ifdef CONFIG_PROVE_LOCKING
-static int alloc_submit_wq(struct xe_guc *guc)
-{
-	int i;
-
-	for (i = 0; i < NUM_SUBMIT_WQ; ++i) {
-		guc->submission_state.submit_wq_pool[i] =
-			alloc_ordered_workqueue("submit_wq", 0);
-		if (!guc->submission_state.submit_wq_pool[i])
-			goto err_free;
-	}
-
-	return 0;
-
-err_free:
-	while (i)
-		destroy_workqueue(guc->submission_state.submit_wq_pool[--i]);
-
-	return -ENOMEM;
-}
-
-static void free_submit_wq(struct xe_guc *guc)
-{
-	int i;
-
-	for (i = 0; i < NUM_SUBMIT_WQ; ++i)
-		destroy_workqueue(guc->submission_state.submit_wq_pool[i]);
-}
-
-static struct workqueue_struct *get_submit_wq(struct xe_guc *guc)
-{
-	int idx = guc->submission_state.submit_wq_idx++ % NUM_SUBMIT_WQ;
-
-	return guc->submission_state.submit_wq_pool[idx];
-}
-#else
-static int alloc_submit_wq(struct xe_guc *guc)
-{
-	return 0;
-}
-
-static void free_submit_wq(struct xe_guc *guc)
-{
-
-}
-
-static struct workqueue_struct *get_submit_wq(struct xe_guc *guc)
-{
-	return NULL;
-}
-#endif
-
 static void guc_submit_fini(struct drm_device *drm, void *arg)
 {
 	struct xe_guc *guc = arg;
 
 	xa_destroy(&guc->submission_state.exec_queue_lookup);
-	free_submit_wq(guc);
 }
 
 static void guc_submit_wedged_fini(struct drm_device *drm, void *arg)
@@ -337,10 +284,6 @@ int xe_guc_submit_init(struct xe_guc *guc, unsigned int num_ids)
 	if (err)
 		return err;
 
-	err = alloc_submit_wq(guc);
-	if (err)
-		return err;
-
 	gt->exec_queue_ops = &guc_exec_queue_ops;
 
 	xa_init(&guc->submission_state.exec_queue_lookup);
@@ -1445,8 +1388,7 @@ static int guc_exec_queue_init(struct xe_exec_queue *q)
 	timeout = (q->vm && xe_vm_in_lr_mode(q->vm)) ? MAX_SCHEDULE_TIMEOUT :
 		  msecs_to_jiffies(q->sched_props.job_timeout_ms);
 	err = xe_sched_init(&ge->sched, &drm_sched_ops, &xe_sched_ops,
-			    get_submit_wq(guc),
-			    q->lrc[0]->ring.size / MAX_JOB_SIZE_BYTES, 64,
+			    NULL, q->lrc[0]->ring.size / MAX_JOB_SIZE_BYTES, 64,
 			    timeout, guc_to_gt(guc)->ordered_wq, NULL,
 			    q->name, gt_to_xe(q->gt)->drm.dev);
 	if (err)
diff --git a/drivers/gpu/drm/xe/xe_guc_types.h b/drivers/gpu/drm/xe/xe_guc_types.h
index 546ac6350a31..585f5c274f09 100644
--- a/drivers/gpu/drm/xe/xe_guc_types.h
+++ b/drivers/gpu/drm/xe/xe_guc_types.h
@@ -72,13 +72,6 @@ struct xe_guc {
 		atomic_t stopped;
 		/** @submission_state.lock: protects submission state */
 		struct mutex lock;
-#ifdef CONFIG_PROVE_LOCKING
-#define NUM_SUBMIT_WQ	256
-		/** @submission_state.submit_wq_pool: submission ordered workqueues pool */
-		struct workqueue_struct *submit_wq_pool[NUM_SUBMIT_WQ];
-		/** @submission_state.submit_wq_idx: submission ordered workqueue index */
-		int submit_wq_idx;
-#endif
 		/** @submission_state.enabled: submission is enabled */
 		bool enabled;
 	} submission_state;
-- 
2.34.1


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

* Re: [PATCH v2 3/5] workqueue: Add interface for user-defined workqueue lockdep map
  2024-07-31  0:31 ` [PATCH v2 3/5] workqueue: Add interface for user-defined workqueue lockdep map Matthew Brost
@ 2024-07-31  0:36   ` Tejun Heo
  2024-07-31  1:15     ` Matthew Brost
  0 siblings, 1 reply; 8+ messages in thread
From: Tejun Heo @ 2024-07-31  0:36 UTC (permalink / raw)
  To: Matthew Brost
  Cc: intel-xe, dri-devel, linux-kernel, jiangshanlai,
	christian.koenig, ltuikov89, daniel

Hello,

On Tue, Jul 30, 2024 at 05:31:17PM -0700, Matthew Brost wrote:
> +#define alloc_ordered_workqueue_lockdep_map(fmt, flags, lockdep_map, args...)	\
> +	alloc_workqueue_lockdep_map(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, lockdep_map, ##args)
> +#endif

alloc_ordered_workqueue() is a macro too but would you mind making this an
inline function?

> @@ -4795,11 +4795,17 @@ static void wq_init_lockdep(struct workqueue_struct *wq)
>  
>  static void wq_unregister_lockdep(struct workqueue_struct *wq)
>  {
> +	if (wq->flags & __WQ_USER_OWNED_LOCKDEP)
> +		return;

Do you still need the flag? Can't you test wq->lockdep_map !=
&wq->__lockdep_map instead?

Thanks.

-- 
tejun

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

* Re: [PATCH v2 3/5] workqueue: Add interface for user-defined workqueue lockdep map
  2024-07-31  0:36   ` Tejun Heo
@ 2024-07-31  1:15     ` Matthew Brost
  0 siblings, 0 replies; 8+ messages in thread
From: Matthew Brost @ 2024-07-31  1:15 UTC (permalink / raw)
  To: Tejun Heo
  Cc: intel-xe, dri-devel, linux-kernel, jiangshanlai,
	christian.koenig, ltuikov89, daniel

On Tue, Jul 30, 2024 at 02:36:13PM -1000, Tejun Heo wrote:
> Hello,
> 
> On Tue, Jul 30, 2024 at 05:31:17PM -0700, Matthew Brost wrote:
> > +#define alloc_ordered_workqueue_lockdep_map(fmt, flags, lockdep_map, args...)	\
> > +	alloc_workqueue_lockdep_map(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, lockdep_map, ##args)
> > +#endif
> 
> alloc_ordered_workqueue() is a macro too but would you mind making this an
> inline function?
> 

Not at all.

> > @@ -4795,11 +4795,17 @@ static void wq_init_lockdep(struct workqueue_struct *wq)
> >  
> >  static void wq_unregister_lockdep(struct workqueue_struct *wq)
> >  {
> > +	if (wq->flags & __WQ_USER_OWNED_LOCKDEP)
> > +		return;
> 
> Do you still need the flag? Can't you test wq->lockdep_map !=
> &wq->__lockdep_map instead?
>

Ah, yes. That is better. Will change.

Matt
 
> Thanks.
> 
> -- 
> tejun

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

end of thread, other threads:[~2024-07-31  1:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-31  0:31 [PATCH v2 0/5] Use user-defined workqueue lockdep map for drm sched Matthew Brost
2024-07-31  0:31 ` [PATCH v2 1/5] workqueue: Split alloc_workqueue into internal function and lockdep init Matthew Brost
2024-07-31  0:31 ` [PATCH v2 2/5] workqueue: Change workqueue lockdep map to pointer Matthew Brost
2024-07-31  0:31 ` [PATCH v2 3/5] workqueue: Add interface for user-defined workqueue lockdep map Matthew Brost
2024-07-31  0:36   ` Tejun Heo
2024-07-31  1:15     ` Matthew Brost
2024-07-31  0:31 ` [PATCH v2 4/5] drm/sched: Use drm sched lockdep map for submit_wq Matthew Brost
2024-07-31  0:31 ` [PATCH v2 5/5] drm/xe: Drop GuC submit_wq pool Matthew Brost

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

all inboxes | Powered by JetHome®