* [PATCH 0/2] wifi: replace system_wq and system_unbound_wq uses
@ 2025-09-18 15:25 Marco Crivellari
2025-09-18 15:25 ` [PATCH 1/2] wifi: iwlwifi: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Marco Crivellari @ 2025-09-18 15:25 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Johannes Berg, Miri Korenblit, Emmanuel Grumbach,
Pagadala Yesu Anjaneyulu
Hi!
Below is a summary of a discussion about the Workqueue API and cpu isolation
considerations. Details and more information are available here:
"workqueue: Always use wq_select_unbound_cpu() for WORK_CPU_UNBOUND."
https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
=== 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 consistentcy cannot be addressed without refactoring the API.
=== Plan and future plans ===
This patchset is the first stone on a refactoring needed in order to
address the points aforementioned; it will have a positive impact also
on the cpu isolation, in the long term, moving away percpu workqueue in
favor to an unbound model.
These are the main steps:
1) API refactoring (that this patch is introducing)
- Make more clear and uniform the system wq names, both per-cpu and
unbound. This to avoid any possible confusion on what should be
used.
- Introduction of WQ_PERCPU: this flag is the complement of WQ_UNBOUND,
introduced in this patchset and used on all the callers that are not
currently using WQ_UNBOUND.
WQ_UNBOUND will be removed in a future release cycle.
Most users don't need to be per-cpu, because they don't have
locality requirements, because of that, a next future step will be
make "unbound" the default behavior.
2) Check who really needs to be per-cpu
- Remove the WQ_PERCPU flag when is not strictly required.
3) Add a new API (prefer local cpu)
- There are users that don't require a local execution, like mentioned
above; despite that, local execution yeld to performance gain.
This new API will prefer the local execution, without requiring it.
=== Introduced Changes by this series ===
1) [P 1-2] Replace use of system_wq and system_unbound_wq
system_wq is a per-CPU workqueue, but his name is not clear.
system_unbound_wq is to be used when locality is not required.
Because of that, system_wq has been renamed in system_percpu_wq, and
system_unbound_wq has been renamed in system_dfl_wq.
Thanks!
Marco Crivellari (2):
wifi: iwlwifi: replace use of system_unbound_wq with system_dfl_wq
wifi: replace use of system_wq with system_percpu_wq
drivers/net/wireless/intel/ipw2x00/ipw2100.c | 6 +++---
drivers/net/wireless/intel/ipw2x00/ipw2200.c | 2 +-
drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 4 ++--
drivers/net/wireless/intel/iwlwifi/iwl-trans.h | 2 +-
drivers/net/wireless/intel/iwlwifi/mvm/tdls.c | 6 +++---
5 files changed, 10 insertions(+), 10 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] wifi: iwlwifi: replace use of system_unbound_wq with system_dfl_wq
2025-09-18 15:25 [PATCH 0/2] wifi: replace system_wq and system_unbound_wq uses Marco Crivellari
@ 2025-09-18 15:25 ` Marco Crivellari
2025-09-18 15:25 ` [PATCH 2/2] wifi: replace use of system_wq with system_percpu_wq Marco Crivellari
2025-10-16 14:55 ` [PATCH 0/2] wifi: replace system_wq and system_unbound_wq uses Marco Crivellari
2 siblings, 0 replies; 4+ messages in thread
From: Marco Crivellari @ 2025-09-18 15:25 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Johannes Berg, Miri Korenblit, Emmanuel Grumbach,
Pagadala Yesu Anjaneyulu
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.
system_unbound_wq should be the default workqueue so as not to enforce
locality constraints for random work whenever it's not required.
Adding system_dfl_wq to encourage its use when unbound work should be used.
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/net/wireless/intel/iwlwifi/fw/dbg.c | 4 ++--
drivers/net/wireless/intel/iwlwifi/iwl-trans.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 2ce55859641c..e5f31b82339a 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -2933,7 +2933,7 @@ int iwl_fw_dbg_collect_desc(struct iwl_fw_runtime *fwrt,
IWL_WARN(fwrt, "Collecting data: trigger %d fired.\n",
le32_to_cpu(desc->trig_desc.type));
- queue_delayed_work(system_unbound_wq, &wk_data->wk,
+ queue_delayed_work(system_dfl_wq, &wk_data->wk,
usecs_to_jiffies(delay));
return 0;
@@ -3237,7 +3237,7 @@ int iwl_fw_dbg_ini_collect(struct iwl_fw_runtime *fwrt,
if (sync)
iwl_fw_dbg_collect_sync(fwrt, idx);
else
- queue_delayed_work(system_unbound_wq,
+ queue_delayed_work(system_dfl_wq,
&fwrt->dump.wks[idx].wk,
usecs_to_jiffies(delay));
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index a552669db6e2..2f24b639c133 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -1092,7 +1092,7 @@ static inline void iwl_trans_schedule_reset(struct iwl_trans *trans,
*/
trans->restart.during_reset = test_bit(STATUS_IN_SW_RESET,
&trans->status);
- queue_delayed_work(system_unbound_wq, &trans->restart.wk, 0);
+ queue_delayed_work(system_dfl_wq, &trans->restart.wk, 0);
}
static inline void iwl_trans_fw_error(struct iwl_trans *trans,
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] wifi: replace use of system_wq with system_percpu_wq
2025-09-18 15:25 [PATCH 0/2] wifi: replace system_wq and system_unbound_wq uses Marco Crivellari
2025-09-18 15:25 ` [PATCH 1/2] wifi: iwlwifi: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
@ 2025-09-18 15:25 ` Marco Crivellari
2025-10-16 14:55 ` [PATCH 0/2] wifi: replace system_wq and system_unbound_wq uses Marco Crivellari
2 siblings, 0 replies; 4+ messages in thread
From: Marco Crivellari @ 2025-09-18 15:25 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Johannes Berg, Miri Korenblit, Emmanuel Grumbach,
Pagadala Yesu Anjaneyulu
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.
system_wq is a per-cpu workqueue, but its name is not clear. Because of
that has been renamed in system_percpu_wq.
The old system_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/net/wireless/intel/ipw2x00/ipw2100.c | 6 +++---
drivers/net/wireless/intel/ipw2x00/ipw2200.c | 2 +-
drivers/net/wireless/intel/iwlwifi/mvm/tdls.c | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
index 215814861cbd..c7c5bc0f1650 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
@@ -2143,7 +2143,7 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
/* Make sure the RF Kill check timer is running */
priv->stop_rf_kill = 0;
- mod_delayed_work(system_wq, &priv->rf_kill, round_jiffies_relative(HZ));
+ mod_delayed_work(system_percpu_wq, &priv->rf_kill, round_jiffies_relative(HZ));
}
static void ipw2100_scan_event(struct work_struct *work)
@@ -2170,7 +2170,7 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status)
round_jiffies_relative(msecs_to_jiffies(4000)));
} else {
priv->user_requested_scan = 0;
- mod_delayed_work(system_wq, &priv->scan_event, 0);
+ mod_delayed_work(system_percpu_wq, &priv->scan_event, 0);
}
}
@@ -4252,7 +4252,7 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
"disabled by HW switch\n");
/* Make sure the RF_KILL check timer is running */
priv->stop_rf_kill = 0;
- mod_delayed_work(system_wq, &priv->rf_kill,
+ mod_delayed_work(system_percpu_wq, &priv->rf_kill,
round_jiffies_relative(HZ));
} else
schedule_reset(priv);
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
index 24a5624ef207..09035a77e775 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
@@ -4415,7 +4415,7 @@ static void handle_scan_event(struct ipw_priv *priv)
round_jiffies_relative(msecs_to_jiffies(4000)));
} else {
priv->user_requested_scan = 0;
- mod_delayed_work(system_wq, &priv->scan_event, 0);
+ mod_delayed_work(system_percpu_wq, &priv->scan_event, 0);
}
}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c b/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
index 36379b738de1..0df31639fa5e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
@@ -234,7 +234,7 @@ void iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
* Also convert TU to msec.
*/
delay = TU_TO_MS(vif->bss_conf.dtim_period * vif->bss_conf.beacon_int);
- mod_delayed_work(system_wq, &mvm->tdls_cs.dwork,
+ mod_delayed_work(system_percpu_wq, &mvm->tdls_cs.dwork,
msecs_to_jiffies(delay));
iwl_mvm_tdls_update_cs_state(mvm, IWL_MVM_TDLS_SW_ACTIVE);
@@ -548,7 +548,7 @@ iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
*/
delay = 2 * TU_TO_MS(vif->bss_conf.dtim_period *
vif->bss_conf.beacon_int);
- mod_delayed_work(system_wq, &mvm->tdls_cs.dwork,
+ mod_delayed_work(system_percpu_wq, &mvm->tdls_cs.dwork,
msecs_to_jiffies(delay));
return 0;
}
@@ -659,6 +659,6 @@ iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw,
/* register a timeout in case we don't succeed in switching */
delay = vif->bss_conf.dtim_period * vif->bss_conf.beacon_int *
1024 / 1000;
- mod_delayed_work(system_wq, &mvm->tdls_cs.dwork,
+ mod_delayed_work(system_percpu_wq, &mvm->tdls_cs.dwork,
msecs_to_jiffies(delay));
}
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] wifi: replace system_wq and system_unbound_wq uses
2025-09-18 15:25 [PATCH 0/2] wifi: replace system_wq and system_unbound_wq uses Marco Crivellari
2025-09-18 15:25 ` [PATCH 1/2] wifi: iwlwifi: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
2025-09-18 15:25 ` [PATCH 2/2] wifi: replace use of system_wq with system_percpu_wq Marco Crivellari
@ 2025-10-16 14:55 ` Marco Crivellari
2 siblings, 0 replies; 4+ messages in thread
From: Marco Crivellari @ 2025-10-16 14:55 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Michal Hocko, Johannes Berg,
Miri Korenblit, Emmanuel Grumbach, Pagadala Yesu Anjaneyulu
On Thu, Sep 18, 2025 at 5:26 PM Marco Crivellari
<marco.crivellari@suse.com> wrote:
>[...]
> Marco Crivellari (2):
> wifi: iwlwifi: replace use of system_unbound_wq with system_dfl_wq
> wifi: replace use of system_wq with system_percpu_wq
>
> drivers/net/wireless/intel/ipw2x00/ipw2100.c | 6 +++---
> drivers/net/wireless/intel/ipw2x00/ipw2200.c | 2 +-
> drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 4 ++--
> drivers/net/wireless/intel/iwlwifi/iwl-trans.h | 2 +-
> drivers/net/wireless/intel/iwlwifi/mvm/tdls.c | 6 +++---
> 5 files changed, 10 insertions(+), 10 deletions(-)
>
> --
> 2.51.0
>
Gentle ping.
Thank you!
--
Marco Crivellari
L3 Support Engineer, Technology & Product
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-16 14:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-18 15:25 [PATCH 0/2] wifi: replace system_wq and system_unbound_wq uses Marco Crivellari
2025-09-18 15:25 ` [PATCH 1/2] wifi: iwlwifi: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
2025-09-18 15:25 ` [PATCH 2/2] wifi: replace use of system_wq with system_percpu_wq Marco Crivellari
2025-10-16 14:55 ` [PATCH 0/2] wifi: replace system_wq and system_unbound_wq uses 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®