Skip to contentSkip to conversation

Let create*_workqueue() accept a printf-style format string

PATCH In review Bart Van Assche 9 participants 71 messages Jun 30, 2024 – Aug 9, 2024

Subsystems (59)
lore
Share & tools
lore

Bart Van Assche

author reviewer
#0 lore raw

cover Let create*_workqueue() accept a printf-style format string

Hi Tejun,

A significant amount of kernel code formats the workqueue name before it calls a workqueue creation function. This patch series simplifies such kernel code and modifies the create*_workqueue() macros such that these accept a printf-style format string and argument list.

The approach of this patch series is as follows:
1. Introduce the create*_workqueue2() macros that accept a printf-style format string and argument list.
2. Convert all workqueue creation calls that might pass a name that includes a formatting character from create*_workqueue(name) into create*_workqueue2("%s", name).
3. Convert all workqueue creation code that is preceded by workqueue name formatting code into a create*_workqueue2(fmt, args) call.
4. Convert all create*_workqueue2() calls into create*_workqueue() calls, remove the original create*_workqueue() calls and rename the new create*_workqueue2() macros into create*_workqueue().

Please consider this patch series for the next merge window.

Thanks,

Bart.

Bart Van Assche (53):
workqueue: Introduce the create*_workqueue2() macros
dmaengine: idxd: Switch to create*_workqueue2() drm/amdgpu: Switch to create*_workqueue2()
media: i2c: adv7511: Switch to create*_workqueue2()
media: cobalt: Switch to create*_workqueue2()
media: dm1105: Switch to create*_workqueue2()
misc: bcm_vk: Switch to create*_workqueue2()
net: amd-xgbe: Switch to create*_workqueue2()
net: atlantic: Switch to create*_workqueue2()
net: mvpp2: Switch to create*_workqueue2()
remoteproc: stm32: Switch to create*_workqueue2() mm/z3fold: Switch to create*_workqueue2()
usb: typec: tcpm: Switch to create*_workqueue2() net/qla3xxx: Switch to create*_workqueue2()
sfc: Switch to create*_workqueue2()
wifi: zd1211rw: Switch to create*_workqueue2()
power: supply: mt6370: Switch to create*_workqueue2()
remoteproc: imx_rproc: Switch to create*_workqueue2()
scsi: hisi_sas: Switch to create*_workqueue2()
scsi: mpt3sas: Switch to create*_workqueue2() accel/habanalabs: Simplify the workqueue creation calls
crypto: safexcel - Simplify a create*_workqueue() call
pds_core: Simplify a create*_workqueue() call
net: bna: Simplify a create*_workqueue() call net/mlx5: Simplify the create*_workqueue() calls
net: lan966x: Simplify a create*_workqueue() call
net: sparx5: Simplify the create*_workqueue() calls
net: mscc: ocelot: Simplify a create*_workqueue() call
net: qed: Simplify a create*_workqueue() call
net: stmmac: Simplify a create*_workqueue() call
nfc: mrvl: Simplify a create*_workqueue() call
scsi: ibmvscsi_tgt: Simplify a create*_workqueue() call
scsi: libsas: Simplify the create*_workqueue() calls
scsi: mpi3mr: Simplify a create*_workqueue() call
scsi: qedf: Simplify the create*_workqueue() calls
scsi: qedi: Simplify the create*_workqueue() calls
scsi: qla2xxx: Simplify the create*_workqueue() calls
scsi: qla4xxx: Simplify a create*_workqueue() call
scsi: vmw_pvscsi: Simplify a create*_workqueue() call
scsi: myrb: Simplify the create*_workqueue() calls
scsi: myrs: Simplify the create*_workqueue() calls
scsi: stex: Simplify the create*_workqueue() calls
scsi: fcoe: Simplify the create*_workqueue() calls
scsi: snic: Simplify the create*_workqueue() calls
scsi: scsi_transport_fc: Simplify the create*_workqueue() calls
scsi: core: Simplify the alloc_workqueue() calls
serial: max3100: Simplify a create*_workqueue() call
scsi: ufs: Simplify the create*_workqueue() calls
usb: typec: ucsi: Simplify a create*_workqueue() call
cifs: Simplify a create*_workqueue() call
mac802154: Simplify the create*_workqueue() calls
nfc: nci: Simplify the create*_workqueue() calls
workqueue: Rename create*_workqueue2() into create*_workqueue()

 drivers/accel/habanalabs/common/device.c      | 25 +++++++++----------
 drivers/crypto/inside-secure/safexcel.c       |  4 +--
 drivers/dma/idxd/cdev.c                       |  2 +-
 drivers/dma/idxd/init.c                       |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c     |  2 +-
 drivers/media/i2c/adv7511-v4l2.c              |  2 +-
 drivers/media/pci/cobalt/cobalt-driver.c      |  2 +-
 drivers/media/pci/dm1105/dm1105.c             |  2 +-
 drivers/misc/bcm-vk/bcm_vk_dev.c              |  2 +-
 drivers/net/ethernet/amd/pds_core/main.c      |  7 ++----
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c      |  4 +--
 .../net/ethernet/aquantia/atlantic/aq_main.c  |  2 +-
 drivers/net/ethernet/brocade/bna/bnad.c       |  4 +--
 drivers/net/ethernet/brocade/bna/bnad.h       |  1 -
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   |  3 ++-
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 12 ++-------
 .../net/ethernet/mellanox/mlx5/core/health.c  | 10 ++------
 .../mellanox/mlx5/core/sf/vhca_event.c        |  5 ++--
 .../microchip/lan966x/lan966x_ethtool.c       |  7 ++----
 .../microchip/sparx5/sparx5_ethtool.c         |  6 ++---
 .../ethernet/microchip/sparx5/sparx5_main.c   |  6 ++---
 drivers/net/ethernet/mscc/ocelot_stats.c      |  6 ++---
 drivers/net/ethernet/qlogic/qed/qed_sriov.c   |  9 +++----
 drivers/net/ethernet/qlogic/qla3xxx.c         |  2 +-
 drivers/net/ethernet/sfc/efx_common.c         |  3 ++-
 drivers/net/ethernet/sfc/falcon/efx.c         |  3 ++-
 drivers/net/ethernet/sfc/siena/efx_common.c   |  3 ++-
 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |  1 -
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++-----
 drivers/net/wireless/zydas/zd1211rw/zd_usb.c  |  2 +-
 drivers/nfc/nfcmrvl/fw_dnld.c                 |  8 +++---
 drivers/power/supply/mt6370-charger.c         |  2 +-
 drivers/remoteproc/imx_rproc.c                |  2 +-
 drivers/remoteproc/stm32_rproc.c              |  2 +-
 drivers/scsi/fcoe/fcoe_sysfs.c                |  7 +-----
 drivers/scsi/hisi_sas/hisi_sas_main.c         |  2 +-
 drivers/scsi/hosts.c                          |  9 +++----
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c      |  4 +--
 drivers/scsi/libsas/sas_init.c                |  9 +++----
 drivers/scsi/mpi3mr/mpi3mr_fw.c               |  4 +--
 drivers/scsi/mpt3sas/mpt3sas_base.c           |  4 +--
 drivers/scsi/myrb.c                           |  5 ++--
 drivers/scsi/myrb.h                           |  1 -
 drivers/scsi/myrs.c                           |  5 ++--
 drivers/scsi/myrs.h                           |  1 -
 drivers/scsi/qedf/qedf_main.c                 | 17 +++++--------
 drivers/scsi/qedi/qedi_main.c                 |  8 +++---
 drivers/scsi/qla2xxx/qla_os.c                 | 10 ++++----
 drivers/scsi/qla4xxx/ql4_os.c                 |  5 ++--
 drivers/scsi/scsi_transport_fc.c              |  4 +--
 drivers/scsi/snic/snic_main.c                 |  5 ++--
 drivers/scsi/stex.c                           |  6 ++---
 drivers/scsi/vmw_pvscsi.c                     |  8 ++----
 drivers/tty/serial/max3100.c                  |  4 +--
 drivers/ufs/core/ufshcd.c                     | 13 +++-------
 drivers/usb/typec/tcpm/fusb302.c              |  2 +-
 drivers/usb/typec/ucsi/ucsi.c                 |  9 ++-----
 fs/smb/client/smbdirect.c                     |  3 +--
 include/linux/mlx5/driver.h                   |  5 ----
 include/linux/workqueue.h                     | 15 +++++------
 include/scsi/fcoe_sysfs.h                     |  1 -
 include/scsi/scsi_host.h                      |  1 -
 include/scsi/scsi_transport_fc.h              |  3 ---
 mm/z3fold.c                                   |  4 +--
 net/mac802154/main.c                          |  7 +++---
 net/nfc/nci/core.c                            | 13 +++++-----
 66 files changed, 135 insertions(+), 223 deletions(-)
author reviewer
#1 lore raw

PATCH 1/53 workqueue: Introduce the create*_workqueue2() macros

A common pattern in the Linux kernel is that sprintf(), snprintf() or kasprintf() is used to format the workqueue name that is passed to create_workqueue(), create_freezable_workqueue() or create_singlethread_workqueue(). Prepare for simplifying such code by introducing the create*_workqueue2() macros that accept a printf-style format string and argument list. A later patch will remove the create*_workqueue() macros and will rename the create*_workqueue2() macros into create*_workqueue().

---
 include/linux/workqueue.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/linux/workqueue.h +9 -0
index d9968bfc8eac..762aaedaba56 100644
@@ -525,11 +525,20 @@ alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);
 
 #define create_workqueue(name)						\
 	alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name))
+#define create_workqueue2(fmt, args...) \
+	alloc_workqueue(fmt, __WQ_LEGACY | WQ_MEM_RECLAIM, 1, ##args)
 #define create_freezable_workqueue(name)				\
 	alloc_workqueue("%s", __WQ_LEGACY | WQ_FREEZABLE | WQ_UNBOUND |	\
 			WQ_MEM_RECLAIM, 1, (name))
+#define create_freezable_workqueue2(fmt, args...)                               \
+	alloc_workqueue(                                                       \
+		fmt, __WQ_LEGACY | WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, \
+		1, ##args)
 #define create_singlethread_workqueue(name)				\
 	alloc_ordered_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, name)
+#define create_singlethread_workqueue2(fmt, args...)			\
+	alloc_ordered_workqueue(fmt, __WQ_LEGACY | WQ_MEM_RECLAIM, ##args)
+
 
 #define from_work(var, callback_work, work_fieldname)	\
 	container_of(callback_work, typeof(*var), work_fieldname)
reviewer
#2 lore raw

Re: [PATCH 01/53] workqueue: Introduce the create*_workqueue2() macros

Hello

include/linux/workqueue.h alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...); · line 532

Quoted 11 lines · Bart Van Assche
include/linux/workqueue.h +2 -0
@@ -525,11 +525,20 @@ alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);
 
 #define create_workqueue(name)                                         \
        alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name))
+#define create_workqueue2(fmt, args...) \
+       alloc_workqueue(fmt, __WQ_LEGACY | WQ_MEM_RECLAIM, 1, ##args)
 #define create_freezable_workqueue(name)                               \
        alloc_workqueue("%s", __WQ_LEGACY | WQ_FREEZABLE | WQ_UNBOUND | \
                        WQ_MEM_RECLAIM, 1, (name))

Is there any possible preprocessor hack to avoid the renaming of the functions?

Thanks
Lai

author reviewer
#3 lore raw

Re: [PATCH 01/53] workqueue: Introduce the create*_workqueue2() macros

Quoted 6 lines · Lai Jiangshan
Quoted 4 lines · Bart Van Assche
include/linux/workqueue.h +0 -0
@@ -525,11 +525,20 @@ alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);
 
Quoted 9 lines

include/linux/workqueue.h alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...); · line 532

Quoted 7 lines
include/linux/workqueue.h +2 -0
  #define create_workqueue(name)                                         \
         alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name))
+#define create_workqueue2(fmt, args...) \
+       alloc_workqueue(fmt, __WQ_LEGACY | WQ_MEM_RECLAIM, 1, ##args)
  #define create_freezable_workqueue(name)                               \
         alloc_workqueue("%s", __WQ_LEGACY | WQ_FREEZABLE | WQ_UNBOUND | \
                         WQ_MEM_RECLAIM, 1, (name))

Is there any possible preprocessor hack to avoid the renaming of the functions?

Thanks Lai for having taken a look. As one can see here the last patch of this patch series renames create_workqueue2() back to create_workqueue(): https://lore.kernel.org/linux-kernel/[email protected]/

Bart.

#4 lore raw

Re: [PATCH 01/53] workqueue: Introduce the create*_workqueue2() macros

Quoted 17 lines · Bart Van Assche
Quoted 6 lines · Lai Jiangshan
Quoted 4 lines · Bart Van Assche
include/linux/workqueue.h +0 -0
@@ -525,11 +525,20 @@ alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);
 
Quoted 9 lines

include/linux/workqueue.h alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...); · line 532

Quoted 7 lines
include/linux/workqueue.h +2 -0
  #define create_workqueue(name)                                         \
         alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name))
+#define create_workqueue2(fmt, args...) \
+       alloc_workqueue(fmt, __WQ_LEGACY | WQ_MEM_RECLAIM, 1, ##args)
  #define create_freezable_workqueue(name)                               \
         alloc_workqueue("%s", __WQ_LEGACY | WQ_FREEZABLE | WQ_UNBOUND | \
                         WQ_MEM_RECLAIM, 1, (name))

Is there any possible preprocessor hack to avoid the renaming of the functions?

Quoted 2 lines

Thanks Lai for having taken a look. As one can see here the last patch of
this patch series renames create_workqueue2() back to create_workqueue(): https://lore.kernel.org/linux-kernel/[email protected]/

This can be done with the preprocessor to detect how many arguments are being used, so then there is no need to do the renaming passes and conversions can land via subsystems:

include/linux/workqueue.h +18 -7
index fb3993894536..00420f85b881 100644
@@ -523,13 +523,24 @@ alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);
 #define alloc_ordered_workqueue(fmt, flags, args...)			\
 	alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
 
-#define create_workqueue(name)						\
-	alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name))
-#define create_freezable_workqueue(name)				\
-	alloc_workqueue("%s", __WQ_LEGACY | WQ_FREEZABLE | WQ_UNBOUND |	\
-			WQ_MEM_RECLAIM, 1, (name))
-#define create_singlethread_workqueue(name)				\
-	alloc_ordered_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, name)
+#define __has_one_arg(args...)  __is_defined(COUNT_ARGS(args))
+
+#define __create_workqueue1(flags, name) \
+                alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM | (flags), \
+				1, name)
+#define __create_workqueue0(flags, fmt, args...) \
+                alloc_workqueue(fmt, __WQ_LEGACY | WQ_MEM_RECLAIM | (flags), \
+				1, args)
+
+#define create_workqueue(args...) \
+        CONCATENATE(__create_workqueue, __has_one_arg(args))\
+                (0, args)
+#define create_freezeable_workqueue(args...) \
+        CONCATENATE(__create_workqueue, __has_one_arg(args))\
+                (WQ_UNBOUND | WQ_FREEZABLE, args)
+#define create_singlethread_workqueue(args...) \
+        CONCATENATE(__create_workqueue, __has_one_arg(args))\
+                (WQ_UNBOUND | __WQ_ORDERED, args)
 
 #define from_work(var, callback_work, work_fieldname)	\
 	container_of(callback_work, typeof(*var), work_fieldname)

Now conversions are one step, e.g.:

fs/smb/client/smbdirect.c +1 -2
index d74e829de51c..f7f27c6f1a15 100644
@@ -1458,8 +1458,7 @@ static int allocate_caches_and_workqueue(struct smbd_connection *info)
 	if (!info->response_mempool)
 		goto out3;
 
-	scnprintf(name, MAX_NAME_LEN, "smbd_%p", info);
-	info->workqueue = create_workqueue(name);
+	info->workqueue = create_workqueue("smbd_%p", info);
 	if (!info->workqueue)
 		goto out4;
 
Signature · 1 line
Kees Cook
author reviewer
#5 lore raw

Re: [PATCH 01/53] workqueue: Introduce the create*_workqueue2() macros

Quoted 3 lines · Kees Cook

This can be done with the preprocessor to detect how many arguments are being used, so then there is no need to do the renaming passes and conversions can land via subsystems:

Thanks Kees, this is very useful feedback.

As one can see here, Tejun requested not to add support for a format string in the create*_workqueue() macros:
https://lore.kernel.org/linux-kernel/[email protected]/

Hence a different approach for the SCSI create*_workqueue() macros:
https://lore.kernel.org/linux-scsi/[email protected]/

Best regards,

Bart.

#6 lore raw

Re: [PATCH 01/53] workqueue: Introduce the create*_workqueue2() macros

Quoted 10 lines · Bart Van Assche
Quoted 3 lines · Kees Cook

This can be done with the preprocessor to detect how many arguments are being used, so then there is no need to do the renaming passes and conversions can land via subsystems:

Thanks Kees, this is very useful feedback.

As one can see here, Tejun requested not to add support for a format string in the create*_workqueue() macros:
https://lore.kernel.org/linux-kernel/[email protected]/

Ah! I should have read the thread more fully. :)

Quoted 2 lines

Hence a different approach for the SCSI create*_workqueue() macros:
https://lore.kernel.org/linux-scsi/[email protected]/

Gotcha. Okay, well, that's a lot of flags to open-code, but I guess that's fine? :P

Signature · 1 line
Kees Cook
maintainer
#7 lore raw

Re: [PATCH 01/53] workqueue: Introduce the create*_workqueue2() macros

Hello,

Quoted 5 lines · Kees Cook
Quoted 2 lines

Hence a different approach for the SCSI create*_workqueue() macros:
https://lore.kernel.org/linux-scsi/[email protected]/

Gotcha. Okay, well, that's a lot of flags to open-code, but I guess that's fine? :P

The flag in question is WQ_MEM_RECLAIM and that flag has a direct cost of creating a dedicated kthread which mostly sits idle, so we want it to be explicit. In SCSI, the naive expansion is likely to be correct for most cases.

It's a bit tricky in that the failure mode of incorrectly missing the flag is critical (system deadlock under memory pressure) but can be difficult to trigger and the depencency chain may not be immediately evident when looking at the code. The upsides are that when it happens, it's usually not too difficult to tell from the backtraces and lockdep annotation sometimes helps with finding missing cases (which is suppressed when using the old interface because it's unclear whether MEM_RECLAIM is there intentionally or not).

Anyways, yeah, we want it to be explicit.

Thanks.

Signature · 1 line
tejun
author reviewer
#8 lore raw

PATCH 2/53 dmaengine: idxd: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/dma/idxd/cdev.c | 2 +-
 drivers/dma/idxd/init.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/dma/idxd/cdev.c +1 -1
index 57f1bf2ab20b..5aef47e5c6e4 100644
@@ -619,7 +619,7 @@ static int idxd_user_drv_probe(struct idxd_dev *idxd_dev)
 		goto wq_err;
 	}
 
-	wq->wq = create_workqueue(dev_name(wq_confdev(wq)));
+	wq->wq = create_workqueue2("%s", dev_name(wq_confdev(wq)));
 	if (!wq->wq) {
 		rc = -ENOMEM;
 		goto wq_err;
drivers/dma/idxd/init.c +1 -1
index a7295943fa22..a3e821090bf2 100644
@@ -397,7 +397,7 @@ static int idxd_setup_internals(struct idxd_device *idxd)
 	if (rc < 0)
 		goto err_group;
 
-	idxd->wq = create_workqueue(dev_name(dev));
+	idxd->wq = create_workqueue2("%s", dev_name(dev));
 	if (!idxd->wq) {
 		rc = -ENOMEM;
 		goto err_wkq_create;
author reviewer
#9 lore raw

PATCH 3/53 drm/amdgpu: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1 -1
index ea4873f6ccd1..6ed3af1286fb 100644
@@ -131,7 +131,7 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_d
 	reset_domain->type = type;
 	kref_init(&reset_domain->refcount);
 
-	reset_domain->wq = create_singlethread_workqueue(wq_name);
+	reset_domain->wq = create_singlethread_workqueue2("%s", wq_name);
 	if (!reset_domain->wq) {
 		DRM_ERROR("Failed to allocate wq for amdgpu_reset_domain!");
 		amdgpu_reset_put_reset_domain(reset_domain);
author reviewer
#10 lore raw

PATCH 4/53 media: i2c: adv7511: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/media/i2c/adv7511-v4l2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/adv7511-v4l2.c +1 -1
index 79946e9c7401..88e065a65ac1 100644
@@ -1885,7 +1885,7 @@ static int adv7511_probe(struct i2c_client *client)
 		goto err_unreg_cec;
 	}
 
-	state->work_queue = create_singlethread_workqueue(sd->name);
+	state->work_queue = create_singlethread_workqueue2("%s", sd->name);
 	if (state->work_queue == NULL) {
 		v4l2_err(sd, "could not create workqueue\n");
 		err = -ENOMEM;
author reviewer
#11 lore raw

PATCH 5/53 media: cobalt: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/media/pci/cobalt/cobalt-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/cobalt/cobalt-driver.c +1 -1
index 6e1a0614e6d0..24e8f4439c53 100644
@@ -683,7 +683,7 @@ static int cobalt_probe(struct pci_dev *pci_dev,
 	cobalt_info("Initializing card %d\n", cobalt->instance);
 
 	cobalt->irq_work_queues =
-		create_singlethread_workqueue(cobalt->v4l2_dev.name);
+		create_singlethread_workqueue2("%s", cobalt->v4l2_dev.name);
 	if (cobalt->irq_work_queues == NULL) {
 		cobalt_err("Could not create workqueue\n");
 		retval = -ENOMEM;
author reviewer
#12 lore raw

PATCH 6/53 media: dm1105: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/media/pci/dm1105/dm1105.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/dm1105/dm1105.c +1 -1
index 9e9c7c071acc..05959891aa5f 100644
@@ -1123,7 +1123,7 @@ static int dm1105_probe(struct pci_dev *pdev,
 
 	INIT_WORK(&dev->work, dm1105_dmx_buffer);
 	sprintf(dev->wqn, "%s/%d", dvb_adapter->name, dvb_adapter->num);
-	dev->wq = create_singlethread_workqueue(dev->wqn);
+	dev->wq = create_singlethread_workqueue2("%s", dev->wqn);
 	if (!dev->wq) {
 		ret = -ENOMEM;
 		goto err_dvb_net;
author reviewer
#13 lore raw

PATCH 7/53 misc: bcm_vk: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/misc/bcm-vk/bcm_vk_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/bcm-vk/bcm_vk_dev.c +1 -1
index d4a96137728d..ced5c9f17909 100644
@@ -1428,7 +1428,7 @@ static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	INIT_WORK(&vk->wq_work, bcm_vk_wq_handler);
 
 	/* create dedicated workqueue */
-	vk->wq_thread = create_singlethread_workqueue(name);
+	vk->wq_thread = create_singlethread_workqueue2("%s", name);
 	if (!vk->wq_thread) {
 		dev_err(dev, "Fail to create workqueue thread\n");
 		err = -ENOMEM;
author reviewer
#14 lore raw

PATCH 8/53 net: amd-xgbe: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +2 -2
index c4a4e316683f..20281f0381be 100644
@@ -1846,14 +1846,14 @@ static int xgbe_open(struct net_device *netdev)
 
 	/* Create workqueues */
 	pdata->dev_workqueue =
-		create_singlethread_workqueue(netdev_name(netdev));
+		create_singlethread_workqueue2("%s", netdev_name(netdev));
 	if (!pdata->dev_workqueue) {
 		netdev_err(netdev, "device workqueue creation failed\n");
 		return -ENOMEM;
 	}
 
 	pdata->an_workqueue =
-		create_singlethread_workqueue(pdata->an_name);
+		create_singlethread_workqueue2("%s", pdata->an_name);
 	if (!pdata->an_workqueue) {
 		netdev_err(netdev, "phy workqueue creation failed\n");
 		ret = -ENOMEM;
author reviewer
#15 lore raw

PATCH 9/53 net: atlantic: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/net/ethernet/aquantia/atlantic/aq_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_main.c +1 -1
index c1d1673c5749..606ec93ba429 100644
@@ -513,7 +513,7 @@ static int __init aq_ndev_init_module(void)
 {
 	int ret;
 
-	aq_ndev_wq = create_singlethread_workqueue(aq_ndev_driver_name);
+	aq_ndev_wq = create_singlethread_workqueue2("%s", aq_ndev_driver_name);
 	if (!aq_ndev_wq) {
 		pr_err("Failed to create workqueue\n");
 		return -ENOMEM;
author reviewer
#16 lore raw

PATCH 10/53 net: mvpp2: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -1
index 9adf4301c9b1..58b104d2f24c 100644
@@ -7635,7 +7635,8 @@ static int mvpp2_probe(struct platform_device *pdev)
 	snprintf(priv->queue_name, sizeof(priv->queue_name),
 		 "stats-wq-%s%s", netdev_name(priv->port_list[0]->dev),
 		 priv->port_count > 1 ? "+" : "");
-	priv->stats_queue = create_singlethread_workqueue(priv->queue_name);
+	priv->stats_queue =
+		create_singlethread_workqueue2("%s", priv->queue_name);
 	if (!priv->stats_queue) {
 		err = -ENOMEM;
 		goto err_port_probe;
author reviewer
#17 lore raw

PATCH 11/53 remoteproc: stm32: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/remoteproc/stm32_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/stm32_rproc.c +1 -1
index 88623df7d0c3..5af6fdc6881c 100644
@@ -867,7 +867,7 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 		rproc->state = RPROC_DETACHED;
 
 	rproc->has_iommu = false;
-	ddata->workqueue = create_workqueue(dev_name(dev));
+	ddata->workqueue = create_workqueue2("%s", dev_name(dev));
 	if (!ddata->workqueue) {
 		dev_err(dev, "cannot create workqueue\n");
 		ret = -ENOMEM;
author reviewer
#18 lore raw

PATCH 12/53 mm/z3fold: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 mm/z3fold.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/z3fold.c +2 -2
index 2ebfed32871b..6fd3a05ecfc6 100644
@@ -934,10 +934,10 @@ static struct z3fold_pool *z3fold_create_pool(const char *name, gfp_t gfp)
 	INIT_LIST_HEAD(&pool->stale);
 	atomic64_set(&pool->pages_nr, 0);
 	pool->name = name;
-	pool->compact_wq = create_singlethread_workqueue(pool->name);
+	pool->compact_wq = create_singlethread_workqueue2("%s", pool->name);
 	if (!pool->compact_wq)
 		goto out_unbuddied;
-	pool->release_wq = create_singlethread_workqueue(pool->name);
+	pool->release_wq = create_singlethread_workqueue2("%s", pool->name);
 	if (!pool->release_wq)
 		goto out_wq;
 	INIT_WORK(&pool->work, free_pages_work);
author reviewer
#19 lore raw

PATCH 13/53 usb: typec: tcpm: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/usb/typec/tcpm/fusb302.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/fusb302.c +1 -1
index ef18a448b740..894e5f6bba60 100644
@@ -1715,7 +1715,7 @@ static int fusb302_probe(struct i2c_client *client)
 	if (IS_ERR(chip->vbus))
 		return PTR_ERR(chip->vbus);
 
-	chip->wq = create_singlethread_workqueue(dev_name(chip->dev));
+	chip->wq = create_singlethread_workqueue2("%s", dev_name(chip->dev));
 	if (!chip->wq)
 		return -ENOMEM;
 
author reviewer
#20 lore raw

PATCH 14/53 net/qla3xxx: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/net/ethernet/qlogic/qla3xxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qla3xxx.c +1 -1
index fc78bc959ded..5912679bd2f0 100644
@@ -3862,7 +3862,7 @@ static int ql3xxx_probe(struct pci_dev *pdev,
 	netif_carrier_off(ndev);
 	netif_stop_queue(ndev);
 
-	qdev->workqueue = create_singlethread_workqueue(ndev->name);
+	qdev->workqueue = create_singlethread_workqueue2("%s", ndev->name);
 	if (!qdev->workqueue) {
 		unregister_netdev(ndev);
 		err = -ENOMEM;
author reviewer
#21 lore raw

PATCH 15/53 sfc: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/net/ethernet/sfc/efx_common.c       | 3 ++-
 drivers/net/ethernet/sfc/falcon/efx.c       | 3 ++-
 drivers/net/ethernet/sfc/siena/efx_common.c | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/sfc/efx_common.c +2 -1
index 4ebd5ae23eca..6dc068d2c295 100644
@@ -1035,7 +1035,8 @@ int efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev)
 	/* Would be good to use the net_dev name, but we're too early */
 	snprintf(efx->workqueue_name, sizeof(efx->workqueue_name), "sfc%s",
 		 pci_name(pci_dev));
-	efx->workqueue = create_singlethread_workqueue(efx->workqueue_name);
+	efx->workqueue =
+		create_singlethread_workqueue2("%s", efx->workqueue_name);
 	if (!efx->workqueue) {
 		rc = -ENOMEM;
 		goto fail;
drivers/net/ethernet/sfc/falcon/efx.c +2 -1
index 8925745f1c17..d4d02e2438c6 100644
@@ -2671,7 +2671,8 @@ static int ef4_init_struct(struct ef4_nic *efx,
 	/* Would be good to use the net_dev name, but we're too early */
 	snprintf(efx->workqueue_name, sizeof(efx->workqueue_name), "sfc%s",
 		 pci_name(pci_dev));
-	efx->workqueue = create_singlethread_workqueue(efx->workqueue_name);
+	efx->workqueue =
+		create_singlethread_workqueue2("%s", efx->workqueue_name);
 	if (!efx->workqueue)
 		goto fail;
 
drivers/net/ethernet/sfc/siena/efx_common.c +2 -1
index cf195162e270..1a1448a75d99 100644
@@ -1050,7 +1050,8 @@ int efx_siena_init_struct(struct efx_nic *efx,
 	/* Would be good to use the net_dev name, but we're too early */
 	snprintf(efx->workqueue_name, sizeof(efx->workqueue_name), "sfc%s",
 		 pci_name(pci_dev));
-	efx->workqueue = create_singlethread_workqueue(efx->workqueue_name);
+	efx->workqueue =
+		create_singlethread_workqueue2("%s", efx->workqueue_name);
 	if (!efx->workqueue) {
 		rc = -ENOMEM;
 		goto fail;
author reviewer
#22 lore raw

PATCH 16/53 wifi: zd1211rw: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/net/wireless/zydas/zd1211rw/zd_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/zydas/zd1211rw/zd_usb.c +1 -1
index f3b567a13ded..54501732cd91 100644
@@ -1542,7 +1542,7 @@ static int __init usb_init(void)
 
 	pr_debug("%s usb_init()\n", driver.name);
 
-	zd_workqueue = create_singlethread_workqueue(driver.name);
+	zd_workqueue = create_singlethread_workqueue2("%s", driver.name);
 	if (zd_workqueue == NULL) {
 		pr_err("%s couldn't create workqueue\n", driver.name);
 		return -ENOMEM;
author reviewer
#23 lore raw

PATCH 17/53 power: supply: mt6370: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/power/supply/mt6370-charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/mt6370-charger.c +1 -1
index e24fce087d80..8843da4dda92 100644
@@ -908,7 +908,7 @@ static int mt6370_chg_probe(struct platform_device *pdev)
 
 	priv->attach = MT6370_ATTACH_STAT_DETACH;
 
-	priv->wq = create_singlethread_workqueue(dev_name(priv->dev));
+	priv->wq = create_singlethread_workqueue2("%s", dev_name(priv->dev));
 	if (!priv->wq)
 		return dev_err_probe(dev, -ENOMEM,
 				     "Failed to create workqueue\n");
author reviewer
#24 lore raw

PATCH 18/53 remoteproc: imx_rproc: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

---
 drivers/remoteproc/imx_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/imx_rproc.c +1 -1
index 5a3fb902acc9..14fe2aca50c4 100644
@@ -1064,7 +1064,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
 	priv->dev = dev;
 
 	dev_set_drvdata(dev, rproc);
-	priv->workqueue = create_workqueue(dev_name(dev));
+	priv->workqueue = create_workqueue("%s", dev_name(dev));
 	if (!priv->workqueue) {
 		dev_err(dev, "cannot create workqueue\n");
 		return -ENOMEM;
author reviewer
#25 lore raw

PATCH 19/53 scsi: hisi_sas: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -1
index ec1a3e7ee94d..ba6f20baf6ae 100644
@@ -2302,7 +2302,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba)
 
 	hisi_hba->last_slot_index = 0;
 
-	hisi_hba->wq = create_singlethread_workqueue(dev_name(dev));
+	hisi_hba->wq = create_singlethread_workqueue2("%s", dev_name(dev));
 	if (!hisi_hba->wq) {
 		dev_err(dev, "sas_alloc: failed to create workqueue\n");
 		goto err_out;
author reviewer
#26 lore raw

PATCH 20/53 scsi: mpt3sas: Switch to create*_workqueue2()

In reply to Bart Van Assche

Prepare for removal of the create*_workqueue() macros.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -2
index b2bcf4a27ddc..2d8a56309ef0 100644
@@ -846,8 +846,8 @@ mpt3sas_base_start_watchdog(struct MPT3SAS_ADAPTER *ioc)
 	snprintf(ioc->fault_reset_work_q_name,
 	    sizeof(ioc->fault_reset_work_q_name), "poll_%s%d_status",
 	    ioc->driver_name, ioc->id);
-	ioc->fault_reset_work_q =
-		create_singlethread_workqueue(ioc->fault_reset_work_q_name);
+	ioc->fault_reset_work_q = create_singlethread_workqueue2(
+		"%s", ioc->fault_reset_work_q_name);
 	if (!ioc->fault_reset_work_q) {
 		ioc_err(ioc, "%s: failed (line=%d)\n", __func__, __LINE__);
 		return;
author reviewer
#27 lore raw

PATCH 21/53 accel/habanalabs: Simplify the workqueue creation calls

In reply to Bart Van Assche

Pass a format string to the workqueue creation calls instead of formatting the workqueue name before a workqueue creation macro is used.

---
 drivers/accel/habanalabs/common/device.c | 25 ++++++++++++------------
 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/accel/habanalabs/common/device.c +12 -13
index 8f92445c5a90..e44c8352c1da 100644
@@ -831,7 +831,6 @@ static void device_release_watchdog_func(struct work_struct *work)
 static int device_early_init(struct hl_device *hdev)
 {
 	int i, rc;
-	char workq_name[32];
 
 	switch (hdev->asic_type) {
 	case ASIC_GOYA:
@@ -883,8 +882,8 @@ static int device_early_init(struct hl_device *hdev)
 	}
 
 	for (i = 0 ; i < hdev->asic_prop.completion_queues_count ; i++) {
-		snprintf(workq_name, 32, "hl%u-free-jobs-%u", hdev->cdev_idx, (u32) i);
-		hdev->cq_wq[i] = create_singlethread_workqueue(workq_name);
+		hdev->cq_wq[i] = create_singlethread_workqueue2(
+			"hl%u-free-jobs-%u", hdev->cdev_idx, i);
 		if (hdev->cq_wq[i] == NULL) {
 			dev_err(hdev->dev, "Failed to allocate CQ workqueue\n");
 			rc = -ENOMEM;
@@ -892,16 +891,16 @@ static int device_early_init(struct hl_device *hdev)
 		}
 	}
 
-	snprintf(workq_name, 32, "hl%u-events", hdev->cdev_idx);
-	hdev->eq_wq = create_singlethread_workqueue(workq_name);
+	hdev->eq_wq =
+		create_singlethread_workqueue2("hl%u-events", hdev->cdev_idx);
 	if (hdev->eq_wq == NULL) {
 		dev_err(hdev->dev, "Failed to allocate EQ workqueue\n");
 		rc = -ENOMEM;
 		goto free_cq_wq;
 	}
 
-	snprintf(workq_name, 32, "hl%u-cs-completions", hdev->cdev_idx);
-	hdev->cs_cmplt_wq = alloc_workqueue(workq_name, WQ_UNBOUND, 0);
+	hdev->cs_cmplt_wq = alloc_workqueue("hl%u-cs-completions", WQ_UNBOUND,
+					    0, hdev->cdev_idx);
 	if (!hdev->cs_cmplt_wq) {
 		dev_err(hdev->dev,
 			"Failed to allocate CS completions workqueue\n");
@@ -909,8 +908,8 @@ static int device_early_init(struct hl_device *hdev)
 		goto free_eq_wq;
 	}
 
-	snprintf(workq_name, 32, "hl%u-ts-free-obj", hdev->cdev_idx);
-	hdev->ts_free_obj_wq = alloc_workqueue(workq_name, WQ_UNBOUND, 0);
+	hdev->ts_free_obj_wq = alloc_workqueue("hl%u-ts-free-obj", WQ_UNBOUND,
+					       0, hdev->cdev_idx);
 	if (!hdev->ts_free_obj_wq) {
 		dev_err(hdev->dev,
 			"Failed to allocate Timestamp registration free workqueue\n");
@@ -918,8 +917,8 @@ static int device_early_init(struct hl_device *hdev)
 		goto free_cs_cmplt_wq;
 	}
 
-	snprintf(workq_name, 32, "hl%u-prefetch", hdev->cdev_idx);
-	hdev->prefetch_wq = alloc_workqueue(workq_name, WQ_UNBOUND, 0);
+	hdev->prefetch_wq =
+		alloc_workqueue("hl%u-prefetch", WQ_UNBOUND, 0, hdev->cdev_idx);
 	if (!hdev->prefetch_wq) {
 		dev_err(hdev->dev, "Failed to allocate MMU prefetch workqueue\n");
 		rc = -ENOMEM;
@@ -938,8 +937,8 @@ static int device_early_init(struct hl_device *hdev)
 
 	hl_mem_mgr_init(hdev->dev, &hdev->kernel_mem_mgr);
 
-	snprintf(workq_name, 32, "hl%u_device_reset", hdev->cdev_idx);
-	hdev->reset_wq = create_singlethread_workqueue(workq_name);
+	hdev->reset_wq = create_singlethread_workqueue2("hl%u_device_reset",
+							hdev->cdev_idx);
 	if (!hdev->reset_wq) {
 		rc = -ENOMEM;
 		dev_err(hdev->dev, "Failed to create device reset WQ\n");
author reviewer
#28 lore raw

PATCH 22/53 crypto: safexcel - Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/crypto/inside-secure/safexcel.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/crypto/inside-secure/safexcel.c +1 -3
index f5c1912aa564..45cff3adc71d 100644
@@ -1615,7 +1615,6 @@ static int safexcel_probe_generic(void *pdev,
 		return -ENOMEM;
 
 	for (i = 0; i < priv->config.rings; i++) {
-		char wq_name[9] = {0};
 		int irq;
 		struct safexcel_ring_irq_data *ring_irq;
 
@@ -1664,9 +1663,8 @@ static int safexcel_probe_generic(void *pdev,
 		INIT_WORK(&priv->ring[i].work_data.work,
 			  safexcel_dequeue_work);
 
-		snprintf(wq_name, 9, "wq_ring%d", i);
 		priv->ring[i].workqueue =
-			create_singlethread_workqueue(wq_name);
+			create_singlethread_workqueue2("wq_ring%d", i);
 		if (!priv->ring[i].workqueue) {
 			ret = -ENOMEM;
 			goto err_cleanup_rings;
author reviewer
#29 lore raw

PATCH 23/53 pds_core: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/net/ethernet/amd/pds_core/main.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/amd/pds_core/main.c +2 -5
index 660268ff9562..e2e49656c111 100644
@@ -213,12 +213,9 @@ static const struct devlink_param pdsc_dl_params[] = {
 			      pdsc_dl_enable_validate),
 };
 
-#define PDSC_WQ_NAME_LEN 24
-
 static int pdsc_init_pf(struct pdsc *pdsc)
 {
 	struct devlink_health_reporter *hr;
-	char wq_name[PDSC_WQ_NAME_LEN];
 	struct devlink *dl;
 	int err;
 
@@ -236,8 +233,8 @@ static int pdsc_init_pf(struct pdsc *pdsc)
 		goto err_out_release_regions;
 
 	/* General workqueue and timer, but don't start timer yet */
-	snprintf(wq_name, sizeof(wq_name), "%s.%d", PDS_CORE_DRV_NAME, pdsc->uid);
-	pdsc->wq = create_singlethread_workqueue(wq_name);
+	pdsc->wq = create_singlethread_workqueue2("%s.%d", PDS_CORE_DRV_NAME,
+						  pdsc->uid);
 	INIT_WORK(&pdsc->health_work, pdsc_health_thread);
 	INIT_WORK(&pdsc->pci_reset_work, pdsc_pci_reset_thread);
 	timer_setup(&pdsc->wdtimer, pdsc_wdtimer_cb, 0);
Reviewed-by on v1 23/53
#30 lore raw

Re: [PATCH 23/53] pds_core: Simplify a create*_workqueue() call

Quoted 29 lines · Bart Van Assche

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
  drivers/net/ethernet/amd/pds_core/main.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/amd/pds_core/main.c +0 -3
index 660268ff9562..e2e49656c111 100644
@@ -213,12 +213,9 @@ static const struct devlink_param pdsc_dl_params[] = {
                               pdsc_dl_enable_validate),
  };
 
-#define PDSC_WQ_NAME_LEN 24
-
  static int pdsc_init_pf(struct pdsc *pdsc)
  {
         struct devlink_health_reporter *hr;
-       char wq_name[PDSC_WQ_NAME_LEN];
         struct devlink *dl;
         int err;
 

drivers/net/ethernet/amd/pds_core/main.c static int pdsc_init_pf(struct pdsc *pdsc) · line 237

Quoted 7 lines
drivers/net/ethernet/amd/pds_core/main.c +2 -2
@@ -236,8 +233,8 @@ static int pdsc_init_pf(struct pdsc *pdsc)
                 goto err_out_release_regions;
 
         /* General workqueue and timer, but don't start timer yet */
-       snprintf(wq_name, sizeof(wq_name), "%s.%d", PDS_CORE_DRV_NAME, pdsc->uid);
-       pdsc->wq = create_singlethread_workqueue(wq_name);
+       pdsc->wq = create_singlethread_workqueue2("%s.%d", PDS_CORE_DRV_NAME,
+                                                 pdsc->uid);

LGTM. Thanks.

BTW, I don't actually see patch 53/53 that renames *workqueue2() -> *workqueue(). Am I missing something here? It's mentioned in the cover letter, but I don't see it on the series thread.

Brett

Quoted 3 lines
drivers/net/ethernet/amd/pds_core/main.c +0 -0
         INIT_WORK(&pdsc->health_work, pdsc_health_thread);
         INIT_WORK(&pdsc->pci_reset_work, pdsc_pci_reset_thread);
         timer_setup(&pdsc->wdtimer, pdsc_wdtimer_cb, 0);
author reviewer
#31 lore raw

Re: [PATCH 23/53] pds_core: Simplify a create*_workqueue() call

Quoted 7 lines · Brett Creeley

LGTM. Thanks.

BTW, I don't actually see patch 53/53 that renames *workqueue2() -> *workqueue(). Am I missing something here? It's mentioned in the cover letter, but I don't see it on the series thread.

Hi Brett,

I don't see patch 53/53 either on Lore. Maybe I hit an outgoing mail limit when I sent out this patch series.

Note: as one can see from Tejun's reply to the cover letter I will have to rework this patch series so I'm not sure whether it's useful that I make patch 53/53 available now.

Thanks,

Bart.

author reviewer
#32 lore raw

PATCH 24/53 net: bna: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/net/ethernet/brocade/bna/bnad.c | 4 ++--
 drivers/net/ethernet/brocade/bna/bnad.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +2 -2
index fe121d36112d..7d482e8b0949 100644
@@ -3488,8 +3488,8 @@ bnad_init(struct bnad *bnad,
 	bnad->tx_coalescing_timeo = BFI_TX_COALESCING_TIMEO;
 	bnad->rx_coalescing_timeo = BFI_RX_COALESCING_TIMEO;
 
-	sprintf(bnad->wq_name, "%s_wq_%d", BNAD_NAME, bnad->id);
-	bnad->work_q = create_singlethread_workqueue(bnad->wq_name);
+	bnad->work_q =
+		create_singlethread_workqueue2("%s_wq_%d", BNAD_NAME, bnad->id);
 	if (!bnad->work_q) {
 		iounmap(bnad->bar0);
 		return -ENOMEM;
drivers/net/ethernet/brocade/bna/bnad.h +0 -1
index 10b1e534030e..0d70b1df1793 100644
@@ -346,7 +346,6 @@ struct bnad {
 	char			adapter_name[BNAD_NAME_LEN];
 	char			port_name[BNAD_NAME_LEN];
 	char			mbox_irq_name[BNAD_NAME_LEN];
-	char			wq_name[BNAD_NAME_LEN];
 
 	/* debugfs specific data */
 	char	*regdata;
author reviewer
#33 lore raw

PATCH 25/53 net/mlx5: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c        | 12 ++----------
 drivers/net/ethernet/mellanox/mlx5/core/health.c     | 10 ++--------
 .../net/ethernet/mellanox/mlx5/core/sf/vhca_event.c  |  5 ++---
 include/linux/mlx5/driver.h                          |  5 -----
 4 files changed, 6 insertions(+), 26 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +2 -10
index 20768ef2e9d2..bbc7d0f2fd40 100644
@@ -1560,14 +1560,6 @@ static const struct file_operations olfops = {
 	.read	= outlen_read,
 };
 
-static void set_wqname(struct mlx5_core_dev *dev)
-{
-	struct mlx5_cmd *cmd = &dev->cmd;
-
-	snprintf(cmd->wq_name, sizeof(cmd->wq_name), "mlx5_cmd_%s",
-		 dev_name(dev->device));
-}
-
 static void clean_debug_files(struct mlx5_core_dev *dev)
 {
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
@@ -2292,8 +2284,8 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 	spin_lock_init(&cmd->alloc_lock);
 	spin_lock_init(&cmd->token_lock);
 
-	set_wqname(dev);
-	cmd->wq = create_singlethread_workqueue(cmd->wq_name);
+	cmd->wq = create_singlethread_workqueue2("mlx5_cmd_%s",
+						 dev_name(dev->device));
 	if (!cmd->wq) {
 		mlx5_core_err(dev, "failed to create command workqueue\n");
 		return -ENOMEM;
drivers/net/ethernet/mellanox/mlx5/core/health.c +2 -8
index a6329ca2d9bf..1c46bced73cd 100644
@@ -869,7 +869,6 @@ int mlx5_health_init(struct mlx5_core_dev *dev)
 {
 	struct devlink *devlink = priv_to_devlink(dev);
 	struct mlx5_core_health *health;
-	char *name;
 
 	if (!mlx5_dev_is_lightweight(dev)) {
 		devl_lock(devlink);
@@ -879,14 +878,9 @@ int mlx5_health_init(struct mlx5_core_dev *dev)
 	mlx5_reporter_vnic_create(dev);
 
 	health = &dev->priv.health;
-	name = kmalloc(64, GFP_KERNEL);
-	if (!name)
-		goto out_err;
 
-	strcpy(name, "mlx5_health");
-	strcat(name, dev_name(dev->device));
-	health->wq = create_singlethread_workqueue(name);
-	kfree(name);
+	health->wq = create_singlethread_workqueue2("mlx5_health%s",
+						    dev_name(dev->device));
 	if (!health->wq)
 		goto out_err;
 	INIT_WORK(&health->fatal_report_work, mlx5_fw_fatal_reporter_err_work);
drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c +2 -3
index cda01ba441ae..b761350617df 100644
@@ -148,7 +148,6 @@ void mlx5_vhca_state_cap_handle(struct mlx5_core_dev *dev, void *set_hca_cap)
 int mlx5_vhca_event_init(struct mlx5_core_dev *dev)
 {
 	struct mlx5_vhca_state_notifier *notifier;
-	char wq_name[MLX5_CMD_WQ_MAX_NAME];
 	struct mlx5_vhca_events *events;
 	int err, i;
 
@@ -162,8 +161,8 @@ int mlx5_vhca_event_init(struct mlx5_core_dev *dev)
 	events->dev = dev;
 	dev->priv.vhca_events = events;
 	for (i = 0; i < MLX5_DEV_MAX_WQS; i++) {
-		snprintf(wq_name, MLX5_CMD_WQ_MAX_NAME, "mlx5_vhca_event%d", i);
-		events->handler[i].wq = create_singlethread_workqueue(wq_name);
+		events->handler[i].wq =
+			create_singlethread_workqueue2("mlx5_vhca_event%d", i);
 		if (!events->handler[i].wq) {
 			err = -ENOMEM;
 			goto err_create_wq;
include/linux/mlx5/driver.h +0 -5
index 779cfdf2e9d6..835b960b9fdc 100644
@@ -66,10 +66,6 @@ enum {
 	MLX5_BOARD_ID_LEN = 64,
 };
 
-enum {
-	MLX5_CMD_WQ_MAX_NAME	= 32,
-};
-
 enum {
 	CMD_OWNER_SW		= 0x0,
 	CMD_OWNER_HW		= 0x1,
@@ -317,7 +313,6 @@ struct mlx5_cmd {
 	 */
 	spinlock_t	token_lock;
 	u8		token;
-	char		wq_name[MLX5_CMD_WQ_MAX_NAME];
 	struct workqueue_struct *wq;
 	int	mode;
 	u16     allowed_opcode;
author reviewer
#34 lore raw

PATCH 26/53 net: lan966x: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c +2 -5
index 06811c60d598..69e6bb0cc44d 100644
@@ -701,8 +701,6 @@ void lan966x_stats_get(struct net_device *dev,
 
 int lan966x_stats_init(struct lan966x *lan966x)
 {
-	char queue_name[32];
-
 	lan966x->stats_layout = lan966x_stats_layout;
 	lan966x->num_stats = ARRAY_SIZE(lan966x_stats_layout);
 	lan966x->stats = devm_kcalloc(lan966x->dev, lan966x->num_phys_ports *
@@ -713,9 +711,8 @@ int lan966x_stats_init(struct lan966x *lan966x)
 
 	/* Init stats worker */
 	mutex_init(&lan966x->stats_lock);
-	snprintf(queue_name, sizeof(queue_name), "%s-stats",
-		 dev_name(lan966x->dev));
-	lan966x->stats_queue = create_singlethread_workqueue(queue_name);
+	lan966x->stats_queue = create_singlethread_workqueue2(
+		"%s-stats", dev_name(lan966x->dev));
 	if (!lan966x->stats_queue)
 		return -ENOMEM;
 
author reviewer
#35 lore raw

PATCH 27/53 net: sparx5: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c | 6 ++----
 drivers/net/ethernet/microchip/sparx5/sparx5_main.c    | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c +2 -4
index a06dc5a9b355..e15736831747 100644
@@ -1231,7 +1231,6 @@ const struct ethtool_ops sparx5_ethtool_ops = {
 
 int sparx_stats_init(struct sparx5 *sparx5)
 {
-	char queue_name[32];
 	int portno;
 
 	sparx5->stats_layout = sparx5_stats_layout;
@@ -1249,9 +1248,8 @@ int sparx_stats_init(struct sparx5 *sparx5)
 		if (sparx5->ports[portno])
 			sparx5_config_port_stats(sparx5, portno);
 
-	snprintf(queue_name, sizeof(queue_name), "%s-stats",
-		 dev_name(sparx5->dev));
-	sparx5->stats_queue = create_singlethread_workqueue(queue_name);
+	sparx5->stats_queue = create_singlethread_workqueue2(
+		"%s-stats", dev_name(sparx5->dev));
 	if (!sparx5->stats_queue)
 		return -ENOMEM;
 
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +2 -4
index b64c814eac11..39c87e85fb8c 100644
@@ -596,7 +596,6 @@ static void sparx5_board_init(struct sparx5 *sparx5)
 static int sparx5_start(struct sparx5 *sparx5)
 {
 	u8 broadcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-	char queue_name[32];
 	u32 idx;
 	int err;
 
@@ -661,9 +660,8 @@ static int sparx5_start(struct sparx5 *sparx5)
 	/* Init mact_sw struct */
 	mutex_init(&sparx5->mact_lock);
 	INIT_LIST_HEAD(&sparx5->mact_entries);
-	snprintf(queue_name, sizeof(queue_name), "%s-mact",
-		 dev_name(sparx5->dev));
-	sparx5->mact_queue = create_singlethread_workqueue(queue_name);
+	sparx5->mact_queue =
+		create_singlethread_workqueue2("%s-mact", dev_name(sparx5->dev));
 	if (!sparx5->mact_queue)
 		return -ENOMEM;
 
author reviewer
#36 lore raw

PATCH 28/53 net: mscc: ocelot: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/net/ethernet/mscc/ocelot_stats.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/mscc/ocelot_stats.c +2 -4
index c018783757fb..55bb6fac6e36 100644
@@ -951,7 +951,6 @@ static int ocelot_prepare_stats_regions(struct ocelot *ocelot)
 
 int ocelot_stats_init(struct ocelot *ocelot)
 {
-	char queue_name[32];
 	int ret;
 
 	ocelot->stats = devm_kcalloc(ocelot->dev,
@@ -960,9 +959,8 @@ int ocelot_stats_init(struct ocelot *ocelot)
 	if (!ocelot->stats)
 		return -ENOMEM;
 
-	snprintf(queue_name, sizeof(queue_name), "%s-stats",
-		 dev_name(ocelot->dev));
-	ocelot->stats_queue = create_singlethread_workqueue(queue_name);
+	ocelot->stats_queue = create_singlethread_workqueue2(
+		"%s-stats", dev_name(ocelot->dev));
 	if (!ocelot->stats_queue)
 		return -ENOMEM;
 
author reviewer
#37 lore raw

PATCH 29/53 net: qed: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/net/ethernet/qlogic/qed/qed_sriov.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_sriov.c +3 -6
index fa167b1aa019..29c5b301bbd7 100644
@@ -5262,7 +5262,6 @@ void qed_iov_wq_stop(struct qed_dev *cdev, bool schedule_first)
 
 int qed_iov_wq_start(struct qed_dev *cdev)
 {
-	char name[NAME_SIZE];
 	int i;
 
 	for_each_hwfn(cdev, i) {
@@ -5274,11 +5273,9 @@ int qed_iov_wq_start(struct qed_dev *cdev)
 		if (IS_PF(p_hwfn->cdev) && !IS_PF_SRIOV(p_hwfn))
 			continue;
 
-		snprintf(name, NAME_SIZE, "iov-%02x:%02x.%02x",
-			 cdev->pdev->bus->number,
-			 PCI_SLOT(cdev->pdev->devfn), p_hwfn->abs_pf_id);
-
-		p_hwfn->iov_wq = create_singlethread_workqueue(name);
+		p_hwfn->iov_wq = create_singlethread_workqueue2(
+			"iov-%02x:%02x.%02x", cdev->pdev->bus->number,
+			PCI_SLOT(cdev->pdev->devfn), p_hwfn->abs_pf_id);
 		if (!p_hwfn->iov_wq) {
 			DP_NOTICE(p_hwfn, "Cannot create iov workqueue\n");
 			return -ENOMEM;
author reviewer
#38 lore raw

PATCH 30/53 net: stmmac: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h      |  1 -
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 ++++-------
 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +0 -1
index b23b920eedb1..b47528ad4fb6 100644
@@ -343,7 +343,6 @@ struct stmmac_priv {
 	unsigned long fpe_task_state;
 	struct workqueue_struct *fpe_wq;
 	struct work_struct fpe_task;
-	char wq_name[IFNAMSIZ + 4];
 
 	/* TC Handling */
 	unsigned int tc_entries_max;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -7
index b3afc7cb7d72..42d0e2e630c9 100644
@@ -3362,17 +3362,14 @@ static void stmmac_safety_feat_configuration(struct stmmac_priv *priv)
 
 static int stmmac_fpe_start_wq(struct stmmac_priv *priv)
 {
-	char *name;
-
 	clear_bit(__FPE_TASK_SCHED, &priv->fpe_task_state);
 	clear_bit(__FPE_REMOVING,  &priv->fpe_task_state);
 
-	name = priv->wq_name;
-	sprintf(name, "%s-fpe", priv->dev->name);
-
-	priv->fpe_wq = create_singlethread_workqueue(name);
+	priv->fpe_wq =
+		create_singlethread_workqueue2("%s-fpe", priv->dev->name);
 	if (!priv->fpe_wq) {
-		netdev_err(priv->dev, "%s: Failed to create workqueue\n", name);
+		netdev_err(priv->dev, "%s: Failed to create workqueue\n",
+			   __func__);
 
 		return -ENOMEM;
 	}
author reviewer
#39 lore raw

PATCH 31/53 nfc: mrvl: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/nfc/nfcmrvl/fw_dnld.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/nfc/nfcmrvl/fw_dnld.c +3 -5
index e83f65596a88..fc8d9466422d 100644
@@ -442,12 +442,10 @@ static void fw_dnld_rx_work(struct work_struct *work)
 
 int nfcmrvl_fw_dnld_init(struct nfcmrvl_private *priv)
 {
-	char name[32];
-
 	INIT_WORK(&priv->fw_dnld.rx_work, fw_dnld_rx_work);
-	snprintf(name, sizeof(name), "%s_nfcmrvl_fw_dnld_rx_wq",
-		 dev_name(&priv->ndev->nfc_dev->dev));
-	priv->fw_dnld.rx_wq = create_singlethread_workqueue(name);
+	priv->fw_dnld.rx_wq = create_singlethread_workqueue2(
+		"%s_nfcmrvl_fw_dnld_rx_wq",
+		dev_name(&priv->ndev->nfc_dev->dev));
 	if (!priv->fw_dnld.rx_wq)
 		return -ENOMEM;
 	skb_queue_head_init(&priv->fw_dnld.rx_q);
#40 lore raw

Re: [PATCH 31/53] nfc: mrvl: Simplify a create*_workqueue() call

Quoted 6 lines · Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/nfc/nfcmrvl/fw_dnld.c | 8 +++-----

I only got this patch, no links to new API being introduced and there is no create_singlethread_workqueue2() call. Looks fine, but tricky to review. Provide first patch or lore link in patch changelog.

Best regards,
Krzysztof

author reviewer
#41 lore raw

Re: [PATCH 31/53] nfc: mrvl: Simplify a create*_workqueue() call

Quoted 11 lines · Krzysztof Kozlowski
Quoted 6 lines · Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
  drivers/nfc/nfcmrvl/fw_dnld.c | 8 +++-----

I only got this patch, no links to new API being introduced and there is no create_singlethread_workqueue2() call. Looks fine, but tricky to review. Provide first patch or lore link in patch changelog.

Thanks for the advice. I will do this if I have to repost this patch series.

This is the link to the entire patch series:
https://lore.kernel.org/linux-kernel/[email protected]/

Further feedback is welcome.

Thanks,

Bart.

author reviewer
#43 lore raw

PATCH 32/53 scsi: ibmvscsi_tgt: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +1 -3
index 2fca17cf8b51..a106e3a1b833 100644
@@ -3425,7 +3425,6 @@ static int ibmvscsis_probe(struct vio_dev *vdev,
 	struct scsi_info *vscsi;
 	int rc = 0;
 	long hrc = 0;
-	char wq_name[24];
 
 	vscsi = kzalloc(sizeof(*vscsi), GFP_KERNEL);
 	if (!vscsi) {
@@ -3536,8 +3535,7 @@ static int ibmvscsis_probe(struct vio_dev *vdev,
 	init_completion(&vscsi->wait_idle);
 	init_completion(&vscsi->unconfig);
 
-	snprintf(wq_name, 24, "ibmvscsis%s", dev_name(&vdev->dev));
-	vscsi->work_q = create_workqueue(wq_name);
+	vscsi->work_q = create_workqueue2("ibmvscsis%s", dev_name(&vdev->dev));
 	if (!vscsi->work_q) {
 		rc = -ENOMEM;
 		dev_err(&vscsi->dev, "create_workqueue failed\n");
author reviewer
#44 lore raw

PATCH 33/53 scsi: libsas: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/libsas/sas_init.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/scsi/libsas/sas_init.c +4 -5
index 9c8cc723170d..e7d2edf9e635 100644
@@ -92,7 +92,6 @@ void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
 
 int sas_register_ha(struct sas_ha_struct *sas_ha)
 {
-	char name[64];
 	int error = 0;
 
 	mutex_init(&sas_ha->disco_mutex);
@@ -121,13 +120,13 @@ int sas_register_ha(struct sas_ha_struct *sas_ha)
 	}
 
 	error = -ENOMEM;
-	snprintf(name, sizeof(name), "%s_event_q", dev_name(sas_ha->dev));
-	sas_ha->event_q = create_singlethread_workqueue(name);
+	sas_ha->event_q = create_singlethread_workqueue2("%s_event_q",
+							 dev_name(sas_ha->dev));
 	if (!sas_ha->event_q)
 		goto Undo_ports;
 
-	snprintf(name, sizeof(name), "%s_disco_q", dev_name(sas_ha->dev));
-	sas_ha->disco_q = create_singlethread_workqueue(name);
+	sas_ha->disco_q = create_singlethread_workqueue2("%s_disco_q",
+							 dev_name(sas_ha->dev));
 	if (!sas_ha->disco_q)
 		goto Undo_event_q;
 
Reviewed-by on v1 33/53
#45 lore raw

Re: [PATCH 33/53] scsi: libsas: Simplify the create*_workqueue() calls

Quoted 5 lines · Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>

Looks good.

Signature · 2 lines
Damien Le Moal
Western Digital Research
reviewer Reviewed-by on v1 33/53
#46 lore raw

Re: [PATCH 33/53] scsi: libsas: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Bart Van Assche 於 2024/7/1 6:26 寫道:

Quoted 8 lines

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
  drivers/scsi/libsas/sas_init.c | 9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)

祝一切顺利

author reviewer
#47 lore raw

PATCH 34/53 scsi: mpi3mr: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/mpi3mr/mpi3mr_fw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_fw.c +2 -2
index c2a22e96f7b7..d0dfd0c43f71 100644
@@ -2689,8 +2689,8 @@ void mpi3mr_start_watchdog(struct mpi3mr_ioc *mrioc)
 	snprintf(mrioc->watchdog_work_q_name,
 	    sizeof(mrioc->watchdog_work_q_name), "watchdog_%s%d", mrioc->name,
 	    mrioc->id);
-	mrioc->watchdog_work_q =
-	    create_singlethread_workqueue(mrioc->watchdog_work_q_name);
+	mrioc->watchdog_work_q = create_singlethread_workqueue2(
+		"%s", mrioc->watchdog_work_q_name);
 	if (!mrioc->watchdog_work_q) {
 		ioc_err(mrioc, "%s: failed (line=%d)\n", __func__, __LINE__);
 		return;
author reviewer
#48 lore raw

PATCH 35/53 scsi: qedf: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/qedf/qedf_main.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/scsi/qedf/qedf_main.c +6 -11
index 49adddf978cc..ffbd67a46368 100644
@@ -3372,9 +3372,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 	QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_INFO, "qedf->io_mempool=%p.\n",
 	    qedf->io_mempool);
 
-	sprintf(host_buf, "qedf_%u_link",
-	    qedf->lport->host->host_no);
-	qedf->link_update_wq = create_workqueue(host_buf);
+	qedf->link_update_wq =
+		create_workqueue2("qedf_%u_link", qedf->lport->host->host_no);
 	INIT_DELAYED_WORK(&qedf->link_update, qedf_handle_link_update);
 	INIT_DELAYED_WORK(&qedf->link_recovery, qedf_link_recovery);
 	INIT_DELAYED_WORK(&qedf->grcdump_work, qedf_wq_grcdump);
@@ -3584,9 +3583,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 	ether_addr_copy(params.ll2_mac_address, qedf->mac);
 
 	/* Start LL2 processing thread */
-	snprintf(host_buf, 20, "qedf_%d_ll2", host->host_no);
-	qedf->ll2_recv_wq =
-		create_workqueue(host_buf);
+	qedf->ll2_recv_wq = create_workqueue2("qedf_%d_ll2", host->host_no);
 	if (!qedf->ll2_recv_wq) {
 		QEDF_ERR(&(qedf->dbg_ctx), "Failed to LL2 workqueue.\n");
 		rc = -ENOMEM;
@@ -3627,9 +3624,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 		}
 	}
 
-	sprintf(host_buf, "qedf_%u_timer", qedf->lport->host->host_no);
 	qedf->timer_work_queue =
-		create_workqueue(host_buf);
+		create_workqueue2("qedf_%u_timer", qedf->lport->host->host_no);
 	if (!qedf->timer_work_queue) {
 		QEDF_ERR(&(qedf->dbg_ctx), "Failed to start timer "
 			  "workqueue.\n");
@@ -3639,9 +3635,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 
 	/* DPC workqueue is not reaped during recovery unload */
 	if (mode != QEDF_MODE_RECOVERY) {
-		sprintf(host_buf, "qedf_%u_dpc",
-		    qedf->lport->host->host_no);
-		qedf->dpc_wq = create_workqueue(host_buf);
+		qedf->dpc_wq = create_workqueue2("qedf_%u_dpc",
+						 qedf->lport->host->host_no);
 	}
 	INIT_DELAYED_WORK(&qedf->recovery_work, qedf_recovery_handler);
 
author reviewer
#49 lore raw

PATCH 36/53 scsi: qedi: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/qedi/qedi_main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/qedi/qedi_main.c +4 -4
index cd0180b1f5b9..09da8209095a 100644
@@ -2766,8 +2766,8 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
 			goto free_cid_que;
 		}
 
-		sprintf(host_buf, "host_%d", qedi->shost->host_no);
-		qedi->tmf_thread = create_singlethread_workqueue(host_buf);
+		qedi->tmf_thread = create_singlethread_workqueue2(
+			"host_%d", qedi->shost->host_no);
 		if (!qedi->tmf_thread) {
 			QEDI_ERR(&qedi->dbg_ctx,
 				 "Unable to start tmf thread!\n");
@@ -2775,8 +2775,8 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
 			goto free_cid_que;
 		}
 
-		sprintf(host_buf, "qedi_ofld%d", qedi->shost->host_no);
-		qedi->offload_thread = create_workqueue(host_buf);
+		qedi->offload_thread =
+			create_workqueue2("qedi_ofld%d", qedi->shost->host_no);
 		if (!qedi->offload_thread) {
 			QEDI_ERR(&qedi->dbg_ctx,
 				 "Unable to start offload thread!\n");
author reviewer
#50 lore raw

PATCH 37/53 scsi: qla2xxx: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/qla2xxx/qla_os.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +5 -5
index fcb06df2ce4e..f3f4972962f0 100644
@@ -2915,7 +2915,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 	scsi_qla_host_t *base_vha = NULL;
 	struct qla_hw_data *ha;
 	char pci_info[30];
-	char fw_str[30], wq_name[30];
+	char fw_str[30];
 	struct scsi_host_template *sht;
 	int bars, mem_only = 0;
 	uint16_t req_length = 0, rsp_length = 0;
@@ -3505,12 +3505,12 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 	INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error);
 
 	if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) {
-		sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no);
-		ha->dpc_lp_wq = create_singlethread_workqueue(wq_name);
+		ha->dpc_lp_wq = create_singlethread_workqueue2(
+			"qla2xxx_%lu_dpc_lp_wq", base_vha->host_no);
 		INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen);
 
-		sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no);
-		ha->dpc_hp_wq = create_singlethread_workqueue(wq_name);
+		ha->dpc_hp_wq = create_singlethread_workqueue2(
+			"qla2xxx_%lu_dpc_hp_wq", base_vha->host_no);
 		INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work);
 		INIT_WORK(&ha->idc_state_handler,
 		    qla83xx_idc_state_handler_work);
author reviewer
#51 lore raw

PATCH 38/53 scsi: qla4xxx: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/qla4xxx/ql4_os.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +2 -3
index 17cccd14765f..267c459376ed 100644
@@ -8630,7 +8630,6 @@ static int qla4xxx_probe_adapter(struct pci_dev *pdev,
 	struct Scsi_Host *host;
 	struct scsi_qla_host *ha;
 	uint8_t init_retry_count = 0;
-	char buf[34];
 	struct qla4_8xxx_legacy_intr_set *nx_legacy_intr;
 	uint32_t dev_state;
 
@@ -8805,8 +8804,8 @@ static int qla4xxx_probe_adapter(struct pci_dev *pdev,
 	/* Startup the kernel thread for this host adapter. */
 	DEBUG2(printk("scsi: %s: Starting kernel thread for "
 		      "qla4xxx_dpc\n", __func__));
-	sprintf(buf, "qla4xxx_%lu_dpc", ha->host_no);
-	ha->dpc_thread = create_singlethread_workqueue(buf);
+	ha->dpc_thread =
+		create_singlethread_workqueue2("qla4xxx_%lu_dpc", ha->host_no);
 	if (!ha->dpc_thread) {
 		ql4_printk(KERN_WARNING, ha, "Unable to start DPC thread!\n");
 		ret = -ENODEV;
author reviewer
#52 lore raw

PATCH 39/53 scsi: vmw_pvscsi: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/vmw_pvscsi.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/vmw_pvscsi.c +2 -6
index c4fea077265e..40ad8a3a32e0 100644
@@ -1123,8 +1123,6 @@ static void pvscsi_msg_workqueue_handler(struct work_struct *data)
 
 static int pvscsi_setup_msg_workqueue(struct pvscsi_adapter *adapter)
 {
-	char name[32];
-
 	if (!pvscsi_use_msg)
 		return 0;
 
@@ -1134,10 +1132,8 @@ static int pvscsi_setup_msg_workqueue(struct pvscsi_adapter *adapter)
 	if (pvscsi_reg_read(adapter, PVSCSI_REG_OFFSET_COMMAND_STATUS) == -1)
 		return 0;
 
-	snprintf(name, sizeof(name),
-		 "vmw_pvscsi_wq_%u", adapter->host->host_no);
-
-	adapter->workqueue = create_singlethread_workqueue(name);
+	adapter->workqueue = create_singlethread_workqueue2(
+		"vmw_pvscsi_wq_%u", adapter->host->host_no);
 	if (!adapter->workqueue) {
 		printk(KERN_ERR "vmw_pvscsi: failed to create work queue\n");
 		return 0;
author reviewer
#53 lore raw

PATCH 40/53 scsi: myrb: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/myrb.c | 5 ++---
 drivers/scsi/myrb.h | 1 -
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/myrb.c +2 -3
index f684eb5e0489..6e8f056c0939 100644
@@ -112,9 +112,8 @@ static bool myrb_create_mempools(struct pci_dev *pdev, struct myrb_hba *cb)
 		return false;
 	}
 
-	snprintf(cb->work_q_name, sizeof(cb->work_q_name),
-		 "myrb_wq_%d", cb->host->host_no);
-	cb->work_q = create_singlethread_workqueue(cb->work_q_name);
+	cb->work_q =
+		create_singlethread_workqueue2("myrb_wq_%d", cb->host->host_no);
 	if (!cb->work_q) {
 		dma_pool_destroy(cb->dcdb_pool);
 		cb->dcdb_pool = NULL;
drivers/scsi/myrb.h +0 -1
index fb8eacfceee8..78dc4136fb10 100644
@@ -712,7 +712,6 @@ struct myrb_hba {
 	struct Scsi_Host *host;
 
 	struct workqueue_struct *work_q;
-	char work_q_name[20];
 	struct delayed_work monitor_work;
 	unsigned long primary_monitor_time;
 	unsigned long secondary_monitor_time;
author reviewer
#54 lore raw

PATCH 41/53 scsi: myrs: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/myrs.c | 5 ++---
 drivers/scsi/myrs.h | 1 -
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/myrs.c +2 -3
index e824be9d9bbb..768475f1b3d8 100644
@@ -2206,9 +2206,8 @@ static bool myrs_create_mempools(struct pci_dev *pdev, struct myrs_hba *cs)
 		return false;
 	}
 
-	snprintf(cs->work_q_name, sizeof(cs->work_q_name),
-		 "myrs_wq_%d", shost->host_no);
-	cs->work_q = create_singlethread_workqueue(cs->work_q_name);
+	cs->work_q =
+		create_singlethread_workqueue2("myrs_wq_%d", shost->host_no);
 	if (!cs->work_q) {
 		dma_pool_destroy(cs->dcdb_pool);
 		cs->dcdb_pool = NULL;
drivers/scsi/myrs.h +0 -1
index 9f6696d0ddd5..e1d6b123de7b 100644
@@ -904,7 +904,6 @@ struct myrs_hba {
 	bool disable_enc_msg;
 
 	struct workqueue_struct *work_q;
-	char work_q_name[20];
 	struct delayed_work monitor_work;
 	unsigned long primary_monitor_time;
 	unsigned long secondary_monitor_time;
author reviewer
#55 lore raw

PATCH 42/53 scsi: stex: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/stex.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/stex.c +2 -4
index 8ffb75be99bc..5c88f6a8249e 100644
@@ -334,7 +334,6 @@ struct st_hba {
 	struct st_ccb *wait_ccb;
 	__le32 *scratch;
 
-	char work_q_name[20];
 	struct workqueue_struct *work_q;
 	struct work_struct reset_work;
 	wait_queue_head_t reset_waitq;
@@ -1795,9 +1794,8 @@ static int stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	hba->pdev = pdev;
 	init_waitqueue_head(&hba->reset_waitq);
 
-	snprintf(hba->work_q_name, sizeof(hba->work_q_name),
-		 "stex_wq_%d", host->host_no);
-	hba->work_q = create_singlethread_workqueue(hba->work_q_name);
+	hba->work_q =
+		create_singlethread_workqueue2("stex_wq_%d", host->host_no);
 	if (!hba->work_q) {
 		printk(KERN_ERR DRV_NAME "(%s): create workqueue failed\n",
 			pci_name(pdev));
author reviewer
#56 lore raw

PATCH 43/53 scsi: fcoe: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/fcoe/fcoe_sysfs.c | 7 +------
 include/scsi/fcoe_sysfs.h      | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/scsi/fcoe/fcoe_sysfs.c +1 -6
index 453665ac6020..d534f4007399 100644
@@ -45,8 +45,6 @@ MODULE_PARM_DESC(fcf_dev_loss_tmo,
  */
 #define fcoe_ctlr_id(x)				\
 	((x)->id)
-#define fcoe_ctlr_work_q_name(x)		\
-	((x)->work_q_name)
 #define fcoe_ctlr_work_q(x)			\
 	((x)->work_q)
 #define fcoe_ctlr_devloss_work_q_name(x)	\
@@ -797,10 +795,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
 
 	ctlr->fcf_dev_loss_tmo = fcoe_fcf_dev_loss_tmo;
 
-	snprintf(ctlr->work_q_name, sizeof(ctlr->work_q_name),
-		 "ctlr_wq_%d", ctlr->id);
-	ctlr->work_q = create_singlethread_workqueue(
-		ctlr->work_q_name);
+	ctlr->work_q = create_singlethread_workqueue2("ctlr_wq_%d", ctlr->id);
 	if (!ctlr->work_q)
 		goto out_del;
 
include/scsi/fcoe_sysfs.h +0 -1
index 4b1216de3f22..45b1e9ca92e9 100644
@@ -50,7 +50,6 @@ struct fcoe_ctlr_device {
 	struct fcoe_sysfs_function_template *f;
 
 	struct list_head		fcfs;
-	char				work_q_name[20];
 	struct workqueue_struct		*work_q;
 	char				devloss_work_q_name[20];
 	struct workqueue_struct		*devloss_work_q;
author reviewer
#57 lore raw

PATCH 44/53 scsi: snic: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called. Not setting shost->work_q_name is safe because there is no code that reads this struct member. Additionally, a later patch removes this struct member.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/snic/snic_main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/snic/snic_main.c +2 -3
index cc824dcfe7da..676ccf41b9da 100644
@@ -300,9 +300,8 @@ snic_add_host(struct Scsi_Host *shost, struct pci_dev *pdev)
 	}
 
 	SNIC_BUG_ON(shost->work_q != NULL);
-	snprintf(shost->work_q_name, sizeof(shost->work_q_name), "scsi_wq_%d",
-		 shost->host_no);
-	shost->work_q = create_singlethread_workqueue(shost->work_q_name);
+	shost->work_q =
+		create_singlethread_workqueue2("scsi_wq_%d", shost->host_no);
 	if (!shost->work_q) {
 		SNIC_HOST_ERR(shost, "Failed to Create ScsiHost wq.\n");
 
author reviewer
#58 lore raw

PATCH 45/53 scsi: scsi_transport_fc: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/scsi_transport_fc.c | 4 +---
 include/scsi/scsi_transport_fc.h | 3 ---
 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/scsi/scsi_transport_fc.c +1 -3
index 7d088b8da075..d07e82fd82a8 100644
@@ -441,9 +441,7 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
 	fc_host->next_vport_number = 0;
 	fc_host->npiv_vports_inuse = 0;
 
-	snprintf(fc_host->work_q_name, sizeof(fc_host->work_q_name),
-		 "fc_wq_%d", shost->host_no);
-	fc_host->work_q = alloc_workqueue("%s", 0, 0, fc_host->work_q_name);
+	fc_host->work_q = alloc_workqueue("fc_wq_%d", 0, 0, shost->host_no);
 	if (!fc_host->work_q)
 		return -ENOMEM;
 
include/scsi/scsi_transport_fc.h +0 -3
index 4b884b8013e0..b0688652ce39 100644
@@ -575,7 +575,6 @@ struct fc_host_attrs {
 	u16 npiv_vports_inuse;
 
 	/* work queues for rport state manipulation */
-	char work_q_name[20];
 	struct workqueue_struct *work_q;
 	char devloss_work_q_name[20];
 	struct workqueue_struct *devloss_work_q;
@@ -654,8 +653,6 @@ struct fc_host_attrs {
 	(((struct fc_host_attrs *)(x)->shost_data)->next_vport_number)
 #define fc_host_npiv_vports_inuse(x)	\
 	(((struct fc_host_attrs *)(x)->shost_data)->npiv_vports_inuse)
-#define fc_host_work_q_name(x) \
-	(((struct fc_host_attrs *)(x)->shost_data)->work_q_name)
 #define fc_host_work_q(x) \
 	(((struct fc_host_attrs *)(x)->shost_data)->work_q)
 #define fc_host_devloss_work_q_name(x) \
author reviewer
#59 lore raw

PATCH 46/53 scsi: core: Simplify the alloc_workqueue() calls

In reply to Bart Van Assche

Pass a format string to alloc_workqueue2() instead of formatting the workqueue name before alloc_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/scsi/hosts.c     | 9 ++++-----
 include/scsi/scsi_host.h | 1 -
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/scsi/hosts.c +4 -5
index 7f987335b44c..e021f1106bea 100644
@@ -292,11 +292,10 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
 	}
 
 	if (shost->transportt->create_work_queue) {
-		snprintf(shost->work_q_name, sizeof(shost->work_q_name),
-			 "scsi_wq_%d", shost->host_no);
-		shost->work_q = alloc_workqueue("%s",
-			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
-			1, shost->work_q_name);
+		shost->work_q = alloc_workqueue(
+			"scsi_wq_%d",
+			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND, 1,
+			shost->host_no);
 
 		if (!shost->work_q) {
 			error = -EINVAL;
include/scsi/scsi_host.h +0 -1
index 19a1c5c48935..2b4ab0369ffb 100644
@@ -677,7 +677,6 @@ struct Scsi_Host {
 	/*
 	 * Optional work queue to be utilized by the transport
 	 */
-	char work_q_name[20];
 	struct workqueue_struct *work_q;
 
 	/*
author reviewer
#60 lore raw

PATCH 47/53 serial: max3100: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/tty/serial/max3100.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/tty/serial/max3100.c +1 -3
index fda63918d1eb..e8e7a36d73cf 100644
@@ -548,7 +548,6 @@ static void max3100_shutdown(struct uart_port *port)
 static int max3100_startup(struct uart_port *port)
 {
 	struct max3100_port *s = to_max3100_port(port);
-	char b[12];
 	int ret;
 
 	dev_dbg(&s->spi->dev, "%s\n", __func__);
@@ -564,8 +563,7 @@ static int max3100_startup(struct uart_port *port)
 	s->parity = 0;
 	s->rts = 0;
 
-	sprintf(b, "max3100-%d", s->minor);
-	s->workqueue = create_freezable_workqueue(b);
+	s->workqueue = create_freezable_workqueue2("max3100-%d", s->minor);
 	if (!s->workqueue) {
 		dev_warn(&s->spi->dev, "cannot create workqueue\n");
 		return -EBUSY;
Reviewed-by on v1 47/53
#61 lore raw

Re: [PATCH 47/53] serial: max3100: Simplify a create*_workqueue() call

Quoted 2 lines · Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author reviewer
#62 lore raw

PATCH 48/53 scsi: ufs: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

Cc Martin K. Petersen <[email protected]>
---
 drivers/ufs/core/ufshcd.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/ufs/core/ufshcd.c +4 -9
index 1b65e6ae4137..9df5b82a6790 100644
@@ -1783,8 +1783,6 @@ static void ufshcd_remove_clk_scaling_sysfs(struct ufs_hba *hba)
 
 static void ufshcd_init_clk_scaling(struct ufs_hba *hba)
 {
-	char wq_name[sizeof("ufs_clkscaling_00")];
-
 	if (!ufshcd_is_clkscaling_supported(hba))
 		return;
 
@@ -1796,9 +1794,8 @@ static void ufshcd_init_clk_scaling(struct ufs_hba *hba)
 	INIT_WORK(&hba->clk_scaling.resume_work,
 		  ufshcd_clk_scaling_resume_work);
 
-	snprintf(wq_name, sizeof(wq_name), "ufs_clkscaling_%d",
-		 hba->host->host_no);
-	hba->clk_scaling.workq = create_singlethread_workqueue(wq_name);
+	hba->clk_scaling.workq = create_singlethread_workqueue2(
+		"ufs_clkscaling_%d", hba->host->host_no);
 
 	hba->clk_scaling.is_initialized = true;
 }
@@ -10328,7 +10325,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	int err;
 	struct Scsi_Host *host = hba->host;
 	struct device *dev = hba->dev;
-	char eh_wq_name[sizeof("ufs_eh_wq_00")];
 
 	/*
 	 * dev_set_drvdata() must be called before any callbacks are registered
@@ -10395,9 +10391,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	hba->max_pwr_info.is_valid = false;
 
 	/* Initialize work queues */
-	snprintf(eh_wq_name, sizeof(eh_wq_name), "ufs_eh_wq_%d",
-		 hba->host->host_no);
-	hba->eh_wq = create_singlethread_workqueue(eh_wq_name);
+	hba->eh_wq = create_singlethread_workqueue2("ufs_eh_wq_%d",
+						    hba->host->host_no);
 	if (!hba->eh_wq) {
 		dev_err(hba->dev, "%s: failed to create eh workqueue\n",
 			__func__);
author reviewer
#63 lore raw

PATCH 49/53 usb: typec: ucsi: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 drivers/usb/typec/ucsi/ucsi.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +2 -7
index 2cc7aedd490f..2209f45c2b9a 100644
@@ -1504,15 +1504,10 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
 	enum typec_accessory *accessory = cap->accessory;
 	enum usb_role u_role = USB_ROLE_NONE;
 	u64 command;
-	char *name;
 	int ret;
 
-	name = kasprintf(GFP_KERNEL, "%s-con%d", dev_name(ucsi->dev), con->num);
-	if (!name)
-		return -ENOMEM;
-
-	con->wq = create_singlethread_workqueue(name);
-	kfree(name);
+	con->wq = create_singlethread_workqueue2("%s-con%d",
+						 dev_name(ucsi->dev), con->num);
 	if (!con->wq)
 		return -ENOMEM;
 
author reviewer
#64 lore raw

PATCH 50/53 cifs: Simplify a create*_workqueue() call

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 fs/smb/client/smbdirect.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/smb/client/smbdirect.c +1 -2
index d74e829de51c..045067fa2a37 100644
@@ -1458,8 +1458,7 @@ static int allocate_caches_and_workqueue(struct smbd_connection *info)
 	if (!info->response_mempool)
 		goto out3;
 
-	scnprintf(name, MAX_NAME_LEN, "smbd_%p", info);
-	info->workqueue = create_workqueue(name);
+	info->workqueue = create_workqueue2("smbd_%p", info);
 	if (!info->workqueue)
 		goto out4;
 
author reviewer
#65 lore raw

PATCH 51/53 mac802154: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue2() instead of formatting the workqueue name before create*_workqueue() is called.

---
 net/mac802154/main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
net/mac802154/main.c +3 -4
index 9ab7396668d2..9da6b21eb3b5 100644
@@ -193,19 +193,18 @@ static void ieee802154_setup_wpan_phy_pib(struct wpan_phy *wpan_phy)
 int ieee802154_register_hw(struct ieee802154_hw *hw)
 {
 	struct ieee802154_local *local = hw_to_local(hw);
-	char mac_wq_name[IFNAMSIZ + 10] = {};
 	struct net_device *dev;
 	int rc = -ENOSYS;
 
 	local->workqueue =
-		create_singlethread_workqueue(wpan_phy_name(local->phy));
+		create_singlethread_workqueue2("%s", wpan_phy_name(local->phy));
 	if (!local->workqueue) {
 		rc = -ENOMEM;
 		goto out;
 	}
 
-	snprintf(mac_wq_name, IFNAMSIZ + 10, "%s-mac-cmds", wpan_phy_name(local->phy));
-	local->mac_wq =	create_singlethread_workqueue(mac_wq_name);
+	local->mac_wq = create_singlethread_workqueue2(
+		"%s-mac-cmds", wpan_phy_name(local->phy));
 	if (!local->mac_wq) {
 		rc = -ENOMEM;
 		goto out_wq;
author reviewer
#66 lore raw

PATCH 52/53 nfc: nci: Simplify the create*_workqueue() calls

In reply to Bart Van Assche

Pass a format string to create*_workqueue() instead of formatting the workqueue name before create*_workqueue() is called.

---
 net/nfc/nci/core.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
net/nfc/nci/core.c +6 -7
index f456a5911e7d..4b5cb2017e39 100644
@@ -1225,29 +1225,28 @@ int nci_register_device(struct nci_dev *ndev)
 {
 	int rc;
 	struct device *dev = &ndev->nfc_dev->dev;
-	char name[32];
 
 	ndev->flags = 0;
 
 	INIT_WORK(&ndev->cmd_work, nci_cmd_work);
-	snprintf(name, sizeof(name), "%s_nci_cmd_wq", dev_name(dev));
-	ndev->cmd_wq = create_singlethread_workqueue(name);
+	ndev->cmd_wq =
+		create_singlethread_workqueue2("%s_nci_cmd_wq", dev_name(dev));
 	if (!ndev->cmd_wq) {
 		rc = -ENOMEM;
 		goto exit;
 	}
 
 	INIT_WORK(&ndev->rx_work, nci_rx_work);
-	snprintf(name, sizeof(name), "%s_nci_rx_wq", dev_name(dev));
-	ndev->rx_wq = create_singlethread_workqueue(name);
+	ndev->rx_wq =
+		create_singlethread_workqueue2("%s_nci_rx_wq", dev_name(dev));
 	if (!ndev->rx_wq) {
 		rc = -ENOMEM;
 		goto destroy_cmd_wq_exit;
 	}
 
 	INIT_WORK(&ndev->tx_work, nci_tx_work);
-	snprintf(name, sizeof(name), "%s_nci_tx_wq", dev_name(dev));
-	ndev->tx_wq = create_singlethread_workqueue(name);
+	ndev->tx_wq =
+		create_singlethread_workqueue2("%s_nci_tx_wq", dev_name(dev));
 	if (!ndev->tx_wq) {
 		rc = -ENOMEM;
 		goto destroy_rx_wq_exit;
maintainer
#68 lore raw
In reply to Bart Van Assche

Hello, Bart.

Quoted 2 lines · Bart Van Assche

1. Introduce the create*_workqueue2() macros that accept a printf-style format string and argument list.

I don't think we want to update create_workqueue() interface at all. Please convert them to use alloc_workqueue() instead. Once we convert all create_workqueue() users then we can just drop the old interface.

The challenge with converging to alloc_workqueue() interface is that the conversion needs to explicitly decide whether WQ_MEM_RECLAIM is needed or not but that shouldn't be *too* difficult.

Thanks.

Signature · 1 line
tejun
author reviewer
#69 lore raw
Quoted 11 lines · Tejun Heo
Quoted 2 lines · Bart Van Assche

1. Introduce the create*_workqueue2() macros that accept a printf-style format string and argument list.

I don't think we want to update create_workqueue() interface at all. Please convert them to use alloc_workqueue() instead. Once we convert all create_workqueue() users then we can just drop the old interface.

The challenge with converging to alloc_workqueue() interface is that the conversion needs to explicitly decide whether WQ_MEM_RECLAIM is needed or not but that shouldn't be *too* difficult.

The create*_workqueue() macros are used about 270 times in the Linux kernel (the macro names also occur in some comments):

$ git grep -nHEw 'create_workqueue|create_freezable_workqueue|create_singlethread_workqueue' | grep -Ev 'Documentation/|include/linux/workqueue' | wc -l
    271

That's too much for a single patch series. I can start with converting the SCSI workqueue creation code.

Thanks,

Bart.

maintainer
#70 lore raw

Hello, Bart.

Quoted 10 lines · Bart Van Assche

The create*_workqueue() macros are used about 270 times in the Linux kernel (the macro names also occur in some comments):

$ git grep -nHEw
'create_workqueue|create_freezable_workqueue|create_singlethread_workqueue'
| grep -Ev 'Documentation/|include/linux/workqueue' | wc -l
    271

That's too much for a single patch series. I can start with converting the SCSI workqueue creation code.

Yeah, it's been on the to-do list for a long time. Starting with SCSI sounds great.

Thank you.

Signature · 1 line
tejun