Skip to contentSkip to conversation

Simplify multiple create*_workqueue() invocations

PATCH Superseded Bart Van Assche 4 participants 28 messages Aug 16, 2024 – Aug 20, 2024

Subsystems (22)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Bart Van Assche

author reviewer
#0 lore raw

v2 cover Simplify multiple create*_workqueue() invocations

Hi Martin,

Multiple SCSI drivers use snprintf() to format a workqueue name before invoking one of the create*_workqueue() macros. This patch series simplifies such code by passing the format string and arguments to alloc_workqueue(). Please consider this patch series for the next merge window.

Thanks,

Bart.

Changes compared to v1:
- Added several Reviewed-by tags.

Bart Van Assche (18):
scsi: Expand all create*_workqueue() invocations
scsi: mptfusion: Simplify the alloc*_workqueue() invocations
scsi: be2iscsi: Simplify an alloc_workqueue() invocation
scsi: bfa: Simplify an alloc_ordered_workqueue() invocation
scsi: esas2r: Simplify an alloc_ordered_workqueue() invocation
scsi: fcoe: Simplify alloc_ordered_workqueue() invocations
scsi: ibmvscsi_tgt: Simplify an alloc_workqueue() invocation
scsi: mpi3mr: Simplify an alloc_ordered_workqueue() invocation
scsi: mpt3sas: Simplify an alloc_ordered_workqueue() invocation
scsi: myrb: Simplify an alloc_ordered_workqueue() invocation
scsi: myrs: Simplify an alloc_ordered_workqueue() invocation
scsi: qedf: Simplify alloc_workqueue() invocations
scsi: qedi: Simplify an alloc_workqueue() invocation
scsi: snic: Simplify alloc_workqueue() invocations
scsi: scsi_transport_fc: Simplify alloc_workqueue() invocations
scsi: stex: Simplify an alloc_ordered_workqueue() invocation
scsi: ufs: Simplify alloc*_workqueue() invocation
scsi: core: Simplify an alloc_workqueue() invocation

 drivers/message/fusion/mptbase.c            | 10 +++-------
 drivers/message/fusion/mptbase.h            |  3 ---
 drivers/message/fusion/mptfc.c              |  7 ++-----
 drivers/scsi/be2iscsi/be_main.c             |  6 ++----
 drivers/scsi/bfa/bfad_im.c                  |  5 ++---
 drivers/scsi/bfa/bfad_im.h                  |  1 -
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c           |  4 ++--
 drivers/scsi/device_handler/scsi_dh_rdac.c  |  3 ++-
 drivers/scsi/elx/efct/efct_lio.c            |  3 ++-
 drivers/scsi/esas2r/esas2r.h                |  1 -
 drivers/scsi/esas2r/esas2r_init.c           |  5 ++---
 drivers/scsi/fcoe/fcoe_sysfs.c              | 18 +++++------------
 drivers/scsi/fnic/fnic_main.c               |  6 ++++--
 drivers/scsi/hisi_sas/hisi_sas_main.c       |  3 ++-
 drivers/scsi/hosts.c                        |  9 ++++-----
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c    |  5 ++---
 drivers/scsi/libfc/fc_exch.c                |  3 ++-
 drivers/scsi/libfc/fc_rport.c               |  3 ++-
 drivers/scsi/libsas/sas_init.c              |  4 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  4 ++--
 drivers/scsi/mpi3mr/mpi3mr.h                |  2 --
 drivers/scsi/mpi3mr/mpi3mr_fw.c             |  4 ++--
 drivers/scsi/mpi3mr/mpi3mr_os.c             |  4 +---
 drivers/scsi/mpt3sas/mpt3sas_base.c         |  4 ++--
 drivers/scsi/mpt3sas/mpt3sas_base.h         |  4 +---
 drivers/scsi/mpt3sas/mpt3sas_scsih.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               | 20 +++++++++----------
 drivers/scsi/qedi/qedi_main.c               |  8 +++++---
 drivers/scsi/qla2xxx/qla_os.c               |  6 ++++--
 drivers/scsi/qla4xxx/ql4_os.c               |  2 +-
 drivers/scsi/scsi_transport_fc.c            | 11 +++--------
 drivers/scsi/snic/snic_main.c               |  8 ++++----
 drivers/scsi/stex.c                         |  6 ++----
 drivers/scsi/vmw_pvscsi.c                   |  3 ++-
 drivers/ufs/core/ufshcd.c                   | 22 +++++++--------------
 include/scsi/fcoe_sysfs.h                   |  2 --
 include/scsi/scsi_host.h                    |  1 -
 include/scsi/scsi_transport_fc.h            |  6 ------
 42 files changed, 90 insertions(+), 142 deletions(-)
author reviewer
#6 lore raw

PATCH v2 2/18 scsi: mptfusion: Simplify the alloc*_workqueue() invocations

Let alloc*_workqueue() format the workqueue names instead of calling snprintf() explicitly.

---
 drivers/message/fusion/mptbase.c | 10 +++-------
 drivers/message/fusion/mptbase.h |  3 ---
 drivers/message/fusion/mptfc.c   |  7 ++-----
 3 files changed, 5 insertions(+), 15 deletions(-)
drivers/message/fusion/mptbase.c +3 -7
index 4bf669c55649..738bc4e60a18 100644
@@ -1856,10 +1856,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 	/* Initialize workqueue */
 	INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work);
 
-	snprintf(ioc->reset_work_q_name, MPT_KOBJ_NAME_LEN,
-		 "mpt_poll_%d", ioc->id);
-	ioc->reset_work_q = alloc_workqueue(ioc->reset_work_q_name,
-					    WQ_MEM_RECLAIM, 0);
+	ioc->reset_work_q =
+		alloc_workqueue("mpt_poll_%d", WQ_MEM_RECLAIM, 0, ioc->id);
 	if (!ioc->reset_work_q) {
 		printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
 		    ioc->name);
@@ -1986,9 +1984,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	INIT_LIST_HEAD(&ioc->fw_event_list);
 	spin_lock_init(&ioc->fw_event_lock);
-	snprintf(ioc->fw_event_q_name, MPT_KOBJ_NAME_LEN, "mpt/%d", ioc->id);
-	ioc->fw_event_q = alloc_workqueue(ioc->fw_event_q_name,
-					  WQ_MEM_RECLAIM, 0);
+	ioc->fw_event_q = alloc_workqueue("mpt/%d", WQ_MEM_RECLAIM, 0, ioc->id);
 	if (!ioc->fw_event_q) {
 		printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
 		    ioc->name);
drivers/message/fusion/mptbase.h +0 -3
index 8031173c3655..b406fd676da0 100644
@@ -729,7 +729,6 @@ typedef struct _MPT_ADAPTER
 	struct list_head	 fw_event_list;
 	spinlock_t		 fw_event_lock;
 	u8			 fw_events_off; /* if '1', then ignore events */
-	char 			 fw_event_q_name[MPT_KOBJ_NAME_LEN];
 
 	struct mutex		 sas_discovery_mutex;
 	u8			 sas_discovery_runtime;
@@ -764,7 +763,6 @@ typedef struct _MPT_ADAPTER
 	u8			 fc_link_speed[2];
 	spinlock_t		 fc_rescan_work_lock;
 	struct work_struct	 fc_rescan_work;
-	char			 fc_rescan_work_q_name[MPT_KOBJ_NAME_LEN];
 	struct workqueue_struct *fc_rescan_work_q;
 
 	/* driver forced bus resets count */
@@ -778,7 +776,6 @@ typedef struct _MPT_ADAPTER
 	spinlock_t		  scsi_lookup_lock;
 	u64			dma_mask;
 	u32			  broadcast_aen_busy;
-	char			 reset_work_q_name[MPT_KOBJ_NAME_LEN];
 	struct workqueue_struct *reset_work_q;
 	struct delayed_work	 fault_reset_work;
 
drivers/message/fusion/mptfc.c +2 -5
index a3c17c4fe69c..91242f26defb 100644
@@ -1349,11 +1349,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	/* initialize workqueue */
 
-	snprintf(ioc->fc_rescan_work_q_name, sizeof(ioc->fc_rescan_work_q_name),
-		 "mptfc_wq_%d", sh->host_no);
-	ioc->fc_rescan_work_q =
-		alloc_ordered_workqueue(ioc->fc_rescan_work_q_name,
-					WQ_MEM_RECLAIM);
+	ioc->fc_rescan_work_q = alloc_ordered_workqueue(
+		"mptfc_wq_%d", WQ_MEM_RECLAIM, sh->host_no);
 	if (!ioc->fc_rescan_work_q) {
 		error = -ENOMEM;
 		goto out_mptfc_host;
author reviewer
#10 lore raw

PATCH v2 3/18 scsi: be2iscsi: Simplify an alloc_workqueue() invocation

In reply to Bart Van Assche

Let alloc_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/be2iscsi/be_main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/be2iscsi/be_main.c +2 -4
index 06acb5ff609e..76a1e373386e 100644
@@ -5528,7 +5528,6 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
 	struct beiscsi_hba *phba = NULL;
 	struct be_eq_obj *pbe_eq;
 	unsigned int s_handle;
-	char wq_name[20];
 	int ret, i;
 
 	ret = beiscsi_enable_pci(pcidev);
@@ -5634,9 +5633,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
 
 	phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0;
 
-	snprintf(wq_name, sizeof(wq_name), "beiscsi_%02x_wq",
-		 phba->shost->host_no);
-	phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, wq_name);
+	phba->wq = alloc_workqueue("beiscsi_%02x_wq", WQ_MEM_RECLAIM, 1,
+				   phba->shost->host_no);
 	if (!phba->wq) {
 		beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
 			    "BM_%d : beiscsi_dev_probe-"
author reviewer
#11 lore raw

PATCH v2 4/18 scsi: bfa: Simplify an alloc_ordered_workqueue() invocation

In reply to Bart Van Assche

Let alloc_ordered_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/bfa/bfad_im.c | 6 ++----
 drivers/scsi/bfa/bfad_im.h | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/scsi/bfa/bfad_im.c +2 -4
index a1d015356063..66fb701401de 100644
@@ -766,10 +766,8 @@ bfad_thread_workq(struct bfad_s *bfad)
 	struct bfad_im_s      *im = bfad->im;
 
 	bfa_trc(bfad, 0);
-	snprintf(im->drv_workq_name, KOBJ_NAME_LEN, "bfad_wq_%d",
-		 bfad->inst_no);
-	im->drv_workq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
-						im->drv_workq_name);
+	im->drv_workq = alloc_ordered_workqueue("bfad_wq_%d", WQ_MEM_RECLAIM,
+						bfad->inst_no);
 	if (!im->drv_workq)
 		return BFA_STATUS_FAILED;
 
drivers/scsi/bfa/bfad_im.h +0 -1
index 4353feedf76a..0884af04bd1f 100644
@@ -134,7 +134,6 @@ struct bfad_fcp_binding {
 struct bfad_im_s {
 	struct bfad_s         *bfad;
 	struct workqueue_struct *drv_workq;
-	char            drv_workq_name[KOBJ_NAME_LEN];
 	struct work_struct	aen_im_notify_work;
 };
 
author reviewer
#12 lore raw

PATCH v2 5/18 scsi: esas2r: Simplify an alloc_ordered_workqueue() invocation

In reply to Bart Van Assche

Let alloc_ordered_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/esas2r/esas2r.h      | 1 -
 drivers/scsi/esas2r/esas2r_init.c | 6 ++----
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/scsi/esas2r/esas2r.h +0 -1
index ed63f7a9ea54..8a133254c4f6 100644
@@ -929,7 +929,6 @@ struct esas2r_adapter {
 	struct list_head fw_event_list;
 	spinlock_t fw_event_lock;
 	u8 fw_events_off;                       /* if '1', then ignore events */
-	char fw_event_q_name[ESAS2R_KOBJ_NAME_LEN];
 	/*
 	 * intr_mode stores the interrupt mode currently being used by this
 	 * adapter. it is based on the interrupt_mode module parameter, but
drivers/scsi/esas2r/esas2r_init.c +2 -4
index ff1fa3160c61..0cea5f3d1a08 100644
@@ -311,10 +311,8 @@ int esas2r_init_adapter(struct Scsi_Host *host, struct pci_dev *pcid,
 	sema_init(&a->nvram_semaphore, 1);
 
 	esas2r_fw_event_off(a);
-	snprintf(a->fw_event_q_name, ESAS2R_KOBJ_NAME_LEN, "esas2r/%d",
-		 a->index);
-	a->fw_event_q = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
-						a->fw_event_q_name);
+	a->fw_event_q =
+		alloc_ordered_workqueue("esas2r/%d", WQ_MEM_RECLAIM, a->index);
 
 	init_waitqueue_head(&a->buffered_ioctl_waiter);
 	init_waitqueue_head(&a->nvram_waiter);
author reviewer
#13 lore raw

PATCH v2 6/18 scsi: fcoe: Simplify alloc_ordered_workqueue() invocations

In reply to Bart Van Assche

Let alloc_ordered_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/fcoe/fcoe_sysfs.c | 18 +++++-------------
 include/scsi/fcoe_sysfs.h      |  2 --
 2 files changed, 5 insertions(+), 15 deletions(-)
drivers/scsi/fcoe/fcoe_sysfs.c +5 -13
index 06357bbf6b2c..0609ca6b9353 100644
@@ -45,12 +45,8 @@ 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)	\
-	((x)->devloss_work_q_name)
 #define fcoe_ctlr_devloss_work_q(x)		\
 	((x)->devloss_work_q)
 #define fcoe_ctlr_mode(x)			\
@@ -797,18 +793,14 @@ 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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
-					       ctlr->work_q_name);
+	ctlr->work_q = alloc_ordered_workqueue("ctlr_wq_%d", WQ_MEM_RECLAIM,
+					       ctlr->id);
 	if (!ctlr->work_q)
 		goto out_del;
 
-	snprintf(ctlr->devloss_work_q_name,
-		 sizeof(ctlr->devloss_work_q_name),
-		 "ctlr_dl_wq_%d", ctlr->id);
-	ctlr->devloss_work_q = alloc_ordered_workqueue(
-		"%s", WQ_MEM_RECLAIM, ctlr->devloss_work_q_name);
+	ctlr->devloss_work_q = alloc_ordered_workqueue("ctlr_dl_wq_%d",
+						       WQ_MEM_RECLAIM,
+						       ctlr->id);
 	if (!ctlr->devloss_work_q)
 		goto out_del_q;
 
include/scsi/fcoe_sysfs.h +0 -2
index 4b1216de3f22..2b28a05e492b 100644
@@ -50,9 +50,7 @@ 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;
 	struct mutex			lock;
 
author reviewer
#14 lore raw

PATCH v2 7/18 scsi: ibmvscsi_tgt: Simplify an alloc_workqueue() invocation

In reply to Bart Van Assche

Let alloc_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +2 -3
index 639f72f28911..16d085d56e9d 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,8 @@ 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 = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, wq_name);
+	vscsi->work_q = alloc_workqueue("ibmvscsis%s", WQ_MEM_RECLAIM, 1,
+					dev_name(&vdev->dev));
 	if (!vscsi->work_q) {
 		rc = -ENOMEM;
 		dev_err(&vscsi->dev, "create_workqueue failed\n");
author reviewer
#15 lore raw

PATCH v2 8/18 scsi: mpi3mr: Simplify an alloc_ordered_workqueue() invocation

In reply to Bart Van Assche

Let alloc_ordered_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/mpi3mr/mpi3mr.h    | 2 --
 drivers/scsi/mpi3mr/mpi3mr_os.c | 4 +---
 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/scsi/mpi3mr/mpi3mr.h +0 -2
index dc2cdd5f0311..c1c97ed1eb38 100644
@@ -1059,7 +1059,6 @@ struct scmd_priv {
  * @sbq_lock: Sense buffer queue lock
  * @sbq_host_index: Sense buffer queuehost index
  * @event_masks: Event mask bitmap
- * @fwevt_worker_name: Firmware event worker thread name
  * @fwevt_worker_thread: Firmware event worker thread
  * @fwevt_lock: Firmware event lock
  * @fwevt_list: Firmware event list
@@ -1240,7 +1239,6 @@ struct mpi3mr_ioc {
 	u32 sbq_host_index;
 	u32 event_masks[MPI3_EVENT_NOTIFY_EVENTMASK_WORDS];
 
-	char fwevt_worker_name[MPI3MR_NAME_LENGTH];
 	struct workqueue_struct	*fwevt_worker_thread;
 	spinlock_t fwevt_lock;
 	struct list_head fwevt_list;
drivers/scsi/mpi3mr/mpi3mr_os.c +1 -3
index ca8f132e03ae..58a66a318e02 100644
@@ -5316,10 +5316,8 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	else
 		scsi_host_set_guard(shost, SHOST_DIX_GUARD_CRC);
 
-	snprintf(mrioc->fwevt_worker_name, sizeof(mrioc->fwevt_worker_name),
-	    "%s%d_fwevt_wrkr", mrioc->driver_name, mrioc->id);
 	mrioc->fwevt_worker_thread = alloc_ordered_workqueue(
-	    mrioc->fwevt_worker_name, 0);
+		"%s%d_fwevt_wrkr", 0, mrioc->driver_name, mrioc->id);
 	if (!mrioc->fwevt_worker_thread) {
 		ioc_err(mrioc, "failure at %s:%d/%s()!\n",
 		    __FILE__, __LINE__, __func__);
author reviewer
#16 lore raw

PATCH v2 9/18 scsi: mpt3sas: Simplify an alloc_ordered_workqueue() invocation

In reply to Bart Van Assche

Let alloc_ordered_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/mpt3sas/mpt3sas_base.h  | 4 +---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +1 -3
index fe1e96fda284..eceb5eeb4651 100644
@@ -1162,8 +1162,7 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc);
  * @fault_reset_work_q_name: fw fault work queue
  * @fault_reset_work_q: ""
  * @fault_reset_work: ""
- * @firmware_event_name: fw event work queue
- * @firmware_event_thread: ""
+ * @firmware_event_thread: fw event work queue
  * @fw_event_lock:
  * @fw_event_list: list of fw events
  * @current_evet: current processing firmware event
@@ -1351,7 +1350,6 @@ struct MPT3SAS_ADAPTER {
 	struct delayed_work fault_reset_work;
 
 	/* fw event handler */
-	char		firmware_event_name[20];
 	struct workqueue_struct	*firmware_event_thread;
 	spinlock_t	fw_event_lock;
 	struct list_head fw_event_list;
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 -3
index 97c2472cd434..728cced42b0e 100644
@@ -12301,10 +12301,8 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	scsi_host_set_guard(shost, SHOST_DIX_GUARD_CRC);
 
 	/* event thread */
-	snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name),
-	    "fw_event_%s%d", ioc->driver_name, ioc->id);
 	ioc->firmware_event_thread = alloc_ordered_workqueue(
-	    ioc->firmware_event_name, 0);
+		"fw_event_%s%d", 0, ioc->driver_name, ioc->id);
 	if (!ioc->firmware_event_thread) {
 		ioc_err(ioc, "failure at %s:%d/%s()!\n",
 			__FILE__, __LINE__, __func__);
author reviewer
#17 lore raw

PATCH v2 10/18 scsi: myrb: Simplify an alloc_ordered_workqueue() invocation

In reply to Bart Van Assche

Let alloc_ordered_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/myrb.c | 6 ++----
 drivers/scsi/myrb.h | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/scsi/myrb.c +2 -4
index 140dc0e9cead..bfc2b835e612 100644
@@ -112,10 +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 =
-		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, cb->work_q_name);
+	cb->work_q = alloc_ordered_workqueue("myrb_wq_%d", WQ_MEM_RECLAIM,
+					     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
#18 lore raw

PATCH v2 11/18 scsi: myrs: Simplify an alloc_ordered_workqueue() invocation

In reply to Bart Van Assche

Let alloc_ordered_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/myrs.c | 6 ++----
 drivers/scsi/myrs.h | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/scsi/myrs.c +2 -4
index 8a8f26633cda..3392feb15cb4 100644
@@ -2206,10 +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 =
-		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, cs->work_q_name);
+	cs->work_q = alloc_ordered_workqueue("myrs_wq_%d", WQ_MEM_RECLAIM,
+					     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
#19 lore raw

PATCH v2 12/18 scsi: qedf: Simplify alloc_workqueue() invocations

In reply to Bart Van Assche

Let alloc_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/qedf/qedf_main.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/scsi/qedf/qedf_main.c +6 -9
index 119afcaf6e13..cf13148ba281 100644
@@ -3372,10 +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 =
-		alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
+	qedf->link_update_wq = alloc_workqueue("qedf_%u_link", WQ_MEM_RECLAIM,
+					       1, 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);
@@ -3585,8 +3583,8 @@ 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 = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
+	qedf->ll2_recv_wq = alloc_workqueue("qedf_%d_ll2", WQ_MEM_RECLAIM, 1,
+					    host->host_no);
 	if (!qedf->ll2_recv_wq) {
 		QEDF_ERR(&(qedf->dbg_ctx), "Failed to LL2 workqueue.\n");
 		rc = -ENOMEM;
@@ -3627,9 +3625,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 =
-		alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
+	qedf->timer_work_queue = alloc_workqueue("qedf_%u_timer",
+				WQ_MEM_RECLAIM, 1, qedf->lport->host->host_no);
 	if (!qedf->timer_work_queue) {
 		QEDF_ERR(&(qedf->dbg_ctx), "Failed to start timer "
 			  "workqueue.\n");
author reviewer
#20 lore raw

PATCH v2 13/18 scsi: qedi: Simplify an alloc_workqueue() invocation

In reply to Bart Van Assche

Let alloc_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/qedi/qedi_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/qedi/qedi_main.c +3 -3
index 319c1da549f7..c5aec26019d6 100644
@@ -2776,9 +2776,9 @@ 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 =
-			alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
+		qedi->offload_thread = alloc_workqueue("qedi_ofld%d",
+						       WQ_MEM_RECLAIM,
+						       1, qedi->shost->host_no);
 		if (!qedi->offload_thread) {
 			QEDI_ERR(&qedi->dbg_ctx,
 				 "Unable to start offload thread!\n");
author reviewer
#21 lore raw

PATCH v2 14/18 scsi: snic: Simplify alloc_workqueue() invocations

In reply to Bart Van Assche

Let alloc_workqueue() format the workqueue name instead of calling snprintf() explicitly. Not setting shost->work_q_name is safe because there is no code that reads the value set by the removed code.

---
 drivers/scsi/snic/snic_main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/snic/snic_main.c +2 -4
index 2bd01eb57869..5ca8bc89dfa7 100644
@@ -300,10 +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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
-						shost->work_q_name);
+	shost->work_q = alloc_ordered_workqueue("scsi_wq_%d", WQ_MEM_RECLAIM,
+						shost->host_no);
 	if (!shost->work_q) {
 		SNIC_HOST_ERR(shost, "Failed to Create ScsiHost wq.\n");
 
author reviewer
#22 lore raw

PATCH v2 15/18 scsi: scsi_transport_fc: Simplify alloc_workqueue() invocations

In reply to Bart Van Assche

Let alloc_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/scsi_transport_fc.c | 11 +++--------
 include/scsi/scsi_transport_fc.h |  6 ------
 2 files changed, 3 insertions(+), 14 deletions(-)
drivers/scsi/scsi_transport_fc.c +3 -8
index 7d088b8da075..62ea7e44460e 100644
@@ -441,18 +441,13 @@ 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;
 
 	fc_host->dev_loss_tmo = fc_dev_loss_tmo;
-	snprintf(fc_host->devloss_work_q_name,
-		 sizeof(fc_host->devloss_work_q_name),
-		 "fc_dl_%d", shost->host_no);
-	fc_host->devloss_work_q = alloc_workqueue("%s", 0, 0,
-					fc_host->devloss_work_q_name);
+	fc_host->devloss_work_q = alloc_workqueue("fc_dl_%d", 0, 0,
+					shost->host_no);
 	if (!fc_host->devloss_work_q) {
 		destroy_workqueue(fc_host->work_q);
 		fc_host->work_q = NULL;
include/scsi/scsi_transport_fc.h +0 -6
index 4b884b8013e0..8e6c60090c62 100644
@@ -575,9 +575,7 @@ 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;
 
 	/* bsg support */
@@ -654,12 +652,8 @@ 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) \
-	(((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q_name)
 #define fc_host_devloss_work_q(x) \
 	(((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q)
 #define fc_host_dev_loss_tmo(x) \
author reviewer
#23 lore raw

PATCH v2 16/18 scsi: stex: Simplify an alloc_ordered_workqueue() invocation

In reply to Bart Van Assche

Let alloc_ordered_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/scsi/stex.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/scsi/stex.c +2 -5
index fbee7db4a835..0e81125df8c7 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,10 +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 =
-		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, hba->work_q_name);
+	hba->work_q = alloc_ordered_workqueue("stex_wq_%d", WQ_MEM_RECLAIM,
+					      host->host_no);
 	if (!hba->work_q) {
 		printk(KERN_ERR DRV_NAME "(%s): create workqueue failed\n",
 			pci_name(pdev));
author reviewer
#27 lore raw

PATCH v2 18/18 scsi: core: Simplify an alloc_workqueue() invocation

In reply to Bart Van Assche

Let alloc_workqueue() format the workqueue name.

---
 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
#24 lore raw

PATCH v2 17/18 scsi: ufs: Simplify alloc*_workqueue() invocation

In reply to Bart Van Assche

Let alloc*_workqueue() format the workqueue name instead of calling snprintf() explicitly.

---
 drivers/ufs/core/ufshcd.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)
drivers/ufs/core/ufshcd.c +7 -16
index 22d5e27485c5..ee68e911741c 100644
@@ -1785,8 +1785,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;
 
@@ -1798,10 +1796,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 =
-		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name);
+	hba->clk_scaling.workq = alloc_ordered_workqueue(
+		"ufs_clkscaling_%d", WQ_MEM_RECLAIM, hba->host->host_no);
 
 	hba->clk_scaling.is_initialized = true;
 }
@@ -2125,8 +2121,6 @@ static void ufshcd_remove_clk_gating_sysfs(struct ufs_hba *hba)
 
 static void ufshcd_init_clk_gating(struct ufs_hba *hba)
 {
-	char wq_name[sizeof("ufs_clk_gating_00")];
-
 	if (!ufshcd_is_clkgating_allowed(hba))
 		return;
 
@@ -2136,10 +2130,9 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba)
 	INIT_DELAYED_WORK(&hba->clk_gating.gate_work, ufshcd_gate_work);
 	INIT_WORK(&hba->clk_gating.ungate_work, ufshcd_ungate_work);
 
-	snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_clk_gating_%d",
-		 hba->host->host_no);
-	hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue(wq_name,
-					WQ_MEM_RECLAIM | WQ_HIGHPRI);
+	hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue(
+		"ufs_clk_gating_%d", WQ_MEM_RECLAIM | WQ_HIGHPRI,
+		hba->host->host_no);
 
 	ufshcd_init_clk_gating_sysfs(hba);
 
@@ -10392,7 +10385,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
@@ -10459,9 +10451,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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, eh_wq_name);
+	hba->eh_wq = alloc_ordered_workqueue("ufs_eh_wq_%d", WQ_MEM_RECLAIM,
+					     hba->host->host_no);
 	if (!hba->eh_wq) {
 		dev_err(hba->dev, "%s: failed to create eh workqueue\n",
 			__func__);
author reviewer
#1 lore raw

PATCH v2 1/18 scsi: Expand all create*_workqueue() invocations

In reply to Bart Van Assche

The workqueue maintainer wants to remove the create*_workqueue() macros because these macros always set the WQ_MEM_RECLAIM flag and because these only support literal workqueue names. Hence this patch that replaces the create*_workqueue() invocations with the definition of this macro. The WQ_MEM_RECLAIM flag has been retained because I think that flag is necessary for workqueues created by storage drivers. This patch has been generated by running spatch and git clang-format. spatch has been invoked as follows:

spatch --in-place --sp-file expand-create-workqueue.spatch $(git grep -lEw 'create_(freezable_|singlethread_|)workqueue' */scsi */ufs)

The contents of the expand-create-workqueue.spatch file is as follows:

@@
expression name;
@@
-create_workqueue(name)
+alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, name)
@@
expression name;
@@
-create_freezable_workqueue(name)
+alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1, name) @@
expression name;
@@
-create_singlethread_workqueue(name) +alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name)

---
 drivers/scsi/bfa/bfad_im.c                  |  3 ++-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c           |  4 ++--
 drivers/scsi/device_handler/scsi_dh_rdac.c  |  3 ++-
 drivers/scsi/elx/efct/efct_lio.c            |  3 ++-
 drivers/scsi/esas2r/esas2r_init.c           |  3 ++-
 drivers/scsi/fcoe/fcoe_sysfs.c              |  8 ++++----
 drivers/scsi/fnic/fnic_main.c               |  6 ++++--
 drivers/scsi/hisi_sas/hisi_sas_main.c       |  3 ++-
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c    |  2 +-
 drivers/scsi/libfc/fc_exch.c                |  3 ++-
 drivers/scsi/libfc/fc_rport.c               |  3 ++-
 drivers/scsi/libsas/sas_init.c              |  4 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  4 ++--
 drivers/scsi/mpi3mr/mpi3mr_fw.c             |  4 ++--
 drivers/scsi/mpt3sas/mpt3sas_base.c         |  4 ++--
 drivers/scsi/myrb.c                         |  3 ++-
 drivers/scsi/myrs.c                         |  3 ++-
 drivers/scsi/qedf/qedf_main.c               | 13 +++++++------
 drivers/scsi/qedi/qedi_main.c               |  6 ++++--
 drivers/scsi/qla2xxx/qla_os.c               |  6 ++++--
 drivers/scsi/qla4xxx/ql4_os.c               |  2 +-
 drivers/scsi/snic/snic_main.c               |  6 ++++--
 drivers/scsi/stex.c                         |  3 ++-
 drivers/scsi/vmw_pvscsi.c                   |  3 ++-
 drivers/ufs/core/ufshcd.c                   |  5 +++--
 25 files changed, 64 insertions(+), 43 deletions(-)
drivers/scsi/bfa/bfad_im.c +2 -1
index a9d3d8562d3c..a1d015356063 100644
@@ -768,7 +768,8 @@ bfad_thread_workq(struct bfad_s *bfad)
 	bfa_trc(bfad, 0);
 	snprintf(im->drv_workq_name, KOBJ_NAME_LEN, "bfad_wq_%d",
 		 bfad->inst_no);
-	im->drv_workq = create_singlethread_workqueue(im->drv_workq_name);
+	im->drv_workq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
+						im->drv_workq_name);
 	if (!im->drv_workq)
 		return BFA_STATUS_FAILED;
 
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +2 -2
index 1078c20c5ef6..f49783b89d04 100644
@@ -2363,8 +2363,8 @@ static int _bnx2fc_create(struct net_device *netdev,
 	interface->vlan_id = vlan_id;
 	interface->tm_timeout = BNX2FC_TM_TIMEOUT;
 
-	interface->timer_work_queue =
-			create_singlethread_workqueue("bnx2fc_timer_wq");
+	interface->timer_work_queue = alloc_ordered_workqueue(
+		"%s", WQ_MEM_RECLAIM, "bnx2fc_timer_wq");
 	if (!interface->timer_work_queue) {
 		printk(KERN_ERR PFX "ulp_init could not create timer_wq\n");
 		rc = -EINVAL;
drivers/scsi/device_handler/scsi_dh_rdac.c +2 -1
index f8a09e3eba58..6e1b252cea0e 100644
@@ -822,7 +822,8 @@ static int __init rdac_init(void)
 	/*
 	 * Create workqueue to handle mode selects for rdac
 	 */
-	kmpath_rdacd = create_singlethread_workqueue("kmpath_rdacd");
+	kmpath_rdacd =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "kmpath_rdacd");
 	if (!kmpath_rdacd) {
 		scsi_unregister_device_handler(&rdac_dh);
 		printk(KERN_ERR "kmpath_rdacd creation failed.\n");
drivers/scsi/elx/efct/efct_lio.c +2 -1
index 6a6ec32c46bd..9ac69356b13e 100644
@@ -1114,7 +1114,8 @@ int efct_scsi_tgt_new_device(struct efct *efct)
 	atomic_set(&efct->tgt_efct.watermark_hit, 0);
 	atomic_set(&efct->tgt_efct.initiator_count, 0);
 
-	lio_wq = create_singlethread_workqueue("efct_lio_worker");
+	lio_wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
+					 "efct_lio_worker");
 	if (!lio_wq) {
 		efc_log_err(efct, "workqueue create failed\n");
 		return -EIO;
drivers/scsi/esas2r/esas2r_init.c +2 -1
index c1a5ab662dc8..ff1fa3160c61 100644
@@ -313,7 +313,8 @@ int esas2r_init_adapter(struct Scsi_Host *host, struct pci_dev *pcid,
 	esas2r_fw_event_off(a);
 	snprintf(a->fw_event_q_name, ESAS2R_KOBJ_NAME_LEN, "esas2r/%d",
 		 a->index);
-	a->fw_event_q = create_singlethread_workqueue(a->fw_event_q_name);
+	a->fw_event_q = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
+						a->fw_event_q_name);
 
 	init_waitqueue_head(&a->buffered_ioctl_waiter);
 	init_waitqueue_head(&a->nvram_waiter);
drivers/scsi/fcoe/fcoe_sysfs.c +4 -4
index 7d3b904af9e8..06357bbf6b2c 100644
@@ -799,16 +799,16 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
 
 	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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
+					       ctlr->work_q_name);
 	if (!ctlr->work_q)
 		goto out_del;
 
 	snprintf(ctlr->devloss_work_q_name,
 		 sizeof(ctlr->devloss_work_q_name),
 		 "ctlr_dl_wq_%d", ctlr->id);
-	ctlr->devloss_work_q = create_singlethread_workqueue(
-		ctlr->devloss_work_q_name);
+	ctlr->devloss_work_q = alloc_ordered_workqueue(
+		"%s", WQ_MEM_RECLAIM, ctlr->devloss_work_q_name);
 	if (!ctlr->devloss_work_q)
 		goto out_del_q;
 
drivers/scsi/fnic/fnic_main.c +4 -2
index 29eead383eb9..0044717d4486 100644
@@ -1161,14 +1161,16 @@ static int __init fnic_init_module(void)
 		goto err_create_fnic_ioreq_slab;
 	}
 
-	fnic_event_queue = create_singlethread_workqueue("fnic_event_wq");
+	fnic_event_queue =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "fnic_event_wq");
 	if (!fnic_event_queue) {
 		printk(KERN_ERR PFX "fnic work queue create failed\n");
 		err = -ENOMEM;
 		goto err_create_fnic_workq;
 	}
 
-	fnic_fip_queue = create_singlethread_workqueue("fnic_fip_q");
+	fnic_fip_queue =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "fnic_fip_q");
 	if (!fnic_fip_queue) {
 		printk(KERN_ERR PFX "fnic FIP work queue create failed\n");
 		err = -ENOMEM;
drivers/scsi/hisi_sas/hisi_sas_main.c +2 -1
index ec1a3e7ee94d..6219807ce3b9 100644
@@ -2302,7 +2302,8 @@ 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 =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, dev_name(dev));
 	if (!hisi_hba->wq) {
 		dev_err(dev, "sas_alloc: failed to create workqueue\n");
 		goto err_out;
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +1 -1
index 2fca17cf8b51..639f72f28911 100644
@@ -3537,7 +3537,7 @@ static int ibmvscsis_probe(struct vio_dev *vdev,
 	init_completion(&vscsi->unconfig);
 
 	snprintf(wq_name, 24, "ibmvscsis%s", dev_name(&vdev->dev));
-	vscsi->work_q = create_workqueue(wq_name);
+	vscsi->work_q = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, wq_name);
 	if (!vscsi->work_q) {
 		rc = -ENOMEM;
 		dev_err(&vscsi->dev, "create_workqueue failed\n");
drivers/scsi/libfc/fc_exch.c +2 -1
index 1d91c457527f..f84a7e6ae379 100644
@@ -2693,7 +2693,8 @@ int fc_setup_exch_mgr(void)
 	fc_cpu_order = ilog2(roundup_pow_of_two(nr_cpu_ids));
 	fc_cpu_mask = (1 << fc_cpu_order) - 1;
 
-	fc_exch_workqueue = create_singlethread_workqueue("fc_exch_workqueue");
+	fc_exch_workqueue = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
+						    "fc_exch_workqueue");
 	if (!fc_exch_workqueue)
 		goto err;
 	return 0;
drivers/scsi/libfc/fc_rport.c +2 -1
index 33da3c1085f0..308cb4872f96 100644
@@ -2263,7 +2263,8 @@ struct fc4_prov fc_rport_t0_prov = {
  */
 int fc_setup_rport(void)
 {
-	rport_event_queue = create_singlethread_workqueue("fc_rport_eq");
+	rport_event_queue =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "fc_rport_eq");
 	if (!rport_event_queue)
 		return -ENOMEM;
 	return 0;
drivers/scsi/libsas/sas_init.c +2 -2
index 9c8cc723170d..8566bb1208a0 100644
@@ -122,12 +122,12 @@ 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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name);
 	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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name);
 	if (!sas_ha->disco_q)
 		goto Undo_event_q;
 
drivers/scsi/megaraid/megaraid_sas_fusion.c +2 -2
index 6c1fb8149553..1eec23da28e2 100644
@@ -1988,8 +1988,8 @@ megasas_fusion_start_watchdog(struct megasas_instance *instance)
 		 sizeof(instance->fault_handler_work_q_name),
 		 "poll_megasas%d_status", instance->host->host_no);
 
-	instance->fw_fault_work_q =
-		create_singlethread_workqueue(instance->fault_handler_work_q_name);
+	instance->fw_fault_work_q = alloc_ordered_workqueue(
+		"%s", WQ_MEM_RECLAIM, instance->fault_handler_work_q_name);
 	if (!instance->fw_fault_work_q) {
 		dev_err(&instance->pdev->dev, "Failed from %s %d\n",
 			__func__, __LINE__);
drivers/scsi/mpi3mr/mpi3mr_fw.c +2 -2
index c196dc14ad20..7c739468dca5 100644
@@ -2742,8 +2742,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 = alloc_ordered_workqueue(
+		"%s", WQ_MEM_RECLAIM, mrioc->watchdog_work_q_name);
 	if (!mrioc->watchdog_work_q) {
 		ioc_err(mrioc, "%s: failed (line=%d)\n", __func__, __LINE__);
 		return;
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -2
index b785a7e88b49..9a24f7776d64 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 = alloc_ordered_workqueue(
+		"%s", WQ_MEM_RECLAIM, ioc->fault_reset_work_q_name);
 	if (!ioc->fault_reset_work_q) {
 		ioc_err(ioc, "%s: failed (line=%d)\n", __func__, __LINE__);
 		return;
drivers/scsi/myrb.c +2 -1
index f684eb5e0489..140dc0e9cead 100644
@@ -114,7 +114,8 @@ static bool myrb_create_mempools(struct pci_dev *pdev, struct myrb_hba *cb)
 
 	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 =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, cb->work_q_name);
 	if (!cb->work_q) {
 		dma_pool_destroy(cb->dcdb_pool);
 		cb->dcdb_pool = NULL;
drivers/scsi/myrs.c +2 -1
index e824be9d9bbb..8a8f26633cda 100644
@@ -2208,7 +2208,8 @@ static bool myrs_create_mempools(struct pci_dev *pdev, struct myrs_hba *cs)
 
 	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 =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, cs->work_q_name);
 	if (!cs->work_q) {
 		dma_pool_destroy(cs->dcdb_pool);
 		cs->dcdb_pool = NULL;
drivers/scsi/qedf/qedf_main.c +7 -6
index 4813087e58a1..119afcaf6e13 100644
@@ -3374,7 +3374,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 
 	sprintf(host_buf, "qedf_%u_link",
 	    qedf->lport->host->host_no);
-	qedf->link_update_wq = create_workqueue(host_buf);
+	qedf->link_update_wq =
+		alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
 	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);
@@ -3585,8 +3586,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 
 	/* 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 = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
 	if (!qedf->ll2_recv_wq) {
 		QEDF_ERR(&(qedf->dbg_ctx), "Failed to LL2 workqueue.\n");
 		rc = -ENOMEM;
@@ -3629,7 +3629,7 @@ 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);
+		alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
 	if (!qedf->timer_work_queue) {
 		QEDF_ERR(&(qedf->dbg_ctx), "Failed to start timer "
 			  "workqueue.\n");
@@ -3641,7 +3641,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 	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 =
+			alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
 	}
 	INIT_DELAYED_WORK(&qedf->recovery_work, qedf_recovery_handler);
 
@@ -4182,7 +4183,7 @@ static int __init qedf_init(void)
 		goto err3;
 	}
 
-	qedf_io_wq = create_workqueue("qedf_io_wq");
+	qedf_io_wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, "qedf_io_wq");
 	if (!qedf_io_wq) {
 		QEDF_ERR(NULL, "Could not create qedf_io_wq.\n");
 		goto err4;
drivers/scsi/qedi/qedi_main.c +4 -2
index cd0180b1f5b9..319c1da549f7 100644
@@ -2767,7 +2767,8 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
 		}
 
 		sprintf(host_buf, "host_%d", qedi->shost->host_no);
-		qedi->tmf_thread = create_singlethread_workqueue(host_buf);
+		qedi->tmf_thread =
+			alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, host_buf);
 		if (!qedi->tmf_thread) {
 			QEDI_ERR(&qedi->dbg_ctx,
 				 "Unable to start tmf thread!\n");
@@ -2776,7 +2777,8 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
 		}
 
 		sprintf(host_buf, "qedi_ofld%d", qedi->shost->host_no);
-		qedi->offload_thread = create_workqueue(host_buf);
+		qedi->offload_thread =
+			alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
 		if (!qedi->offload_thread) {
 			QEDI_ERR(&qedi->dbg_ctx,
 				 "Unable to start offload thread!\n");
drivers/scsi/qla2xxx/qla_os.c +4 -2
index bc3b2aea3f8b..7f980e6141c2 100644
@@ -3501,11 +3501,13 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	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 =
+			alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name);
 		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 =
+			alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name);
 		INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work);
 		INIT_WORK(&ha->idc_state_handler,
 		    qla83xx_idc_state_handler_work);
drivers/scsi/qla4xxx/ql4_os.c +1 -1
index 17cccd14765f..d91f54a6e752 100644
@@ -8806,7 +8806,7 @@ static int qla4xxx_probe_adapter(struct pci_dev *pdev,
 	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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, buf);
 	if (!ha->dpc_thread) {
 		ql4_printk(KERN_WARNING, ha, "Unable to start DPC thread!\n");
 		ret = -ENODEV;
drivers/scsi/snic/snic_main.c +4 -2
index cc824dcfe7da..2bd01eb57869 100644
@@ -302,7 +302,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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
+						shost->work_q_name);
 	if (!shost->work_q) {
 		SNIC_HOST_ERR(shost, "Failed to Create ScsiHost wq.\n");
 
@@ -884,7 +885,8 @@ snic_global_data_init(void)
 	snic_glob->req_cache[SNIC_REQ_TM_CACHE] = cachep;
 
 	/* snic_event queue */
-	snic_glob->event_q = create_singlethread_workqueue("snic_event_wq");
+	snic_glob->event_q =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "snic_event_wq");
 	if (!snic_glob->event_q) {
 		SNIC_ERR("snic event queue create failed\n");
 		ret = -ENOMEM;
drivers/scsi/stex.c +2 -1
index 8ffb75be99bc..fbee7db4a835 100644
@@ -1797,7 +1797,8 @@ static int stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	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 =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, hba->work_q_name);
 	if (!hba->work_q) {
 		printk(KERN_ERR DRV_NAME "(%s): create workqueue failed\n",
 			pci_name(pdev));
drivers/scsi/vmw_pvscsi.c +2 -1
index c4fea077265e..32242d86cf5b 100644
@@ -1137,7 +1137,8 @@ static int pvscsi_setup_msg_workqueue(struct pvscsi_adapter *adapter)
 	snprintf(name, sizeof(name),
 		 "vmw_pvscsi_wq_%u", adapter->host->host_no);
 
-	adapter->workqueue = create_singlethread_workqueue(name);
+	adapter->workqueue =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name);
 	if (!adapter->workqueue) {
 		printk(KERN_ERR "vmw_pvscsi: failed to create work queue\n");
 		return 0;
drivers/ufs/core/ufshcd.c +3 -2
index 0b3d0c8e0dda..22d5e27485c5 100644
@@ -1800,7 +1800,8 @@ static void ufshcd_init_clk_scaling(struct ufs_hba *hba)
 
 	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 =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name);
 
 	hba->clk_scaling.is_initialized = true;
 }
@@ -10460,7 +10461,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	/* 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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, eh_wq_name);
 	if (!hba->eh_wq) {
 		dev_err(hba->dev, "%s: failed to create eh workqueue\n",
 			__func__);
Reviewed-by on v2 17/18
#25 lore raw

Re: [PATCH v2 17/18] scsi: ufs: Simplify alloc*_workqueue() invocation

In reply to Bart Van Assche
Quoted 4 lines · Bart Van Assche

Let alloc*_workqueue() format the workqueue name instead of calling snprintf() explicitly.

- Mani

Quoted 73 lines
---
 drivers/ufs/core/ufshcd.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)
drivers/ufs/core/ufshcd.c +7 -16
index 22d5e27485c5..ee68e911741c 100644
@@ -1785,8 +1785,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;
 
@@ -1798,10 +1796,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 =
-		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name);
+	hba->clk_scaling.workq = alloc_ordered_workqueue(
+		"ufs_clkscaling_%d", WQ_MEM_RECLAIM, hba->host->host_no);
 
 	hba->clk_scaling.is_initialized = true;
 }
@@ -2125,8 +2121,6 @@ static void ufshcd_remove_clk_gating_sysfs(struct ufs_hba *hba)
 
 static void ufshcd_init_clk_gating(struct ufs_hba *hba)
 {
-	char wq_name[sizeof("ufs_clk_gating_00")];
-
 	if (!ufshcd_is_clkgating_allowed(hba))
 		return;
 
@@ -2136,10 +2130,9 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba)
 	INIT_DELAYED_WORK(&hba->clk_gating.gate_work, ufshcd_gate_work);
 	INIT_WORK(&hba->clk_gating.ungate_work, ufshcd_ungate_work);
 
-	snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_clk_gating_%d",
-		 hba->host->host_no);
-	hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue(wq_name,
-					WQ_MEM_RECLAIM | WQ_HIGHPRI);
+	hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue(
+		"ufs_clk_gating_%d", WQ_MEM_RECLAIM | WQ_HIGHPRI,
+		hba->host->host_no);
 
 	ufshcd_init_clk_gating_sysfs(hba);
 
@@ -10392,7 +10385,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
@@ -10459,9 +10451,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 = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, eh_wq_name);
+	hba->eh_wq = alloc_ordered_workqueue("ufs_eh_wq_%d", WQ_MEM_RECLAIM,
+					     hba->host->host_no);
 	if (!hba->eh_wq) {
 		dev_err(hba->dev, "%s: failed to create eh workqueue\n",
 			__func__);
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#2 lore raw

Re: [PATCH v2 01/18] scsi: Expand all create*_workqueue() invocations

In reply to Bart Van Assche

drivers/scsi/bnx2fc/bnx2fc_fcoe.c static int _bnx2fc_create(struct net_device *netdev, · line 2367

Quoted 12 lines · Bart Van Assche
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +2 -2
index 1078c20c5ef6..f49783b89d04 100644
@@ -2363,8 +2363,8 @@ static int _bnx2fc_create(struct net_device *netdev,
 	interface->vlan_id = vlan_id;
 	interface->tm_timeout = BNX2FC_TM_TIMEOUT;
 
-	interface->timer_work_queue =
-			create_singlethread_workqueue("bnx2fc_timer_wq");
+	interface->timer_work_queue = alloc_ordered_workqueue(
+		"%s", WQ_MEM_RECLAIM, "bnx2fc_timer_wq");

Very odd line split. And there are a few more like this one. Maybe your patch needs some manual tuning after running the script ?

The patch overall looks good to me, but it would be nice to have consistency in the line splitting. Personnally, I prefer the pattern such as:

- kmpath_rdacd = create_singlethread_workqueue("kmpath_rdacd");
+ kmpath_rdacd =
+ alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "kmpath_rdacd");

instead of:

- lio_wq = create_singlethread_workqueue("efct_lio_worker");
+ lio_wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
+ "efct_lio_worker");

Though I guess that is a matter of taste :)

Signature · 2 lines
Damien Le Moal
Western Digital Research
#7 lore raw

Re: [PATCH v2 02/18] scsi: mptfusion: Simplify the alloc*_workqueue() invocations

In reply to Bart Van Assche
Quoted 4 lines · Bart Van Assche

Let alloc*_workqueue() format the workqueue names instead of calling snprintf() explicitly.

In patch 1, you have all the changes for removing the use of create_singlethread_workqueue() in a single patch, touching different drivers. But the series has 17 more patches to further cleanup the workqueue API use in various drivers. So why not have the changes in patch 1 split into these different driver patches with a title like "Cleanup and simplify workqueue API use" ? That would make reviewing easier I think and avoid having the patch 2-17 changing again code that was changed in patch 1...

Quoted 81 lines
---
 drivers/message/fusion/mptbase.c | 10 +++-------
 drivers/message/fusion/mptbase.h |  3 ---
 drivers/message/fusion/mptfc.c   |  7 ++-----
 3 files changed, 5 insertions(+), 15 deletions(-)
drivers/message/fusion/mptbase.c +3 -7
index 4bf669c55649..738bc4e60a18 100644
@@ -1856,10 +1856,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 	/* Initialize workqueue */
 	INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work);
 
-	snprintf(ioc->reset_work_q_name, MPT_KOBJ_NAME_LEN,
-		 "mpt_poll_%d", ioc->id);
-	ioc->reset_work_q = alloc_workqueue(ioc->reset_work_q_name,
-					    WQ_MEM_RECLAIM, 0);
+	ioc->reset_work_q =
+		alloc_workqueue("mpt_poll_%d", WQ_MEM_RECLAIM, 0, ioc->id);
 	if (!ioc->reset_work_q) {
 		printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
 		    ioc->name);
@@ -1986,9 +1984,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	INIT_LIST_HEAD(&ioc->fw_event_list);
 	spin_lock_init(&ioc->fw_event_lock);
-	snprintf(ioc->fw_event_q_name, MPT_KOBJ_NAME_LEN, "mpt/%d", ioc->id);
-	ioc->fw_event_q = alloc_workqueue(ioc->fw_event_q_name,
-					  WQ_MEM_RECLAIM, 0);
+	ioc->fw_event_q = alloc_workqueue("mpt/%d", WQ_MEM_RECLAIM, 0, ioc->id);
 	if (!ioc->fw_event_q) {
 		printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
 		    ioc->name);
drivers/message/fusion/mptbase.h +0 -3
index 8031173c3655..b406fd676da0 100644
@@ -729,7 +729,6 @@ typedef struct _MPT_ADAPTER
 	struct list_head	 fw_event_list;
 	spinlock_t		 fw_event_lock;
 	u8			 fw_events_off; /* if '1', then ignore events */
-	char 			 fw_event_q_name[MPT_KOBJ_NAME_LEN];
 
 	struct mutex		 sas_discovery_mutex;
 	u8			 sas_discovery_runtime;
@@ -764,7 +763,6 @@ typedef struct _MPT_ADAPTER
 	u8			 fc_link_speed[2];
 	spinlock_t		 fc_rescan_work_lock;
 	struct work_struct	 fc_rescan_work;
-	char			 fc_rescan_work_q_name[MPT_KOBJ_NAME_LEN];
 	struct workqueue_struct *fc_rescan_work_q;
 
 	/* driver forced bus resets count */
@@ -778,7 +776,6 @@ typedef struct _MPT_ADAPTER
 	spinlock_t		  scsi_lookup_lock;
 	u64			dma_mask;
 	u32			  broadcast_aen_busy;
-	char			 reset_work_q_name[MPT_KOBJ_NAME_LEN];
 	struct workqueue_struct *reset_work_q;
 	struct delayed_work	 fault_reset_work;
 
drivers/message/fusion/mptfc.c +2 -5
index a3c17c4fe69c..91242f26defb 100644
@@ -1349,11 +1349,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	/* initialize workqueue */
 
-	snprintf(ioc->fc_rescan_work_q_name, sizeof(ioc->fc_rescan_work_q_name),
-		 "mptfc_wq_%d", sh->host_no);
-	ioc->fc_rescan_work_q =
-		alloc_ordered_workqueue(ioc->fc_rescan_work_q_name,
-					WQ_MEM_RECLAIM);
+	ioc->fc_rescan_work_q = alloc_ordered_workqueue(
+		"mptfc_wq_%d", WQ_MEM_RECLAIM, sh->host_no);
 	if (!ioc->fc_rescan_work_q) {
 		error = -ENOMEM;
 		goto out_mptfc_host;
Signature · 2 lines
Damien Le Moal
Western Digital Research
author reviewer
#8 lore raw

Re: [PATCH v2 02/18] scsi: mptfusion: Simplify the alloc*_workqueue() invocations

Quoted 6 lines · Damien Le Moal
Quoted 4 lines · Bart Van Assche

Let alloc*_workqueue() format the workqueue names instead of calling snprintf() explicitly.

Quoted 7 lines

In patch 1, you have all the changes for removing the use of create_singlethread_workqueue() in a single patch, touching different drivers. But the series has 17 more patches to further cleanup the workqueue API use in various drivers. So why not have the changes in patch 1 split into these different driver patches with a title like "Cleanup and simplify workqueue API use" ? That would make reviewing easier I think and avoid having the patch 2-17 changing again code that was changed in patch 1...

Hi Damien,

Thanks for having taken a look at this patch series. Would splitting patch 01/18 really help? Splitting that patch would make the description of the split patches longer than the actual code changes. That might annoy other reviewers. Additionally, isn't typical that Coccinelle patches are applied tree-wide instead of one driver at a time? A few examples:
* 795f90c6f13c ("sysctl: treewide: constify argument ctl_table_root::permissions(table)").
* e8058a49e67f ("netlink: introduce type-checking attribute iteration").

Thanks,

Bart.

author reviewer
#3 lore raw

Re: [PATCH v2 01/18] scsi: Expand all create*_workqueue() invocations

In reply to Damien Le Moal
Quoted 30 lines · Damien Le Moal

drivers/scsi/bnx2fc/bnx2fc_fcoe.c static int _bnx2fc_create(struct net_device *netdev, · line 2367

Quoted 12 lines · Bart Van Assche
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +2 -2
index 1078c20c5ef6..f49783b89d04 100644
@@ -2363,8 +2363,8 @@ static int _bnx2fc_create(struct net_device *netdev,
  	interface->vlan_id = vlan_id;
  	interface->tm_timeout = BNX2FC_TM_TIMEOUT;
 
-	interface->timer_work_queue =
-			create_singlethread_workqueue("bnx2fc_timer_wq");
+	interface->timer_work_queue = alloc_ordered_workqueue(
+		"%s", WQ_MEM_RECLAIM, "bnx2fc_timer_wq");

Very odd line split. And there are a few more like this one. Maybe your patch needs some manual tuning after running the script ?

The patch overall looks good to me, but it would be nice to have consistency in the line splitting. Personnally, I prefer the pattern such as:

drivers/scsi/device_handler/scsi_dh_rdac.c +2 -1
-	kmpath_rdacd = create_singlethread_workqueue("kmpath_rdacd");
+	kmpath_rdacd =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "kmpath_rdacd");

instead of:

drivers/scsi/elx/efct/efct_lio.c +2 -1
-	lio_wq = create_singlethread_workqueue("efct_lio_worker");
+	lio_wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
+					 "efct_lio_worker");
Quoted 1 line

Though I guess that is a matter of taste :)

(reduced cc-list)

If I run "git clang-format HEAD^" on this patch, no code is changed. Does this perhaps mean that the .clang-format style file in the kernel tree needs further tuning? The most recent change in that file other
than adding for-each macro names is from two years ago (see also commit 781121a7f6d1 ("clang-format: Fix space after for_each macros")). Or does this perhaps mean that there is broad agreement about the coding style
parameters in the .clang-format file?

Thanks,

Bart.

#9 lore raw

Re: [PATCH v2 02/18] scsi: mptfusion: Simplify the alloc*_workqueue() invocations

In reply to Bart Van Assche
Quoted 17 lines · Bart Van Assche
Quoted 6 lines · Damien Le Moal
Quoted 4 lines · Bart Van Assche

Let alloc*_workqueue() format the workqueue names instead of calling snprintf() explicitly.

Quoted 7 lines

In patch 1, you have all the changes for removing the use of create_singlethread_workqueue() in a single patch, touching different drivers. But the series has 17 more patches to further cleanup the workqueue API use in various drivers. So why not have the changes in patch 1 split into these different driver patches with a title like "Cleanup and simplify workqueue API use" ? That would make reviewing easier I think and avoid having the patch 2-17 changing again code that was changed in patch 1...

Hi Damien,

Quoted 9 lines

Thanks for having taken a look at this patch series. Would splitting patch 01/18 really help? Splitting that patch would make the description of the split patches longer than the actual code changes. That might annoy other reviewers. Additionally, isn't typical that Coccinelle patches are applied tree-wide instead of one driver at a time? A few examples:
* 795f90c6f13c ("sysctl: treewide: constify argument ctl_table_root::permissions(table)").
* e8058a49e67f ("netlink: introduce type-checking attribute iteration").

I know about script-based patches. But in this case, the script generated patch changes lines of code that following patches change again (not all of them though). So I thought splitting patch 1 may be a good idea as that would as well isolate driver changes in their own patches, which definitely should facilitate reviewing by the driver maintainers.

But no strong feelings about all this. If you do not want to do that, fine.

Quoted 5 lines

Thanks,

Bart.

Signature · 2 lines
Damien Le Moal
Western Digital Research
#4 lore raw

Re: [PATCH v2 01/18] scsi: Expand all create*_workqueue() invocations

In reply to Bart Van Assche
Quoted 35 lines · Bart Van Assche
Quoted 30 lines · Damien Le Moal

drivers/scsi/bnx2fc/bnx2fc_fcoe.c static int _bnx2fc_create(struct net_device *netdev, · line 2367

Quoted 12 lines · Bart Van Assche
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +2 -2
index 1078c20c5ef6..f49783b89d04 100644
@@ -2363,8 +2363,8 @@ static int _bnx2fc_create(struct net_device *netdev,
  	interface->vlan_id = vlan_id;
  	interface->tm_timeout = BNX2FC_TM_TIMEOUT;
 
-	interface->timer_work_queue =
-			create_singlethread_workqueue("bnx2fc_timer_wq");
+	interface->timer_work_queue = alloc_ordered_workqueue(
+		"%s", WQ_MEM_RECLAIM, "bnx2fc_timer_wq");

Very odd line split. And there are a few more like this one. Maybe your patch needs some manual tuning after running the script ?

The patch overall looks good to me, but it would be nice to have consistency in the line splitting. Personnally, I prefer the pattern such as:

drivers/scsi/device_handler/scsi_dh_rdac.c +2 -1
-	kmpath_rdacd = create_singlethread_workqueue("kmpath_rdacd");
+	kmpath_rdacd =
+		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "kmpath_rdacd");

instead of:

drivers/scsi/elx/efct/efct_lio.c +2 -1
-	lio_wq = create_singlethread_workqueue("efct_lio_worker");
+	lio_wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
+					 "efct_lio_worker");
Quoted 1 line

Though I guess that is a matter of taste :)

(reduced cc-list)

Quoted 7 lines

If I run "git clang-format HEAD^" on this patch, no code is changed. Does this perhaps mean that the .clang-format style file in the kernel tree needs further tuning? The most recent change in that file other than adding for-each macro names is from two years ago (see also commit 781121a7f6d1 ("clang-format: Fix space after for_each macros")). Or does this perhaps mean that there is broad agreement about the coding style parameters in the .clang-format file?

As I said, most likely a matter of taste :)
The pattern:

	lio_wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
					 "efct_lio_worker");

follows the regular kernel coding style.
I only meant to say that I find the pattern:

	lio_wq =
		alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "efct_lio_worker");

more pleasing visually. But the line may be too long anyway...

Quoted 6 lines

Thanks,

Bart.

Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v2 1/18
#5 lore raw

Re: [PATCH v2 01/18] scsi: Expand all create*_workqueue() invocations

In reply to Bart Van Assche
Quoted 41 lines · Bart Van Assche

External email : Please do not click links or open attachments until you have verified the sender or the content.
The workqueue maintainer wants to remove the create*_workqueue()
macros
because these macros always set the WQ_MEM_RECLAIM flag and because these
only support literal workqueue names. Hence this patch that replaces the
create*_workqueue() invocations with the definition of this macro. The
WQ_MEM_RECLAIM flag has been retained because I think that flag is necessary
for workqueues created by storage drivers. This patch has been generated by
running spatch and git clang-format. spatch has been invoked as follows:

spatch --in-place --sp-file expand-create-workqueue.spatch $(git grep -lEw 'create_(freezable_|singlethread_|)workqueue' */scsi */ufs)

The contents of the expand-create-workqueue.spatch file is as follows:

@@
expression name;
@@

(quoted diff) +1 -1
-create_workqueue(name)
+alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, name)

@@
expression name;
@@

(quoted diff) +1 -1
-create_freezable_workqueue(name)
+alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1,

name)
@@
expression name;
@@

(quoted diff) +1 -1
-create_singlethread_workqueue(name)
+alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name)
Quoted 2 lines
Reviewed-by on v2 17/18
#26 lore raw

Re: [PATCH v2 17/18] scsi: ufs: Simplify alloc*_workqueue() invocation

In reply to Bart Van Assche
Quoted 9 lines · Bart Van Assche

External email : Please do not click links or open attachments until you have verified the sender or the content.
Let alloc*_workqueue() format the workqueue name instead of calling
snprintf() explicitly.

---