[PATCH 0/4] replace old wq(s), added WQ_PERCPU to alloc_workqueue

Marco Crivellari posted 4 patches 3 months, 1 week ago
There is a newer version of this series
drivers/scsi/device_handler/scsi_dh_alua.c | 2 +-
drivers/scsi/qla2xxx/qla_os.c              | 4 ++--
drivers/scsi/scsi_transport_fc.c           | 5 +++--
drivers/scsi/scsi_transport_iscsi.c        | 2 +-
4 files changed, 7 insertions(+), 6 deletions(-)
[PATCH 0/4] replace old wq(s), added WQ_PERCPU to alloc_workqueue
Posted by Marco Crivellari 3 months, 1 week ago
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_wq and 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 clear it should be used when locality
	is not required.

2) [P 2-3-4] WQ_PERCPU added 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.

Thanks!


Marco Crivellari (4):
  scsi: replace use of system_unbound_wq with system_dfl_wq
  scsi: qla2xxx: WQ_PERCPU added to alloc_workqueue users
  scsi: scsi_dh_alua: WQ_PERCPU added to alloc_workqueue users
  scsi: scsi_transport_fc: WQ_PERCPU added to alloc_workqueue users

 drivers/scsi/device_handler/scsi_dh_alua.c | 2 +-
 drivers/scsi/qla2xxx/qla_os.c              | 4 ++--
 drivers/scsi/scsi_transport_fc.c           | 5 +++--
 drivers/scsi/scsi_transport_iscsi.c        | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

-- 
2.51.0
Re: [PATCH 0/4] replace old wq(s), added WQ_PERCPU to alloc_workqueue
Posted by Martin K. Petersen 2 months, 2 weeks ago
On Fri, 31 Oct 2025 10:56:39 +0100, Marco Crivellari wrote:

> === 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);
> 
> [...]

Applied to 6.19/scsi-queue, thanks!

[1/4] scsi: replace use of system_unbound_wq with system_dfl_wq
      https://git.kernel.org/mkp/scsi/c/cd87aa2e507a
[2/4] scsi: qla2xxx: WQ_PERCPU added to alloc_workqueue users
      https://git.kernel.org/mkp/scsi/c/5ca003bb4381
[3/4] scsi: scsi_dh_alua: WQ_PERCPU added to alloc_workqueue users
      https://git.kernel.org/mkp/scsi/c/afad6b34defe
[4/4] scsi: scsi_transport_fc: WQ_PERCPU added to alloc_workqueue users
      https://git.kernel.org/mkp/scsi/c/f76e4e1e836d

-- 
Martin K. Petersen
Re: [PATCH 0/4] replace old wq(s), added WQ_PERCPU to alloc_workqueue
Posted by Martin K. Petersen 2 months, 3 weeks ago
Marco,

> 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.

I applied this series and your other applicable workqueue patches to
6.19/scsi-staging. But ugh, that was a lot of work.

Next time, instead of posting individual patches, please prepare one
comprehensive series for the entire subsystem and submit that as a unit
so I don't have to stitch everything together, deal with dupes, etc.

-- 
Martin K. Petersen
Re: [PATCH 0/4] replace old wq(s), added WQ_PERCPU to alloc_workqueue
Posted by Marco Crivellari 2 months, 3 weeks ago
On Thu, Nov 13, 2025 at 3:38 AM Martin K. Petersen
<martin.petersen@oracle.com> wrote:
>
>
> Marco,
>
> > 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.
>
> I applied this series and your other applicable workqueue patches to
> 6.19/scsi-staging. But ugh, that was a lot of work.
>
> Next time, instead of posting individual patches, please prepare one
> comprehensive series for the entire subsystem and submit that as a unit
> so I don't have to stitch everything together, deal with dupes, etc.
>
> --
> Martin K. Petersen

Sure Martin, thank you!


--

Marco Crivellari

L3 Support Engineer, Technology & Product