Skip to contentSkip to conversation

Replace system_unbound_wq with system_dfl_wq

PATCH In review Marco Crivellari 1 participant 4 messages Apr 2 – Apr 9 Scheduler

lore
Share & tools
lore
#0 lore raw

v3 cover Replace system_unbound_wq with system_dfl_wq

Hi,

Recently the workqueue code has been changed introducing two new workqueue, system_percpu_wq and system_dfl_wq, as a future replacement for system_wq and system_unbound_wq respectively.

The following, address the aforementioned 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-2] Replace uses of system_wq and system_unbound_wq

system_unbound_wq is to be used when locality is not required. Nothing in its name make clear this should be used when locality is not required, so system_unbound_wq has been replaced with system_dfl_wq.

Thanks!

---
Changes in v3:
- rebased on v7.0-rc6

- commit split in two: sched (kernel/sched/core.c) and sched_ext (kernel/sched/ext.c).

- improved commit logs

Changes in v2:
- rebase and improved commit logs

Marco Crivellari (2):
sched: replace use of system_unbound_wq with system_dfl_wq
sched_ext: Replace use of system_unbound_wq with system_dfl_wq

 kernel/sched/core.c | 4 ++--
 kernel/sched/ext.c  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v3 1/2 sched: replace use of system_unbound_wq with system_dfl_wq

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.

---
 kernel/sched/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/core.c +2 -2
index 496dff740dca..aaef6f5292aa 100644
@@ -5681,7 +5681,7 @@ static void sched_tick_remote(struct work_struct *work)
 	os = atomic_fetch_add_unless(&twork->state, -1, TICK_SCHED_REMOTE_RUNNING);
 	WARN_ON_ONCE(os == TICK_SCHED_REMOTE_OFFLINE);
 	if (os == TICK_SCHED_REMOTE_RUNNING)
-		queue_delayed_work(system_unbound_wq, dwork, HZ);
+		queue_delayed_work(system_dfl_wq, dwork, HZ);
 }
 
 static void sched_tick_start(int cpu)
@@ -5700,7 +5700,7 @@ static void sched_tick_start(int cpu)
 	if (os == TICK_SCHED_REMOTE_OFFLINE) {
 		twork->cpu = cpu;
 		INIT_DELAYED_WORK(&twork->work, sched_tick_remote);
-		queue_delayed_work(system_unbound_wq, &twork->work, HZ);
+		queue_delayed_work(system_dfl_wq, &twork->work, HZ);
 	}
 }
 
Signature · 1 line
2.53.0
#2 lore raw

PATCH v3 2/2 sched_ext: Replace use of system_unbound_wq with system_dfl_wq

In reply to Marco Crivellari

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.

---
 kernel/sched/ext.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/ext.c +3 -3
index 26a6ac2f8826..95791a5ebb0d 100644
@@ -2765,7 +2765,7 @@ static void scx_watchdog_workfn(struct work_struct *work)
 
 		cond_resched();
 	}
-	queue_delayed_work(system_unbound_wq, to_delayed_work(work),
+	queue_delayed_work(system_dfl_wq, to_delayed_work(work),
 			   READ_ONCE(scx_watchdog_timeout) / 2);
 }
 
@@ -3704,7 +3704,7 @@ static void scx_kobj_release(struct kobject *kobj)
 	struct scx_sched *sch = container_of(kobj, struct scx_sched, kobj);
 
 	INIT_RCU_WORK(&sch->rcu_work, scx_sched_free_rcu_work);
-	queue_rcu_work(system_unbound_wq, &sch->rcu_work);
+	queue_rcu_work(system_dfl_wq, &sch->rcu_work);
 }
 
 static ssize_t scx_attr_ops_show(struct kobject *kobj,
@@ -5087,7 +5087,7 @@ static void scx_enable_workfn(struct kthread_work *work)
 
 	WRITE_ONCE(scx_watchdog_timeout, timeout);
 	WRITE_ONCE(scx_watchdog_timestamp, jiffies);
-	queue_delayed_work(system_unbound_wq, &scx_watchdog_work,
+	queue_delayed_work(system_dfl_wq, &scx_watchdog_work,
 			   READ_ONCE(scx_watchdog_timeout) / 2);
 
 	/*
Signature · 1 line
2.53.0
#3 lore raw
In reply to Marco Crivellari
Quoted 8 lines · Marco Crivellari

[...]
Marco Crivellari (2):
sched: replace use of system_unbound_wq with system_dfl_wq
sched_ext: Replace use of system_unbound_wq with system_dfl_wq

 kernel/sched/core.c | 4 ++--
 kernel/sched/ext.c  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

Hi,

Gentle ping.

Thanks!

Signature · 3 lines
Marco Crivellari

SUSE Labs