Skip to content

Commit 06c489c

Browse files
DispatchCodeherbertx
authored andcommitted
crypto: qat - add WQ_PERCPU to alloc_workqueue users
Currently if a user enqueues 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. 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 continues the effort to refactor workqueue APIs, which began with the introduction of new workqueues and a new alloc_workqueue flag in: commit 128ea9f ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea ("workqueue: Add new WQ_PERCPU flag") 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> Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 054c7f7 commit 06c489c

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

drivers/crypto/intel/qat/qat_common/adf_aer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,11 @@ int adf_notify_fatal_error(struct adf_accel_dev *accel_dev)
276276
int adf_init_aer(void)
277277
{
278278
device_reset_wq = alloc_workqueue("qat_device_reset_wq",
279-
WQ_MEM_RECLAIM, 0);
279+
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
280280
if (!device_reset_wq)
281281
return -EFAULT;
282282

283-
device_sriov_wq = alloc_workqueue("qat_device_sriov_wq", 0, 0);
283+
device_sriov_wq = alloc_workqueue("qat_device_sriov_wq", WQ_PERCPU, 0);
284284
if (!device_sriov_wq) {
285285
destroy_workqueue(device_reset_wq);
286286
device_reset_wq = NULL;

drivers/crypto/intel/qat/qat_common/adf_isr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ EXPORT_SYMBOL_GPL(adf_isr_resource_alloc);
384384
*/
385385
int __init adf_init_misc_wq(void)
386386
{
387-
adf_misc_wq = alloc_workqueue("qat_misc_wq", WQ_MEM_RECLAIM, 0);
387+
adf_misc_wq = alloc_workqueue("qat_misc_wq",
388+
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
388389

389390
return !adf_misc_wq ? -ENOMEM : 0;
390391
}

drivers/crypto/intel/qat/qat_common/adf_sriov.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ EXPORT_SYMBOL_GPL(adf_sriov_configure);
299299
int __init adf_init_pf_wq(void)
300300
{
301301
/* Workqueue for PF2VF responses */
302-
pf2vf_resp_wq = alloc_workqueue("qat_pf2vf_resp_wq", WQ_MEM_RECLAIM, 0);
302+
pf2vf_resp_wq = alloc_workqueue("qat_pf2vf_resp_wq",
303+
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
303304

304305
return !pf2vf_resp_wq ? -ENOMEM : 0;
305306
}

drivers/crypto/intel/qat/qat_common/adf_vf_isr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ EXPORT_SYMBOL_GPL(adf_flush_vf_wq);
299299
*/
300300
int __init adf_init_vf_wq(void)
301301
{
302-
adf_vf_stop_wq = alloc_workqueue("adf_vf_stop_wq", WQ_MEM_RECLAIM, 0);
302+
adf_vf_stop_wq = alloc_workqueue("adf_vf_stop_wq",
303+
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
303304

304305
return !adf_vf_stop_wq ? -EFAULT : 0;
305306
}

0 commit comments

Comments
 (0)