mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] replace system_unbound_wq, add WQ_PERCPU to alloc_workqueue
@ 2025-11-03 17:06 Marco Crivellari
  2025-11-03 17:06 ` [PATCH v2 1/2] drm/xe: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Marco Crivellari @ 2025-11-03 17:06 UTC (permalink / raw)
  To: linux-kernel, intel-xe, dri-devel
  Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
	Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
	Lucas De Marchi, Thomas Hellstrom, Rodrigo Vivi, David Airlie,
	Simona Vetter

Hi,

=== Current situation: problems ===

Let's consider a nohz_full system with isolated CPUs: wq_unbound_cpumask is
set to the housekeeping CPUs, for !WQ_UNBOUND the local CPU is selected.

This leads to different scenarios if a work item is scheduled on an
isolated CPU where "delay" value is 0 or greater then 0:
        schedule_delayed_work(, 0);

This will be handled by __queue_work() that will queue the work item on the
current local (isolated) CPU, while:

        schedule_delayed_work(, 1);

Will move the timer on an housekeeping CPU, and schedule the work there.

Currently if a user enqueue a work item using schedule_delayed_work() the
used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use
WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to
schedule_work() that is using system_wq and queue_work(), that makes use
again of WORK_CPU_UNBOUND.

This lack of consistency cannot be addressed without refactoring the API.

=== Recent changes to the WQ API ===

The following, address the recent changes in the Workqueue API:

- commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq")
- commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

The old workqueues will be removed in a future release cycle.

=== Introduced Changes by this series ===

1) [P 1]  Replace uses of system_unbound_wq

    system_unbound_wq is to be used when locality is not required.

    Because of that, system_unbound_wq has been replaced with
	system_dfl_wq, to make sure this would be the default choice
	when locality is not important.

	system_dfl_wq behave like system_unbound_wq.

2) [P 2] add WQ_PERCPU to alloc_workqueue()

    This change adds a new WQ_PERCPU flag to explicitly request
    alloc_workqueue() to be per-cpu when WQ_UNBOUND has not been specified.

	The behavior is the same.

Thanks!


---
Changes in v2:
- rebased on v6.18-rc4.

- commit logs integrated with the appropriate workqueue API commit hash.


Marco Crivellari (2):
  drm/xe: replace use of system_unbound_wq with system_dfl_wq
  drm/xe: add WQ_PERCPU to alloc_workqueue users

 drivers/gpu/drm/xe/xe_devcoredump.c     | 2 +-
 drivers/gpu/drm/xe/xe_device.c          | 4 ++--
 drivers/gpu/drm/xe/xe_execlist.c        | 2 +-
 drivers/gpu/drm/xe/xe_ggtt.c            | 2 +-
 drivers/gpu/drm/xe/xe_guc_ct.c          | 4 ++--
 drivers/gpu/drm/xe/xe_hw_engine_group.c | 3 ++-
 drivers/gpu/drm/xe/xe_oa.c              | 2 +-
 drivers/gpu/drm/xe/xe_sriov.c           | 2 +-
 drivers/gpu/drm/xe/xe_vm.c              | 4 ++--
 9 files changed, 13 insertions(+), 12 deletions(-)

-- 
2.51.1


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

* [PATCH v2 1/2] drm/xe: replace use of system_unbound_wq with system_dfl_wq
  2025-11-03 17:06 [PATCH v2 0/2] replace system_unbound_wq, add WQ_PERCPU to alloc_workqueue Marco Crivellari
@ 2025-11-03 17:06 ` Marco Crivellari
  2026-01-08 13:28   ` Rodrigo Vivi
  2025-11-03 17:06 ` [PATCH v2 2/2] drm/xe: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
  2025-12-24 14:51 ` [PATCH v2 0/2] replace system_unbound_wq, add WQ_PERCPU to alloc_workqueue Marco Crivellari
  2 siblings, 1 reply; 8+ messages in thread
From: Marco Crivellari @ 2025-11-03 17:06 UTC (permalink / raw)
  To: linux-kernel, intel-xe, dri-devel
  Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
	Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
	Lucas De Marchi, Thomas Hellstrom, Rodrigo Vivi, David Airlie,
	Simona Vetter

Currently if a user enqueue a work item using schedule_delayed_work() the
used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use
WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to
schedule_work() that is using system_wq and queue_work(), that makes use
again of WORK_CPU_UNBOUND.

This lack of consistency cannot be addressed without refactoring the API.

The above change to the Workqueue API has been introduced by:

commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq")

system_unbound_wq should be the default workqueue so as not to enforce
locality constraints for random work whenever it's not required.

The old system_unbound_wq will be kept for a few release cycles.

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
 drivers/gpu/drm/xe/xe_devcoredump.c | 2 +-
 drivers/gpu/drm/xe/xe_execlist.c    | 2 +-
 drivers/gpu/drm/xe/xe_guc_ct.c      | 4 ++--
 drivers/gpu/drm/xe/xe_oa.c          | 2 +-
 drivers/gpu/drm/xe/xe_vm.c          | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
index 203e3038cc81..806335487021 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump.c
+++ b/drivers/gpu/drm/xe/xe_devcoredump.c
@@ -362,7 +362,7 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
 
 	xe_engine_snapshot_capture_for_queue(q);
 
-	queue_work(system_unbound_wq, &ss->work);
+	queue_work(system_dfl_wq, &ss->work);
 
 	xe_force_wake_put(gt_to_fw(q->gt), fw_ref);
 	dma_fence_end_signalling(cookie);
diff --git a/drivers/gpu/drm/xe/xe_execlist.c b/drivers/gpu/drm/xe/xe_execlist.c
index f83d421ac9d3..99010709f0d2 100644
--- a/drivers/gpu/drm/xe/xe_execlist.c
+++ b/drivers/gpu/drm/xe/xe_execlist.c
@@ -422,7 +422,7 @@ static void execlist_exec_queue_kill(struct xe_exec_queue *q)
 static void execlist_exec_queue_destroy(struct xe_exec_queue *q)
 {
 	INIT_WORK(&q->execlist->destroy_async, execlist_exec_queue_destroy_async);
-	queue_work(system_unbound_wq, &q->execlist->destroy_async);
+	queue_work(system_dfl_wq, &q->execlist->destroy_async);
 }
 
 static int execlist_exec_queue_set_priority(struct xe_exec_queue *q,
diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
index 18f6327bf552..bc2ec3603e7b 100644
--- a/drivers/gpu/drm/xe/xe_guc_ct.c
+++ b/drivers/gpu/drm/xe/xe_guc_ct.c
@@ -543,7 +543,7 @@ int xe_guc_ct_enable(struct xe_guc_ct *ct)
 	spin_lock_irq(&ct->dead.lock);
 	if (ct->dead.reason) {
 		ct->dead.reason |= (1 << CT_DEAD_STATE_REARM);
-		queue_work(system_unbound_wq, &ct->dead.worker);
+		queue_work(system_dfl_wq, &ct->dead.worker);
 	}
 	spin_unlock_irq(&ct->dead.lock);
 #endif
@@ -2186,7 +2186,7 @@ static void ct_dead_capture(struct xe_guc_ct *ct, struct guc_ctb *ctb, u32 reaso
 
 	spin_unlock_irqrestore(&ct->dead.lock, flags);
 
-	queue_work(system_unbound_wq, &(ct)->dead.worker);
+	queue_work(system_dfl_wq, &(ct)->dead.worker);
 }
 
 static void ct_dead_print(struct xe_dead_ct *dead)
diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index a4894eb0d7f3..4e362cd43d51 100644
--- a/drivers/gpu/drm/xe/xe_oa.c
+++ b/drivers/gpu/drm/xe/xe_oa.c
@@ -967,7 +967,7 @@ static void xe_oa_config_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
 	struct xe_oa_fence *ofence = container_of(cb, typeof(*ofence), cb);
 
 	INIT_DELAYED_WORK(&ofence->work, xe_oa_fence_work_fn);
-	queue_delayed_work(system_unbound_wq, &ofence->work,
+	queue_delayed_work(system_dfl_wq, &ofence->work,
 			   usecs_to_jiffies(NOA_PROGRAM_ADDITIONAL_DELAY_US));
 	dma_fence_put(fence);
 }
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 63c65e3d207b..d3a0e0231cd1 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -1064,7 +1064,7 @@ static void vma_destroy_cb(struct dma_fence *fence,
 	struct xe_vma *vma = container_of(cb, struct xe_vma, destroy_cb);
 
 	INIT_WORK(&vma->destroy_work, vma_destroy_work_func);
-	queue_work(system_unbound_wq, &vma->destroy_work);
+	queue_work(system_dfl_wq, &vma->destroy_work);
 }
 
 static void xe_vma_destroy(struct xe_vma *vma, struct dma_fence *fence)
@@ -1823,7 +1823,7 @@ static void xe_vm_free(struct drm_gpuvm *gpuvm)
 	struct xe_vm *vm = container_of(gpuvm, struct xe_vm, gpuvm);
 
 	/* To destroy the VM we need to be able to sleep */
-	queue_work(system_unbound_wq, &vm->destroy_work);
+	queue_work(system_dfl_wq, &vm->destroy_work);
 }
 
 struct xe_vm *xe_vm_lookup(struct xe_file *xef, u32 id)
-- 
2.51.1


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

* [PATCH v2 2/2] drm/xe: add WQ_PERCPU to alloc_workqueue users
  2025-11-03 17:06 [PATCH v2 0/2] replace system_unbound_wq, add WQ_PERCPU to alloc_workqueue Marco Crivellari
  2025-11-03 17:06 ` [PATCH v2 1/2] drm/xe: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
@ 2025-11-03 17:06 ` Marco Crivellari
  2026-01-08 16:53   ` Marco Crivellari
  2025-12-24 14:51 ` [PATCH v2 0/2] replace system_unbound_wq, add WQ_PERCPU to alloc_workqueue Marco Crivellari
  2 siblings, 1 reply; 8+ messages in thread
From: Marco Crivellari @ 2025-11-03 17:06 UTC (permalink / raw)
  To: linux-kernel, intel-xe, dri-devel
  Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
	Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
	Lucas De Marchi, Thomas Hellstrom, Rodrigo Vivi, David Airlie,
	Simona Vetter

Currently if a user enqueue a work item using schedule_delayed_work() the
used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use
WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to
schedule_work() that is using system_wq and queue_work(), that makes use
again of WORK_CPU_UNBOUND.
This lack of consistentcy cannot be addressed without refactoring the API.

The above change to the Workqueue API has been introduced by:

commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

alloc_workqueue() treats all queues as per-CPU by default, while unbound
workqueues must opt-in via WQ_UNBOUND.

This default is suboptimal: most workloads benefit from unbound queues,
allowing the scheduler to place worker threads where they’re needed and
reducing noise when CPUs are isolated.

This change adds a new WQ_PERCPU flag to explicitly request
alloc_workqueue() to be per-cpu when WQ_UNBOUND has not been specified.

With the introduction of the WQ_PERCPU flag (equivalent to !WQ_UNBOUND),
any alloc_workqueue() caller that doesn’t explicitly specify WQ_UNBOUND
must now use WQ_PERCPU.

Once migration is complete, WQ_UNBOUND can be removed and unbound will
become the implicit default.

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
 drivers/gpu/drm/xe/xe_device.c          | 4 ++--
 drivers/gpu/drm/xe/xe_ggtt.c            | 2 +-
 drivers/gpu/drm/xe/xe_hw_engine_group.c | 3 ++-
 drivers/gpu/drm/xe/xe_sriov.c           | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 34d33965eac2..38b42d4f930f 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -486,8 +486,8 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
 	xe->preempt_fence_wq = alloc_ordered_workqueue("xe-preempt-fence-wq",
 						       WQ_MEM_RECLAIM);
 	xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq", 0);
-	xe->unordered_wq = alloc_workqueue("xe-unordered-wq", 0, 0);
-	xe->destroy_wq = alloc_workqueue("xe-destroy-wq", 0, 0);
+	xe->unordered_wq = alloc_workqueue("xe-unordered-wq", WQ_PERCPU, 0);
+	xe->destroy_wq = alloc_workqueue("xe-destroy-wq", WQ_PERCPU, 0);
 	if (!xe->ordered_wq || !xe->unordered_wq ||
 	    !xe->preempt_fence_wq || !xe->destroy_wq) {
 		/*
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 5edc0cad47e2..566163ab96ae 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -291,7 +291,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
 	else
 		ggtt->pt_ops = &xelp_pt_ops;
 
-	ggtt->wq = alloc_workqueue("xe-ggtt-wq", 0, WQ_MEM_RECLAIM);
+	ggtt->wq = alloc_workqueue("xe-ggtt-wq", WQ_PERCPU, WQ_MEM_RECLAIM);
 	if (!ggtt->wq)
 		return -ENOMEM;
 
diff --git a/drivers/gpu/drm/xe/xe_hw_engine_group.c b/drivers/gpu/drm/xe/xe_hw_engine_group.c
index fa4db5f23342..8526addcdf42 100644
--- a/drivers/gpu/drm/xe/xe_hw_engine_group.c
+++ b/drivers/gpu/drm/xe/xe_hw_engine_group.c
@@ -48,7 +48,8 @@ hw_engine_group_alloc(struct xe_device *xe)
 	if (!group)
 		return ERR_PTR(-ENOMEM);
 
-	group->resume_wq = alloc_workqueue("xe-resume-lr-jobs-wq", 0, 0);
+	group->resume_wq = alloc_workqueue("xe-resume-lr-jobs-wq", WQ_PERCPU,
+					   0);
 	if (!group->resume_wq)
 		return ERR_PTR(-ENOMEM);
 
diff --git a/drivers/gpu/drm/xe/xe_sriov.c b/drivers/gpu/drm/xe/xe_sriov.c
index 7d2d6de2aabf..5c36da17f745 100644
--- a/drivers/gpu/drm/xe/xe_sriov.c
+++ b/drivers/gpu/drm/xe/xe_sriov.c
@@ -120,7 +120,7 @@ int xe_sriov_init(struct xe_device *xe)
 		xe_sriov_vf_init_early(xe);
 
 	xe_assert(xe, !xe->sriov.wq);
-	xe->sriov.wq = alloc_workqueue("xe-sriov-wq", 0, 0);
+	xe->sriov.wq = alloc_workqueue("xe-sriov-wq", WQ_PERCPU, 0);
 	if (!xe->sriov.wq)
 		return -ENOMEM;
 
-- 
2.51.1


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

* Re: [PATCH v2 0/2] replace system_unbound_wq, add WQ_PERCPU to alloc_workqueue
  2025-11-03 17:06 [PATCH v2 0/2] replace system_unbound_wq, add WQ_PERCPU to alloc_workqueue Marco Crivellari
  2025-11-03 17:06 ` [PATCH v2 1/2] drm/xe: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
  2025-11-03 17:06 ` [PATCH v2 2/2] drm/xe: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
@ 2025-12-24 14:51 ` Marco Crivellari
  2 siblings, 0 replies; 8+ messages in thread
From: Marco Crivellari @ 2025-12-24 14:51 UTC (permalink / raw)
  To: linux-kernel, intel-xe, dri-devel
  Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
	Sebastian Andrzej Siewior, Michal Hocko, Lucas De Marchi,
	Thomas Hellstrom, Rodrigo Vivi, David Airlie, Simona Vetter

On Mon, Nov 3, 2025 at 6:06 PM Marco Crivellari
<marco.crivellari@suse.com> wrote:
> Marco Crivellari (2):
>   drm/xe: replace use of system_unbound_wq with system_dfl_wq
>   drm/xe: add WQ_PERCPU to alloc_workqueue users
>
>  drivers/gpu/drm/xe/xe_devcoredump.c     | 2 +-
>  drivers/gpu/drm/xe/xe_device.c          | 4 ++--
>  drivers/gpu/drm/xe/xe_execlist.c        | 2 +-
>  drivers/gpu/drm/xe/xe_ggtt.c            | 2 +-
>  drivers/gpu/drm/xe/xe_guc_ct.c          | 4 ++--
>  drivers/gpu/drm/xe/xe_hw_engine_group.c | 3 ++-
>  drivers/gpu/drm/xe/xe_oa.c              | 2 +-
>  drivers/gpu/drm/xe/xe_sriov.c           | 2 +-
>  drivers/gpu/drm/xe/xe_vm.c              | 4 ++--
>  9 files changed, 13 insertions(+), 12 deletions(-)
>

Gentle ping.

Thanks!

-- 

Marco Crivellari

L3 Support Engineer

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

* Re: [PATCH v2 1/2] drm/xe: replace use of system_unbound_wq with system_dfl_wq
  2025-11-03 17:06 ` [PATCH v2 1/2] drm/xe: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
@ 2026-01-08 13:28   ` Rodrigo Vivi
  2026-01-08 13:45     ` Marco Crivellari
  0 siblings, 1 reply; 8+ messages in thread
From: Rodrigo Vivi @ 2026-01-08 13:28 UTC (permalink / raw)
  To: Marco Crivellari
  Cc: linux-kernel, intel-xe, dri-devel, Tejun Heo, Lai Jiangshan,
	Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
	Lucas De Marchi, Thomas Hellstrom, David Airlie, Simona Vetter

On Mon, Nov 03, 2025 at 06:06:03PM +0100, Marco Crivellari wrote:
> Currently if a user enqueue a work item using schedule_delayed_work() the
> used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use
> WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to
> schedule_work() that is using system_wq and queue_work(), that makes use
> again of WORK_CPU_UNBOUND.
> 
> This lack of consistency cannot be addressed without refactoring the API.
> 
> The above change to the Workqueue API has been introduced by:
> 
> commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq")
> 
> system_unbound_wq should be the default workqueue so as not to enforce
> locality constraints for random work whenever it's not required.
> 
> The old system_unbound_wq will be kept for a few release cycles.

I'm sorry for the delay here, but could you please refactor this commit
message?

The first part of this commit message is the true justification for your
original work, not for this patch here.

Except for your last phrase, which indicates, some wish of removing
the unbound_wq, it doesn't state clear on why we should change the
unbound per the dfl (default?).

Perhaps the authors of these cases below wanted to be unbound,
but choosing the default will make us to be tied to whatever
default might become in the future.

Right now both unbound and dfl are identical. In the future
you are planning to remove the unbound, but what about the dfl?
Any plans or possible changes? If no change is planned to dfl,
why create default and simply not stay with the unbound one
that is much more clear on its intention?

Thanks,
Rodrigo.

> 
> Suggested-by: Tejun Heo <tj@kernel.org>
> Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
> ---
>  drivers/gpu/drm/xe/xe_devcoredump.c | 2 +-
>  drivers/gpu/drm/xe/xe_execlist.c    | 2 +-
>  drivers/gpu/drm/xe/xe_guc_ct.c      | 4 ++--
>  drivers/gpu/drm/xe/xe_oa.c          | 2 +-
>  drivers/gpu/drm/xe/xe_vm.c          | 4 ++--
>  5 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
> index 203e3038cc81..806335487021 100644
> --- a/drivers/gpu/drm/xe/xe_devcoredump.c
> +++ b/drivers/gpu/drm/xe/xe_devcoredump.c
> @@ -362,7 +362,7 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
>  
>  	xe_engine_snapshot_capture_for_queue(q);
>  
> -	queue_work(system_unbound_wq, &ss->work);
> +	queue_work(system_dfl_wq, &ss->work);
>  
>  	xe_force_wake_put(gt_to_fw(q->gt), fw_ref);
>  	dma_fence_end_signalling(cookie);
> diff --git a/drivers/gpu/drm/xe/xe_execlist.c b/drivers/gpu/drm/xe/xe_execlist.c
> index f83d421ac9d3..99010709f0d2 100644
> --- a/drivers/gpu/drm/xe/xe_execlist.c
> +++ b/drivers/gpu/drm/xe/xe_execlist.c
> @@ -422,7 +422,7 @@ static void execlist_exec_queue_kill(struct xe_exec_queue *q)
>  static void execlist_exec_queue_destroy(struct xe_exec_queue *q)
>  {
>  	INIT_WORK(&q->execlist->destroy_async, execlist_exec_queue_destroy_async);
> -	queue_work(system_unbound_wq, &q->execlist->destroy_async);
> +	queue_work(system_dfl_wq, &q->execlist->destroy_async);
>  }
>  
>  static int execlist_exec_queue_set_priority(struct xe_exec_queue *q,
> diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
> index 18f6327bf552..bc2ec3603e7b 100644
> --- a/drivers/gpu/drm/xe/xe_guc_ct.c
> +++ b/drivers/gpu/drm/xe/xe_guc_ct.c
> @@ -543,7 +543,7 @@ int xe_guc_ct_enable(struct xe_guc_ct *ct)
>  	spin_lock_irq(&ct->dead.lock);
>  	if (ct->dead.reason) {
>  		ct->dead.reason |= (1 << CT_DEAD_STATE_REARM);
> -		queue_work(system_unbound_wq, &ct->dead.worker);
> +		queue_work(system_dfl_wq, &ct->dead.worker);
>  	}
>  	spin_unlock_irq(&ct->dead.lock);
>  #endif
> @@ -2186,7 +2186,7 @@ static void ct_dead_capture(struct xe_guc_ct *ct, struct guc_ctb *ctb, u32 reaso
>  
>  	spin_unlock_irqrestore(&ct->dead.lock, flags);
>  
> -	queue_work(system_unbound_wq, &(ct)->dead.worker);
> +	queue_work(system_dfl_wq, &(ct)->dead.worker);
>  }
>  
>  static void ct_dead_print(struct xe_dead_ct *dead)
> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> index a4894eb0d7f3..4e362cd43d51 100644
> --- a/drivers/gpu/drm/xe/xe_oa.c
> +++ b/drivers/gpu/drm/xe/xe_oa.c
> @@ -967,7 +967,7 @@ static void xe_oa_config_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
>  	struct xe_oa_fence *ofence = container_of(cb, typeof(*ofence), cb);
>  
>  	INIT_DELAYED_WORK(&ofence->work, xe_oa_fence_work_fn);
> -	queue_delayed_work(system_unbound_wq, &ofence->work,
> +	queue_delayed_work(system_dfl_wq, &ofence->work,
>  			   usecs_to_jiffies(NOA_PROGRAM_ADDITIONAL_DELAY_US));
>  	dma_fence_put(fence);
>  }
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index 63c65e3d207b..d3a0e0231cd1 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -1064,7 +1064,7 @@ static void vma_destroy_cb(struct dma_fence *fence,
>  	struct xe_vma *vma = container_of(cb, struct xe_vma, destroy_cb);
>  
>  	INIT_WORK(&vma->destroy_work, vma_destroy_work_func);
> -	queue_work(system_unbound_wq, &vma->destroy_work);
> +	queue_work(system_dfl_wq, &vma->destroy_work);
>  }
>  
>  static void xe_vma_destroy(struct xe_vma *vma, struct dma_fence *fence)
> @@ -1823,7 +1823,7 @@ static void xe_vm_free(struct drm_gpuvm *gpuvm)
>  	struct xe_vm *vm = container_of(gpuvm, struct xe_vm, gpuvm);
>  
>  	/* To destroy the VM we need to be able to sleep */
> -	queue_work(system_unbound_wq, &vm->destroy_work);
> +	queue_work(system_dfl_wq, &vm->destroy_work);
>  }
>  
>  struct xe_vm *xe_vm_lookup(struct xe_file *xef, u32 id)
> -- 
> 2.51.1
> 

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

* Re: [PATCH v2 1/2] drm/xe: replace use of system_unbound_wq with system_dfl_wq
  2026-01-08 13:28   ` Rodrigo Vivi
@ 2026-01-08 13:45     ` Marco Crivellari
  2026-01-08 14:13       ` Vivi, Rodrigo
  0 siblings, 1 reply; 8+ messages in thread
From: Marco Crivellari @ 2026-01-08 13:45 UTC (permalink / raw)
  To: Rodrigo Vivi
  Cc: linux-kernel, intel-xe, dri-devel, Tejun Heo, Lai Jiangshan,
	Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
	Lucas De Marchi, Thomas Hellstrom, David Airlie, Simona Vetter

On Thu, Jan 8, 2026 at 2:29 PM Rodrigo Vivi <rodrigo.vivi@intel.com> wrote:
> I'm sorry for the delay here, but could you please refactor this commit
> message?
>
> The first part of this commit message is the true justification for your
> original work, not for this patch here.

Hi Rodrigo,

Sure, I already have a new version of it:

---

This patch continues the effort to refactor workqueue APIs, which has begun
with the changes introducing new workqueues and a new alloc_workqueue flag:

   commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq")
   commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

The point of the refactoring is to eventually alter the default behavior of
workqueues to become unbound by default so that their workload placement is
optimized by the scheduler.

Before that to happen, workqueue users must be converted to the better named
new workqueues with no intended behaviour changes:

   system_wq -> system_percpu_wq
   system_unbound_wq -> system_dfl_wq

This way the old obsolete workqueues (system_wq, system_unbound_wq) can be
removed in the future.


> Except for your last phrase, which indicates, some wish of removing
> the unbound_wq, it doesn't state clear on why we should change the
> unbound per the dfl (default?).
>
> Perhaps the authors of these cases below wanted to be unbound,
> but choosing the default will make us to be tied to whatever
> default might become in the future.
>
> Right now both unbound and dfl are identical. In the future
> you are planning to remove the unbound, but what about the dfl?
> Any plans or possible changes? If no change is planned to dfl,
> why create default and simply not stay with the unbound one
> that is much more clear on its intention?

Yes, "dfl" is "default".

With the new version above I think it is clear, but in short: the rename
is needed as a first refactoring step; the plan is to have an unbound workqueue
as default.

system_unbound_wq will be removed and changed with system_dfl_wq.
system_dfl_wq is the new unbound workqueue, it works exactly the same as
system_unbound_wq.

system_wq will be replaced with system_percpu_wq; same thing as above,
no behavioral changes, system_percpu_wq is the new per-cpu workqueue.

This is to make clear that if a per-cpu workqueue is not needed, the correct
choice is system_dfl_wq.

Also, during this conversion phase, I can tell many subsystems asked to
change system_wq (the name of the "old" per-cpu workqueue) with
system_dfl_wq, because they just wanted to use a system workqueue and
thought system_wq was already the unbound one.

All of this work has been discussed here:

https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/

I will add this Link to the above commit log. Let me know if it sounds good.

Thanks!

-- 

Marco Crivellari

L3 Support Engineer

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

* Re: [PATCH v2 1/2] drm/xe: replace use of system_unbound_wq with system_dfl_wq
  2026-01-08 13:45     ` Marco Crivellari
@ 2026-01-08 14:13       ` Vivi, Rodrigo
  0 siblings, 0 replies; 8+ messages in thread
From: Vivi, Rodrigo @ 2026-01-08 14:13 UTC (permalink / raw)
  To: marco.crivellari
  Cc: intel-xe, airlied, tj, mhocko, simona, dri-devel, frederic,
	jiangshanlai, linux-kernel, bigeasy, lucas.demarchi,
	thomas.hellstrom

On Thu, 2026-01-08 at 14:45 +0100, Marco Crivellari wrote:
> On Thu, Jan 8, 2026 at 2:29 PM Rodrigo Vivi <rodrigo.vivi@intel.com>
> wrote:
> > I'm sorry for the delay here, but could you please refactor this
> > commit
> > message?
> > 
> > The first part of this commit message is the true justification for
> > your
> > original work, not for this patch here.
> 
> Hi Rodrigo,
> 
> Sure, I already have a new version of it:
> 
> ---
> 
> This patch continues the effort to refactor workqueue APIs, which has
> begun
> with the changes introducing new workqueues and a new alloc_workqueue
> flag:
> 
>    commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and
> system_dfl_wq")
>    commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")
> 
> The point of the refactoring is to eventually alter the default
> behavior of
> workqueues to become unbound by default so that their workload
> placement is
> optimized by the scheduler.
> 
> Before that to happen, workqueue users must be converted to the
> better named
> new workqueues with no intended behaviour changes:
> 
>    system_wq -> system_percpu_wq
>    system_unbound_wq -> system_dfl_wq
> 
> This way the old obsolete workqueues (system_wq, system_unbound_wq)
> can be
> removed in the future.
> 
> 
> > Except for your last phrase, which indicates, some wish of removing
> > the unbound_wq, it doesn't state clear on why we should change the
> > unbound per the dfl (default?).
> > 
> > Perhaps the authors of these cases below wanted to be unbound,
> > but choosing the default will make us to be tied to whatever
> > default might become in the future.
> > 
> > Right now both unbound and dfl are identical. In the future
> > you are planning to remove the unbound, but what about the dfl?
> > Any plans or possible changes? If no change is planned to dfl,
> > why create default and simply not stay with the unbound one
> > that is much more clear on its intention?
> 
> Yes, "dfl" is "default".
> 
> With the new version above I think it is clear, but in short: the
> rename
> is needed as a first refactoring step; the plan is to have an unbound
> workqueue
> as default.
> 
> system_unbound_wq will be removed and changed with system_dfl_wq.
> system_dfl_wq is the new unbound workqueue, it works exactly the same
> as
> system_unbound_wq.
> 
> system_wq will be replaced with system_percpu_wq; same thing as
> above,
> no behavioral changes, system_percpu_wq is the new per-cpu workqueue.
> 
> This is to make clear that if a per-cpu workqueue is not needed, the
> correct
> choice is system_dfl_wq.
> 
> Also, during this conversion phase, I can tell many subsystems asked
> to
> change system_wq (the name of the "old" per-cpu workqueue) with
> system_dfl_wq, because they just wanted to use a system workqueue and
> thought system_wq was already the unbound one.
> 
> All of this work has been discussed here:
> 
> https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
> 
> I will add this Link to the above commit log. Let me know if it
> sounds good.

This is perfect, thank you!

> 
> Thanks!

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

* Re: [PATCH v2 2/2] drm/xe: add WQ_PERCPU to alloc_workqueue users
  2025-11-03 17:06 ` [PATCH v2 2/2] drm/xe: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
@ 2026-01-08 16:53   ` Marco Crivellari
  0 siblings, 0 replies; 8+ messages in thread
From: Marco Crivellari @ 2026-01-08 16:53 UTC (permalink / raw)
  To: linux-kernel, intel-xe, dri-devel
  Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
	Sebastian Andrzej Siewior, Michal Hocko, Lucas De Marchi,
	Thomas Hellstrom, Rodrigo Vivi, David Airlie, Simona Vetter

Hi,

I realized something in the meantime, looking manually at the patch,
while preparing the v3.
There is a bug in the alloc_workqueue() line in xe_ggtt_init_early():

On Mon, Nov 3, 2025 at 6:06 PM Marco Crivellari
<marco.crivellari@suse.com> wrote:
> [...]
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 5edc0cad47e2..566163ab96ae 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -291,7 +291,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
>         else
>                 ggtt->pt_ops = &xelp_pt_ops;
>
> -       ggtt->wq = alloc_workqueue("xe-ggtt-wq", 0, WQ_MEM_RECLAIM);
> +       ggtt->wq = alloc_workqueue("xe-ggtt-wq", WQ_PERCPU, WQ_MEM_RECLAIM);
>         if (!ggtt->wq)
>                 return -ENOMEM;

> -       ggtt->wq = alloc_workqueue("xe-ggtt-wq", 0, WQ_MEM_RECLAIM);

The workqueue flag is the 2nd parameter, not the 3rd. The 3rd is max_active.

I will send a patch in order to fix this before proceeding with this
entire series.

Thanks!

-- 

Marco Crivellari

L3 Support Engineer

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

end of thread, other threads:[~2026-01-08 16:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-03 17:06 [PATCH v2 0/2] replace system_unbound_wq, add WQ_PERCPU to alloc_workqueue Marco Crivellari
2025-11-03 17:06 ` [PATCH v2 1/2] drm/xe: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
2026-01-08 13:28   ` Rodrigo Vivi
2026-01-08 13:45     ` Marco Crivellari
2026-01-08 14:13       ` Vivi, Rodrigo
2025-11-03 17:06 ` [PATCH v2 2/2] drm/xe: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
2026-01-08 16:53   ` Marco Crivellari
2025-12-24 14:51 ` [PATCH v2 0/2] replace system_unbound_wq, add WQ_PERCPU to alloc_workqueue Marco Crivellari

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®