linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IB/isert: Avoid flush_scheduled_work() usage
@ 2022-05-05  6:07 Tetsuo Handa
  2022-05-10 18:28 ` Sagi Grimberg
  2022-05-20 14:18 ` Jason Gunthorpe
  0 siblings, 2 replies; 4+ messages in thread
From: Tetsuo Handa @ 2022-05-05  6:07 UTC (permalink / raw)
  To: Sagi Grimberg, Jason Gunthorpe, Leon Romanovsky
  Cc: OFED mailing list, target-devel

Flushing system-wide workqueues is dangerous and will be forbidden.
Replace system_wq with local isert_login_wq.

Link: https://lkml.kernel.org/r/49925af7-78a8-a3dd-bce6-cfc02e1a9236@I-love.SAKURA.ne.jp
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
Note: This patch is only compile tested.

 drivers/infiniband/ulp/isert/ib_isert.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 181e39e2a673..b9e8afb51f6e 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -42,6 +42,7 @@ MODULE_PARM_DESC(sg_tablesize,
 
 static DEFINE_MUTEX(device_list_mutex);
 static LIST_HEAD(device_list);
+static struct workqueue_struct *isert_login_wq;
 static struct workqueue_struct *isert_comp_wq;
 static struct workqueue_struct *isert_release_wq;
 
@@ -1017,7 +1018,7 @@ isert_rx_login_req(struct isert_conn *isert_conn)
 		complete(&isert_conn->login_comp);
 		return;
 	}
-	schedule_delayed_work(&conn->login_work, 0);
+	queue_delayed_work(isert_login_wq, &conn->login_work, 0);
 }
 
 static struct iscsi_cmd
@@ -2348,9 +2349,9 @@ isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)
 
 	/*
 	 * For login requests after the first PDU, isert_rx_login_req() will
-	 * kick schedule_delayed_work(&conn->login_work) as the packet is
-	 * received, which turns this callback from iscsi_target_do_login_rx()
-	 * into a NOP.
+	 * kick queue_delayed_work(isert_login_wq, &conn->login_work) as
+	 * the packet is received, which turns this callback from
+	 * iscsi_target_do_login_rx() into a NOP.
 	 */
 	if (!login->first_request)
 		return 0;
@@ -2606,20 +2607,23 @@ static struct iscsit_transport iser_target_transport = {
 
 static int __init isert_init(void)
 {
-	int ret;
+	isert_login_wq = alloc_workqueue("isert_login_wq", 0, 0);
+	if (!isert_login_wq) {
+		isert_err("Unable to allocate isert_login_wq\n");
+		return -ENOMEM;
+	}
 
 	isert_comp_wq = alloc_workqueue("isert_comp_wq",
 					WQ_UNBOUND | WQ_HIGHPRI, 0);
 	if (!isert_comp_wq) {
 		isert_err("Unable to allocate isert_comp_wq\n");
-		return -ENOMEM;
+		goto destroy_login_wq;
 	}
 
 	isert_release_wq = alloc_workqueue("isert_release_wq", WQ_UNBOUND,
 					WQ_UNBOUND_MAX_ACTIVE);
 	if (!isert_release_wq) {
 		isert_err("Unable to allocate isert_release_wq\n");
-		ret = -ENOMEM;
 		goto destroy_comp_wq;
 	}
 
@@ -2630,17 +2634,20 @@ static int __init isert_init(void)
 
 destroy_comp_wq:
 	destroy_workqueue(isert_comp_wq);
+destroy_login_wq:
+	destroy_workqueue(isert_login_wq);
 
-	return ret;
+	return -ENOMEM;
 }
 
 static void __exit isert_exit(void)
 {
-	flush_scheduled_work();
+	flush_workqueue(isert_login_wq);
 	destroy_workqueue(isert_release_wq);
 	destroy_workqueue(isert_comp_wq);
 	iscsit_unregister_transport(&iser_target_transport);
 	isert_info("iSER_TARGET[0] - Released iser_target_transport\n");
+	destroy_workqueue(isert_login_wq);
 }
 
 MODULE_DESCRIPTION("iSER-Target for mainline target infrastructure");
-- 
2.18.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] IB/isert: Avoid flush_scheduled_work() usage
  2022-05-05  6:07 [PATCH] IB/isert: Avoid flush_scheduled_work() usage Tetsuo Handa
@ 2022-05-10 18:28 ` Sagi Grimberg
  2022-05-19  9:58   ` Tetsuo Handa
  2022-05-20 14:18 ` Jason Gunthorpe
  1 sibling, 1 reply; 4+ messages in thread
From: Sagi Grimberg @ 2022-05-10 18:28 UTC (permalink / raw)
  To: Tetsuo Handa, Jason Gunthorpe, Leon Romanovsky
  Cc: OFED mailing list, target-devel

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] IB/isert: Avoid flush_scheduled_work() usage
  2022-05-10 18:28 ` Sagi Grimberg
@ 2022-05-19  9:58   ` Tetsuo Handa
  0 siblings, 0 replies; 4+ messages in thread
From: Tetsuo Handa @ 2022-05-19  9:58 UTC (permalink / raw)
  To: Sagi Grimberg, Jason Gunthorpe, Leon Romanovsky
  Cc: OFED mailing list, target-devel

On 2022/05/11 3:28, Sagi Grimberg wrote:
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

Thank you. Which tree should this patch go to?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] IB/isert: Avoid flush_scheduled_work() usage
  2022-05-05  6:07 [PATCH] IB/isert: Avoid flush_scheduled_work() usage Tetsuo Handa
  2022-05-10 18:28 ` Sagi Grimberg
@ 2022-05-20 14:18 ` Jason Gunthorpe
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2022-05-20 14:18 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: Sagi Grimberg, Leon Romanovsky, OFED mailing list, target-devel

On Thu, May 05, 2022 at 03:07:25PM +0900, Tetsuo Handa wrote:
> Flushing system-wide workqueues is dangerous and will be forbidden.
> Replace system_wq with local isert_login_wq.
> 
> Link: https://lkml.kernel.org/r/49925af7-78a8-a3dd-bce6-cfc02e1a9236@I-love.SAKURA.ne.jp
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
> ---
> Note: This patch is only compile tested.
> 
>  drivers/infiniband/ulp/isert/ib_isert.c | 25 ++++++++++++++++---------
>  1 file changed, 16 insertions(+), 9 deletions(-)

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-20 14:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05  6:07 [PATCH] IB/isert: Avoid flush_scheduled_work() usage Tetsuo Handa
2022-05-10 18:28 ` Sagi Grimberg
2022-05-19  9:58   ` Tetsuo Handa
2022-05-20 14:18 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).