Thread (8 messages) 8 messages, 4 authors, 2021-06-14

Re: BUG: scheduling while atomic when nvmet_rdma_queue_response fails in posting a request

From: Keith Busch <kbusch@kernel.org>
Date: 2021-06-08 18:41:55

On Tue, Jun 08, 2021 at 10:43:45AM -0700, Sagi Grimberg wrote:
quoted hunk ↗ jump to hunk
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 7d607f435e36..6d2eea322779 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -16,6 +16,7 @@
 #include <linux/wait.h>
 #include <linux/inet.h>
 #include <asm/unaligned.h>
+#include <linux/async.h>

 #include <rdma/ib_verbs.h>
 #include <rdma/rdma_cm.h>
@@ -712,6 +713,12 @@ static void nvmet_rdma_send_done(struct ib_cq *cq,
struct ib_wc *wc)
        }
 }

+static void nvmet_rdma_async_release_rsp(void *data, async_cookie_t cookie)
+{
+       struct nvmet_rdma_rsp *rsp = data;
+       nvmet_rdma_release_rsp(rsp);
+}
+
 static void nvmet_rdma_queue_response(struct nvmet_req *req)
 {
        struct nvmet_rdma_rsp *rsp =
@@ -745,7 +752,12 @@ static void nvmet_rdma_queue_response(struct nvmet_req
*req)

        if (unlikely(ib_post_send(cm_id->qp, first_wr, NULL))) {
                pr_err("sending cmd response failed\n");
-               nvmet_rdma_release_rsp(rsp);
+               /*
+                * We might be in atomic context, hence release
+                * the rsp in async context in case we need to
+                * process the wr_wait_list.
+                */
+               async_schedule(nvmet_rdma_async_release_rsp, rsp);
        }
 }
Just FYI, async_schedule() has conditions where it may execute your
callback synchronously. Your suggestion is probably fine for testing,
but it sounds like you require something that can guarantee a non-atomic
context for nvmet_rdma_release_rsp().

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help