Skip to contentSkip to conversation

scsi: iscsi: register sysfs for iscsi workqueue

PATCH Superseded Bob Liu 2 participants 4 messages Apr 17, 2020 – Apr 28, 2020

Subsystems (2)
lore
Share & tools
lore

Bob Liu

author
#0 lore raw

PATCH v2 1/1 scsi: iscsi: register sysfs for iscsi workqueue

Then users can set cpu affinity through "cpumask" for iscsi workqueues, so as to get performance isolation.

This patch changes the max number of active worker form 1 to 2, since ordered workqueue wont' be allowed to change "cpumask".

---
 drivers/scsi/libiscsi.c             | 4 +++-
 drivers/scsi/scsi_transport_iscsi.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +3 -1
index 70b99c0..adf9bb4 100644
@@ -2627,7 +2627,9 @@ struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
 	if (xmit_can_sleep) {
 		snprintf(ihost->workq_name, sizeof(ihost->workq_name),
 			"iscsi_q_%d", shost->host_no);
-		ihost->workq = create_singlethread_workqueue(ihost->workq_name);
+		ihost->workq = alloc_workqueue("%s",
+			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
+			2, ihost->workq_name);
 		if (!ihost->workq)
 			goto free_host;
 	}
drivers/scsi/scsi_transport_iscsi.c +3 -1
index dfc726f..bdbc4a2 100644
@@ -4602,7 +4602,9 @@ static __init int iscsi_transport_init(void)
 		goto unregister_flashnode_bus;
 	}
 
-	iscsi_eh_timer_workq = create_singlethread_workqueue("iscsi_eh");
+	iscsi_eh_timer_workq = alloc_workqueue("%s",
+			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
+			2, "iscsi_eh");
 	if (!iscsi_eh_timer_workq) {
 		err = -ENOMEM;
 		goto release_nls;
Signature · 1 line
2.9.5
author
#1 lore raw

Friendly ping..

Quoted 43 lines · Bob Liu

Then users can set cpu affinity through "cpumask" for iscsi workqueues, so as to get performance isolation.

This patch changes the max number of active worker form 1 to 2, since ordered workqueue wont' be allowed to change "cpumask".

---
 drivers/scsi/libiscsi.c             | 4 +++-
 drivers/scsi/scsi_transport_iscsi.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +3 -1
index 70b99c0..adf9bb4 100644
@@ -2627,7 +2627,9 @@ struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
 	if (xmit_can_sleep) {
 		snprintf(ihost->workq_name, sizeof(ihost->workq_name),
 			"iscsi_q_%d", shost->host_no);
-		ihost->workq = create_singlethread_workqueue(ihost->workq_name);
+		ihost->workq = alloc_workqueue("%s",
+			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
+			2, ihost->workq_name);
 		if (!ihost->workq)
 			goto free_host;
 	}
drivers/scsi/scsi_transport_iscsi.c +3 -1
index dfc726f..bdbc4a2 100644
@@ -4602,7 +4602,9 @@ static __init int iscsi_transport_init(void)
 		goto unregister_flashnode_bus;
 	}
 
-	iscsi_eh_timer_workq = create_singlethread_workqueue("iscsi_eh");
+	iscsi_eh_timer_workq = alloc_workqueue("%s",
+			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
+			2, "iscsi_eh");
 	if (!iscsi_eh_timer_workq) {
 		err = -ENOMEM;
 		goto release_nls;
#2 lore raw
In reply to Bob Liu
Quoted 6 lines · Bob Liu

Then users can set cpu affinity through "cpumask" for iscsi workqueues, so as to get performance isolation.

This patch changes the max number of active worker form 1 to 2, since ordered workqueue wont' be allowed to change "cpumask".

Won't having 2 workers break the current ordering guarantees? Did you check that no-one depends on this?

Quoted 11 lines
---
 drivers/scsi/libiscsi.c             | 4 +++-
 drivers/scsi/scsi_transport_iscsi.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +0 -0
index 70b99c0..adf9bb4 100644

drivers/scsi/libiscsi.c struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht, · line 2632

Quoted 7 lines
drivers/scsi/libiscsi.c +3 -1
@@ -2627,7 +2627,9 @@ struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
 	if (xmit_can_sleep) {
 		snprintf(ihost->workq_name, sizeof(ihost->workq_name),
 			"iscsi_q_%d", shost->host_no);
-		ihost->workq = create_singlethread_workqueue(ihost->workq_name);
+		ihost->workq = alloc_workqueue("%s",
+			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
+			2, ihost->workq_name);

From looking at the documentation, __WQ_LEGACY doesn't seem to belong here.

Quoted 19 lines
drivers/scsi/libiscsi.c +0 -0
 		if (!ihost->workq)
 			goto free_host;
 	}
drivers/scsi/scsi_transport_iscsi.c +3 -1
index dfc726f..bdbc4a2 100644
@@ -4602,7 +4602,9 @@ static __init int iscsi_transport_init(void)
 		goto unregister_flashnode_bus;
 	}
 
-	iscsi_eh_timer_workq = create_singlethread_workqueue("iscsi_eh");
+	iscsi_eh_timer_workq = alloc_workqueue("%s",
+			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
+			2, "iscsi_eh");
 	if (!iscsi_eh_timer_workq) {
 		err = -ENOMEM;
 		goto release_nls;
author
#3 lore raw

Sorry forgot Cc iscsi maintainers.

Quoted 9 lines · Julian Wiedmann
Quoted 6 lines · Bob Liu

Then users can set cpu affinity through "cpumask" for iscsi workqueues, so as to get performance isolation.

This patch changes the max number of active worker form 1 to 2, since ordered workqueue wont' be allowed to change "cpumask".

Won't having 2 workers break the current ordering guarantees?

Yes.

Quoted 2 lines

Did you check that no-one depends on this?

Not quite sure, I'd better add [rfc] to this patch.
But this is the easiest way to set cpu affinity of iscsi workqueue.

Quoted 6 lines
Quoted 6 lines
---
 drivers/scsi/libiscsi.c             | 4 +++-
 drivers/scsi/scsi_transport_iscsi.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Quoted 15 lines

drivers/scsi/libiscsi.c struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht, · line 2632

Quoted 12 lines
drivers/scsi/libiscsi.c +3 -1
index 70b99c0..adf9bb4 100644
@@ -2627,7 +2627,9 @@ struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
 	if (xmit_can_sleep) {
 		snprintf(ihost->workq_name, sizeof(ihost->workq_name),
 			"iscsi_q_%d", shost->host_no);
-		ihost->workq = create_singlethread_workqueue(ihost->workq_name);
+		ihost->workq = alloc_workqueue("%s",
+			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
+			2, ihost->workq_name);

From looking at the documentation, __WQ_LEGACY doesn't seem to belong here.

Indeed, thanks for the review.

Quoted 20 lines
Quoted 19 lines
drivers/scsi/libiscsi.c +0 -0
 		if (!ihost->workq)
 			goto free_host;
 	}
drivers/scsi/scsi_transport_iscsi.c +3 -1
index dfc726f..bdbc4a2 100644
@@ -4602,7 +4602,9 @@ static __init int iscsi_transport_init(void)
 		goto unregister_flashnode_bus;
 	}
 
-	iscsi_eh_timer_workq = create_singlethread_workqueue("iscsi_eh");
+	iscsi_eh_timer_workq = alloc_workqueue("%s",
+			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
+			2, "iscsi_eh");
 	if (!iscsi_eh_timer_workq) {
 		err = -ENOMEM;
 		goto release_nls;