Last WQE Reached event treatment
Subsystems (8)
cover Last WQE Reached event treatment
Hi Jason/Leon/Sagi,
This series adds a support for draining a QP that is associated with a SRQ (Shared Receive Queue).
Leakage problem can occur if we won't treat Last WQE Reached event.
In the series, that is based on some old series I've send during 2018, I used a different approach and handled the event in the RDMA core, as was suggested in discussion in the mailing list.
I've updated RDMA ULPs. Most of them were trivial except IPoIB that was handling the Last WQE reached in the ULP.
I've tested this series with NVMf/RDMA on RoCE.
Max Gurtovoy (6):
IB/core: add support for draining Shared receive queues IB/isert: remove the handling of last WQE reached event RDMA/srpt: remove the handling of last WQE reached event
nvmet-rdma: remove the handling of last WQE reached event
svcrdma: remove the handling of last WQE reached event RDMA/IPoIB: remove the handling of last WQE reached event
drivers/infiniband/core/verbs.c | 83 +++++++++++++++++++++++- drivers/infiniband/ulp/ipoib/ipoib.h | 33 +--------- drivers/infiniband/ulp/ipoib/ipoib_cm.c | 71 ++------------------ drivers/infiniband/ulp/isert/ib_isert.c | 3 - drivers/infiniband/ulp/srpt/ib_srpt.c | 5 -- drivers/nvme/target/rdma.c | 4 -- include/rdma/ib_verbs.h | 2 + net/sunrpc/xprtrdma/svc_rdma_transport.c | 1 - 8 files changed, 92 insertions(+), 110 deletions(-)
Signature · 1 line
2.18.1
PATCH 1/6 IB/core: add support for draining Shared receive queues
To avoid leakage for QPs assocoated with SRQ, according to IB spec (section 10.3.1):
"Note, for QPs that are associated with an SRQ, the Consumer should take the QP through the Error State before invoking a Destroy QP or a Modify QP to the Reset State. The Consumer may invoke the Destroy QP without first performing a Modify QP to the Error State and waiting for the Affiliated Asynchronous Last WQE Reached Event. However, if the Consumer does not wait for the Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment leakage may occur. Therefore, it is good programming practice to teardown a QP that is associated with an SRQ by using the following process:
- Put the QP in the Error State;
- wait for the Affiliated Asynchronous Last WQE Reached Event;
- either:
- drain the CQ by invoking the Poll CQ verb and either wait for CQ to be empty or the number of Poll CQ operations has exceeded CQ capacity size; or
- post another WR that completes on the same CQ and wait for this
WR to return as a WC;
- and then invoke a Destroy QP or Reset QP."
Catch the Last WQE Reached Event in the core layer without involving the ULP drivers with extra logic during drain and destroy QP flows.
The "Last WQE Reached" event will only be send on the errant QP, for signaling that the SRQ flushed all the WQEs that have been dequeued from the SRQ for processing by the associated QP.
--- drivers/infiniband/core/verbs.c | 83 ++++++++++++++++++++++++++++++++- include/rdma/ib_verbs.h | 2 + 2 files changed, 84 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +82 -1
@@ -1101,6 +1101,16 @@ EXPORT_SYMBOL(ib_destroy_srq_user);/* Queue pairs */ +static void __ib_qp_event_handler (struct ib_event *event,void *context) +{ +struct ib_qp *qp = event->element.qp; + +if (event->event ==IB_EVENT_QP_LAST_WQE_REACHED ) +complete (&qp->srq_completion); +else if (qp->registered_event_handler) + qp->registered_event_handler (event, qp->qp_context); +} +static void __ib_shared_qp_event_handler (struct ib_event *event,void *context) {struct ib_qp *qp = context;
@@ -1221,7 +1231,10 @@ static struct ib_qp *create_qp(struct ib_device *dev, struct ib_pd *pd, qp->qp_type = attr->qp_type; qp->rwq_ind_tbl = attr->rwq_ind_tbl; qp->srq = attr->srq; - qp->event_handler = attr->event_handler; +if (qp->srq) +init_completion (&qp->srq_completion); + qp->event_handler = __ib_qp_event_handler; + qp->registered_event_handler = attr->event_handler; qp->port = attr->port_num; qp->qp_context = attr->qp_context;
@@ -2884,6 +2897,72 @@ static void __ib_drain_rq(struct ib_qp *qp)wait_for_completion (&rdrain.done); } +/* +* __ib_drain_srq() - Block until Last WQE Reached event arrives, or timeout +* expires. +* @qp: queue pair associated with SRQ to drain +* +* Quoting 10.3.1 Queue Pair and EE Context States: +* +* Note, for QPs that are associated with an SRQ, the Consumer should take the +* QP through the Error State before invoking a Destroy QP or a Modify QP to the +* Reset State. The Consumer may invoke the Destroy QP without first performing +* a Modify QP to the Error State and waiting for the Affiliated Asynchronous +* Last WQE Reached Event. However, if the Consumer does not wait for the +* Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment +* leakage may occur. Therefore, it is good programming practice to tear down a +* QP that is associated with an SRQ by using the following process: +* +* - Put the QP in the Error State +* - Wait for the Affiliated Asynchronous Last WQE Reached Event; +* - either: +* drain the CQ by invoking the Poll CQ verb and either wait for CQ +* to be empty or the number of Poll CQ operations has exceeded +* CQ capacity size; +* - or +* post another WR that completes on the same CQ and wait for this +* WR to return as a WC; +* - and then invoke a Destroy QP or Reset QP. +* +* We use the first option. +*/ +static void __ib_drain_srq (struct ib_qp *qp) +{ +struct ib_qp_attr attr = { .qp_state =IB_QPS_ERR }; +struct ib_cq *cq; +int n, polled =0 ; +int ret; + +if (!qp->srq) { +WARN_ONCE (1 ,"QP 0x%p is not associated with SRQ\n" , qp); +return ; + } + + ret =ib_modify_qp (qp, &attr,IB_QP_STATE ); +if (ret) { +WARN_ONCE (ret,"failed to drain shared recv queue: %d\n" , ret); +return ; + } + +if (ib_srq_has_cq (qp->srq->srq_type)) { + cq = qp->srq->ext.cq; + }else if (qp->recv_cq) { + cq = qp->recv_cq; + }else { +WARN_ONCE (1 ,"QP 0x%p has no CQ associated with SRQ\n" , qp); +return ; + } + +if (wait_for_completion_timeout (&qp->srq_completion,10 *HZ ) >0 ) { +while (polled != cq->cqe) { + n =ib_process_cq_direct (cq, cq->cqe - polled); +if (!n) +return ; + polled += n; + } + } +} +/** * ib_drain_sq() - Block until all SQ CQEs have been consumed by the * application.
@@ -2962,6 +3041,8 @@ void ib_drain_qp(struct ib_qp *qp)ib_drain_sq (qp);if (!qp->srq)ib_drain_rq (qp); +else +__ib_drain_srq (qp); }EXPORT_SYMBOL (ib_drain_qp);
include/rdma/ib_verbs.h +2 -0
@@ -1788,6 +1788,7 @@ struct ib_qp {struct list_head rdma_mrs;struct list_head sig_mrs;struct ib_srq *srq; +struct completion srq_completion;struct ib_xrcd *xrcd;/* XRC TGT QPs only */ struct list_head xrcd_list;
@@ -1797,6 +1798,7 @@ struct ib_qp {struct ib_qp *real_qp;struct ib_uqp_object *uobject;void (*event_handler)(struct ib_event *,void *); +void (*registered_event_handler)(struct ib_event *,void *);void *qp_context;/* sgid_attrs associated with the AV's */ const struct ib_gid_attr *av_sgid_attr;
Signature · 1 line
2.18.1
PATCH 2/6 IB/isert: remove the handling of last WQE reached event
In reply to Max GurtovoyThis event is handled by the RDMA core layer.
--- drivers/infiniband/ulp/isert/ib_isert.c | 3 --- 1 file changed, 3 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +0 -3
@@ -91,9 +91,6 @@ isert_qp_event_callback(struct ib_event *e, void *context)case IB_EVENT_COMM_EST :rdma_notify (isert_conn->cm_id,IB_EVENT_COMM_EST );break ; -case IB_EVENT_QP_LAST_WQE_REACHED : -isert_warn ("Reached TX IB_EVENT_QP_LAST_WQE_REACHED\n" ); -break ;default :break ; }
Signature · 1 line
2.18.1
PATCH 3/6 RDMA/srpt: remove the handling of last WQE reached event
In reply to Max GurtovoyThis event is handled by the RDMA core layer.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +0 -5
@@ -231,11 +231,6 @@ static void srpt_qp_event(struct ib_event *event, void *ptr)else ib_cm_notify (ch->ib_cm.cm_id, event->event);break ; -case IB_EVENT_QP_LAST_WQE_REACHED : -pr_debug ("%s-%d, state %s: received Last WQE event.\n" , - ch->sess_name, ch->qp->qp_num, -get_ch_state_name (ch->state)); -break ;default :pr_err ("received unrecognized IB QP event %d\n" , event->event);break ;
Signature · 1 line
2.18.1
PATCH 4/6 nvmet-rdma: remove the handling of last WQE reached event
In reply to Max GurtovoyThis event is handled by the RDMA core layer.
--- drivers/nvme/target/rdma.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/nvme/target/rdma.c +0 -4
@@ -1520,10 +1520,6 @@ static void nvmet_rdma_qp_event(struct ib_event *event, void *priv)case IB_EVENT_COMM_EST :rdma_notify (queue->cm_id, event->event);break ; -case IB_EVENT_QP_LAST_WQE_REACHED : -pr_debug ("received last WQE reached event for queue=0x%p\n" , - queue); -break ;default :pr_err ("received IB QP event: %s (%d)\n" ,ib_event_msg (event->event), event->event);
Signature · 1 line
2.18.1
PATCH 5/6 svcrdma: remove the handling of last WQE reached event
In reply to Max GurtovoyThis event is handled by the RDMA core layer.
--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 1 - 1 file changed, 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +0 -1
@@ -107,7 +107,6 @@ static void qp_event_handler(struct ib_event *event, void *context)case IB_EVENT_PATH_MIG :case IB_EVENT_COMM_EST :case IB_EVENT_SQ_DRAINED : -case IB_EVENT_QP_LAST_WQE_REACHED :break ;/* These are considered fatal events */
Signature · 1 line
2.18.1
PATCH 6/6 RDMA/IPoIB: remove the handling of last WQE reached event
In reply to Max GurtovoyThis event is handled by the RDMA core layer.
--- drivers/infiniband/ulp/ipoib/ipoib.h | 33 +----------- drivers/infiniband/ulp/ipoib/ipoib_cm.c | 71 +++---------------------- 2 files changed, 8 insertions(+), 96 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib.h +2 -31
@@ -198,37 +198,10 @@ struct ipoib_cm_data {__be32 mtu; }; -/* -* Quoting 10.3.1 Queue Pair and EE Context States: -* -* Note, for QPs that are associated with an SRQ, the Consumer should take the -* QP through the Error State before invoking a Destroy QP or a Modify QP to the -* Reset State. The Consumer may invoke the Destroy QP without first performing -* a Modify QP to the Error State and waiting for the Affiliated Asynchronous -* Last WQE Reached Event. However, if the Consumer does not wait for the -* Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment -* leakage may occur. Therefore, it is good programming practice to tear down a -* QP that is associated with an SRQ by using the following process: -* -* - Put the QP in the Error State -* - Wait for the Affiliated Asynchronous Last WQE Reached Event; -* - either: -* drain the CQ by invoking the Poll CQ verb and either wait for CQ -* to be empty or the number of Poll CQ operations has exceeded -* CQ capacity size; -* - or -* post another WR that completes on the same CQ and wait for this -* WR to return as a WC; -* - and then invoke a Destroy QP or Reset QP. -* -* We use the second option and wait for a completion on the -* same CQ before destroying QPs attached to our SRQ. -*/ -enum ipoib_cm_state {IPOIB_CM_RX_LIVE ,IPOIB_CM_RX_ERROR ,/* Ignored by stale task */ -IPOIB_CM_RX_FLUSH /* Last WQE Reached event observed */ +IPOIB_CM_RX_FLUSH };struct ipoib_cm_rx {
@@ -267,9 +240,7 @@ struct ipoib_cm_dev_priv {struct ib_cm_id *id;struct list_head passive_ids;/* state: LIVE */ struct list_head rx_error_list;/* state: ERROR */ -struct list_head rx_flush_list;/* state: FLUSH, drain not started */ -struct list_head rx_drain_list;/* state: FLUSH, drain started */ -struct list_head rx_reap_list;/* state: FLUSH, drain done */ +struct list_head rx_reap_list;/* state: FLUSH */ struct work_struct start_task;struct work_struct reap_task;struct work_struct skb_task;
drivers/infiniband/ulp/ipoib/ipoib_cm.c +6 -65
132 lines not on this page · raw message
Signature · 1 line
2.18.1
Re: [PATCH 5/6] svcrdma: remove the handling of last WQE reached event
In reply to Max GurtovoyQuoted 22 lines · Max Gurtovoy
This event is handled by the RDMA core layer.
Signed-off-by Max Gurtovoy <[email protected]>--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 1 - 1 file changed, 1 deletion(-)net/sunrpc/xprtrdma/svc_rdma_transport.c +0
-1@@ -107,7 +107,6 @@ static void qp_event_handler(struct ib_event *event, void *context)case IB_EVENT_PATH_MIG :case IB_EVENT_COMM_EST :case IB_EVENT_SQ_DRAINED : -case IB_EVENT_QP_LAST_WQE_REACHED :break ;/* These are considered fatal events */ Signature · 1 line
2.18.1
Signature · 1 line
Chuck Lever
Bart Van Assche
maintainerRe: [PATCH 1/6] IB/core: add support for draining Shared receive queues
In reply to Max Gurtovoydrivers/infiniband/core/verbs.c static void __ib_drain_rq(struct ib_qp *qp) · line 2963
Quoted 8 lines · Max Gurtovoy
drivers/infiniband/core/verbs.c +8
-0+if (wait_for_completion_timeout (&qp->srq_completion,10 *HZ ) >0 ) { +while (polled != cq->cqe) { + n =ib_process_cq_direct (cq, cq->cqe - polled); +if (!n) +return ; + polled += n; + } + }
Why a hardcoded timeout (10 * HZ) instead of waiting forever?
Thanks,
Bart.
Re: [PATCH 3/6] RDMA/srpt: remove the handling of last WQE reached event
In reply to Max GurtovoyQuoted 13 lines · Max Gurtovoy
This event is handled by the RDMA core layer.
Signed-off-by Max Gurtovoy <[email protected]>--- drivers/infiniband/ulp/srpt/ib_srpt.c | 5 ----- 1 file changed, 5 deletions(-)drivers/infiniband/ulp/srpt/ib_srpt.c +0
-0@@ -231,11 +231,6 @@ static void srpt_qp_event(struct ib_event *event, void *ptr)else
drivers/infiniband/ulp/srpt/ib_srpt.c static void srpt_qp_event(struct ib_event *event, void *ptr) · line 236
Quoted 10 lines
drivers/infiniband/ulp/srpt/ib_srpt.c +0
-5ib_cm_notify (ch->ib_cm.cm_id, event->event);break ; -case IB_EVENT_QP_LAST_WQE_REACHED : -pr_debug ("%s-%d, state %s: received Last WQE event.\n" , - ch->sess_name, ch->qp->qp_num, -get_ch_state_name (ch->state)); -break ;default :pr_err ("received unrecognized IB QP event %d\n" , event->event);break ;
Sagi Grimberg
maintainerRe: [PATCH 1/6] IB/core: add support for draining Shared receive queues
In reply to Max GurtovoyQuoted 41 lines · Max Gurtovoy
To avoid leakage for QPs assocoated with SRQ, according to IB spec (section 10.3.1):
"Note, for QPs that are associated with an SRQ, the Consumer should take the QP through the Error State before invoking a Destroy QP or a Modify QP to the Reset State. The Consumer may invoke the Destroy QP without first performing a Modify QP to the Error State and waiting for the Affiliated Asynchronous Last WQE Reached Event. However, if the Consumer does not wait for the Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment leakage may occur. Therefore, it is good programming practice to teardown a QP that is associated with an SRQ by using the following process:
- Put the QP in the Error State;
- wait for the Affiliated Asynchronous Last WQE Reached Event;
- either:
- drain the CQ by invoking the Poll CQ verb and either wait for CQ to be empty or the number of Poll CQ operations has exceeded CQ capacity size; or
- post another WR that completes on the same CQ and wait for this WR to return as a WC;
- and then invoke a Destroy QP or Reset QP."Catch the Last WQE Reached Event in the core layer without involving the ULP drivers with extra logic during drain and destroy QP flows.
The "Last WQE Reached" event will only be send on the errant QP, for signaling that the SRQ flushed all the WQEs that have been dequeued from the SRQ for processing by the associated QP.
Signed-off-by Max Gurtovoy <[email protected]>--- drivers/infiniband/core/verbs.c | 83 ++++++++++++++++++++++++++++++++- include/rdma/ib_verbs.h | 2 + 2 files changed, 84 insertions(+), 1 deletion(-)drivers/infiniband/core/verbs.c +0
-0@@ -1101,6 +1101,16 @@ EXPORT_SYMBOL(ib_destroy_srq_user);
drivers/infiniband/core/verbs.c EXPORT_SYMBOL(ib_destroy_srq_user); · line 1111
Quoted 10 lines
drivers/infiniband/core/verbs.c +8
-0/* Queue pairs */ +static void __ib_qp_event_handler (struct ib_event *event,void *context) +{ +struct ib_qp *qp = event->element.qp; + +if (event->event ==IB_EVENT_QP_LAST_WQE_REACHED ) +complete (&qp->srq_completion); +else if (qp->registered_event_handler) + qp->registered_event_handler (event, qp->qp_context);
There is no reason what-so-ever to withhold the LAST_WQE_REACHED from the ulp. The ULP may be interested in consuming this event.
This should become:
+static void __ib_qp_event_handler(struct ib_event *event, void *context) +{
+ struct ib_qp *qp = event->element.qp;
+
+ if (event->event == IB_EVENT_QP_LAST_WQE_REACHED)
+ complete(&qp->srq_completion);
+ if (qp->registered_event_handler)
+ qp->registered_event_handler(event, qp->qp_context);
drivers/infiniband/core/verbs.c static struct ib_qp *create_qp(struct ib_device *dev, struct ib_pd *pd, · line 1235
Quoted 12 lines
drivers/infiniband/core/verbs.c +4
-1+} +static void __ib_shared_qp_event_handler (struct ib_event *event,void *context) {struct ib_qp *qp = context;@@ -1221,7 +1231,10 @@ static struct ib_qp *create_qp(struct ib_device *dev, struct ib_pd *pd, qp->qp_type = attr->qp_type; qp->rwq_ind_tbl = attr->rwq_ind_tbl; qp->srq = attr->srq; - qp->event_handler = attr->event_handler; +if (qp->srq) +init_completion (&qp->srq_completion);
I think that if you unconditionally complete, you should also unconditionally initialize.
Sagi Grimberg
maintainerRe: [PATCH 1/6] IB/core: add support for draining Shared receive queues
In reply to Bart Van AsscheQuoted 3 lines · Bart Van Assche
Quoted 2 lines · Max Gurtovoy
+ if (
wait_for_completion_timeout(&qp->srq_completion, 10 * HZ)>
0) {
I think this warrants a comment to why you stop after consuming cq->cqe completions (i.e. shared completions).
Quoted 9 lines
Quoted 7 lines
+ while (polled !=
cq->cqe) {
+ n =ib_process_cq_direct(cq, cq->cqe - polled); + if (!n)
+ return;
+ polled += n;
+ }
+ }Why a hardcoded timeout (10 * HZ) instead of waiting forever?
Agreed. Is there a scenario where the IB event is missed or something?
Sagi Grimberg
maintainerRe: [PATCH 2/6] IB/isert: remove the handling of last WQE reached event
In reply to Max GurtovoyQuoted 12 lines · Max Gurtovoy
This event is handled by the RDMA core layer.
Signed-off-by Max Gurtovoy <[email protected]>--- drivers/infiniband/ulp/isert/ib_isert.c | 3 --- 1 file changed, 3 deletions(-)drivers/infiniband/ulp/isert/ib_isert.c +0
-0
drivers/infiniband/ulp/isert/ib_isert.c isert_qp_event_callback(struct ib_event *e, void *context) · line 96
Quoted 6 lines
drivers/infiniband/ulp/isert/ib_isert.c +0
-3@@ -91,9 +91,6 @@ isert_qp_event_callback(struct ib_event *e, void *context)case IB_EVENT_COMM_EST :rdma_notify (isert_conn->cm_id,IB_EVENT_COMM_EST );break ; -case IB_EVENT_QP_LAST_WQE_REACHED : -isert_warn ("Reached TX IB_EVENT_QP_LAST_WQE_REACHED\n" ); -break ;
Don't think you need to touch the ulps, they want to log these events, so be it. Although, a warn is not appropriate at all here.
Sagi Grimberg
maintainerRe: [PATCH 6/6] RDMA/IPoIB: remove the handling of last WQE reached event
In reply to Max GurtovoyQuoted 1 line · Max Gurtovoy
This event is handled by the RDMA core layer.
I'm assuming that this patch is well tested?
Looks like a fairly involved change.
Leon Romanovsky
maintainerRe: [PATCH 6/6] RDMA/IPoIB: remove the handling of last WQE reached event
Quoted 6 lines · Sagi Grimberg
Quoted 1 line · Max Gurtovoy
This event is handled by the RDMA core layer.
I'm assuming that this patch is well tested?
Not yet.
Thanks
Quoted 2 lines
Looks like a fairly involved change.
Re: [PATCH 1/6] IB/core: add support for draining Shared receive queues
In reply to Sagi GrimbergQuoted 10 lines · Sagi Grimberg
Quoted 3 lines · Bart Van Assche
Quoted 2 lines · Max Gurtovoy
+ if (
wait_for_completion_timeout(&qp->srq_completion, 10 * HZ)>
0) {I think this warrants a comment to why you stop after consuming
cq->cqecompletions (i.e. shared completions).
There is a full explanation in the function documentation.
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
+ while (polled !=
cq->cqe) {
+ n =ib_process_cq_direct(cq, cq->cqe - polled); + if (!n)
+ return;
+ polled += n;
+ }
+ }Why a hardcoded timeout (10 * HZ) instead of waiting forever?
Agreed. Is there a scenario where the IB event is missed or something?
I can change it to (60 * HZ) instead.
I prefer not waiting forever and getting a stuck kernel if the underlying device is defected.
Re: [PATCH 1/6] IB/core: add support for draining Shared receive queues
In reply to Sagi GrimbergQuoted 60 lines · Sagi Grimberg
Quoted 40 lines · Max Gurtovoy
To avoid leakage for QPs assocoated with SRQ, according to IB spec (section 10.3.1):
"Note, for QPs that are associated with an SRQ, the Consumer should take the QP through the Error State before invoking a Destroy QP or a Modify QP to the Reset State. The Consumer may invoke the Destroy QP without first performing a Modify QP to the Error State and waiting for the Affiliated Asynchronous Last WQE Reached Event. However, if the Consumer does not wait for the Affiliated Asynchronous Last WQE Reached Event, then WQE and Data Segment leakage may occur. Therefore, it is good programming practice to teardown a QP that is associated with an SRQ by using the following process:
- Put the QP in the Error State;
- wait for the Affiliated Asynchronous Last WQE Reached Event;
- either:
- drain the CQ by invoking the Poll CQ verb and either wait for CQ to be empty or the number of Poll CQ operations has exceeded CQ capacity size; or
- post another WR that completes on the same CQ and wait for this WR to return as a WC;
- and then invoke a Destroy QP or Reset QP."Catch the Last WQE Reached Event in the core layer without involving the ULP drivers with extra logic during drain and destroy QP flows.
The "Last WQE Reached" event will only be send on the errant QP, for signaling that the SRQ flushed all the WQEs that have been dequeued from the SRQ for processing by the associated QP.
Signed-off-by Max Gurtovoy <[email protected]>---
drivers/infiniband/core/verbs.c| 83 ++++++++++++++++++++++++++++++++- include/rdma/ib_verbs.h | 2 +2 files changed, 84 insertions(+), 1 deletion(-)drivers/infiniband/core/verbs.c +0
-0drivers/infiniband/core/verbs.c EXPORT_SYMBOL(ib_destroy_srq_user); · line 1109
Quoted 9 lines
drivers/infiniband/core/verbs.c +7
-0@@ -1101,6 +1101,16 @@ EXPORT_SYMBOL(ib_destroy_srq_user); /* Queue pairs */ +static void __ib_qp_event_handler(struct ib_event *event, void *context) +{ + struct ib_qp *qp = event->element.qp; + + if (event->event == IB_EVENT_QP_LAST_WQE_REACHED) + complete(&qp->srq_completion); + else if (qp->registered_event_handler) + qp->registered_event_handler(event, qp->qp_context);There is no reason what-so-ever to withhold the
LAST_WQE_REACHEDfrom the ulp. The ULP may be interested in consuming this event.This should become:
drivers/infiniband/core/verbs.c EXPORT_SYMBOL(ib_destroy_srq_user); · line 1111
Quoted 8 lines
drivers/infiniband/core/verbs.c +8
-0+static void __ib_qp_event_handler (struct ib_event *event,void *context) +{ + struct ib_qp *qp = event->element.qp; + + if (event->event == IB_EVENT_QP_LAST_WQE_REACHED) + complete(&qp->srq_completion); + if (qp->registered_event_handler) + qp->registered_event_handler(event, qp->qp_context);
Good idea.
Thanks.
Quoted 17 lines
Quoted 8 lines
drivers/infiniband/core/verbs.c +2
-0+} + static void __ib_shared_qp_event_handler(struct ib_event *event, void *context) { struct ib_qp *qp = context;drivers/infiniband/core/verbs.c static struct ib_qp *create_qp(struct · line 1236
Quoted 7 lines
drivers/infiniband/core/verbs.c +2
-1@@ -1221,7 +1231,10 @@ static struct ib_qp *create_qp(struct ib_device *dev, struct ib_pd *pd, qp->qp_type = attr->qp_type; qp->rwq_ind_tbl = attr->rwq_ind_tbl; qp->srq = attr->srq; - qp->event_handler = attr->event_handler; + if (qp->srq) + init_completion(&qp->srq_completion);I think that if you unconditionally complete, you should also unconditionally initialize.
Non "SRQ" QP will not get "Last WQE reached" event. Unless device is defected.
Anyway, I'm ok with your suggestion. There is no hard in initializing it for Non "SRQ" QPs as well.
Re: [PATCH 2/6] IB/isert: remove the handling of last WQE reached event
In reply to Sagi GrimbergQuoted 10 lines · Sagi Grimberg
Quoted 7 lines · Max Gurtovoy
This event is handled by the RDMA core layer.
Signed-off-by Max Gurtovoy <[email protected]>---
drivers/infiniband/ulp/isert/ib_isert.c| 3 ---1 file changed, 3 deletions(-)
Quoted 15 lines
Quoted 6 lines
drivers/infiniband/ulp/isert/ib_isert.c +0
-0@@ -91,9 +91,6 @@ isert_qp_event_callback(struct ib_event *e, void *context)Quoted 6 lines
case
IB_EVENT_COMM_EST:
rdma_notify(isert_conn->cm_id, IB_EVENT_COMM_EST); break;
- caseIB_EVENT_QP_LAST_WQE_REACHED:
-isert_warn("Reached TX IB_EVENT_QP_LAST_WQE_REACHED\n"); - break;Don't think you need to touch the ulps, they want to log these events, so be it. Although, a warn is not appropriate at all here.
Ok. I'll remove the ULP patches, besides iSER target that is not even implement SRQ.
This is a dead code.
Quoted 7 lines · Max Gurtovoy
Hi Jason/Leon/Sagi,
This series adds a support for draining a QP that is associated with a SRQ (Shared Receive Queue).
Leakage problem can occur if we won't treat Last WQE Reached event.In the series, that is based on some old series I've send during 2018, I
The old series is as below. It had better to post the link.
https://www.spinics.net/lists/linux-rdma/msg59633.html
Zhu Yanjun
Quoted 26 lines
used a different approach and handled the event in the RDMA core, as was suggested in discussion in the mailing list.
I've updated RDMA ULPs. Most of them were trivial except IPoIB that was handling the Last WQE reached in the ULP.
I've tested this series with NVMf/RDMA on RoCE.
Max Gurtovoy (6):
IB/core: add support for draining Shared receive queues IB/isert: remove the handling of last WQE reached event RDMA/srpt: remove the handling of last WQE reached event
nvmet-rdma: remove the handling of last WQE reached event
svcrdma: remove the handling of last WQE reached event RDMA/IPoIB: remove the handling of last WQE reached eventdrivers/infiniband/core/verbs.c | 83 +++++++++++++++++++++++- drivers/infiniband/ulp/ipoib/ipoib.h | 33 +--------- drivers/infiniband/ulp/ipoib/ipoib_cm.c | 71 ++------------------ drivers/infiniband/ulp/isert/ib_isert.c | 3 - drivers/infiniband/ulp/srpt/ib_srpt.c | 5 -- drivers/nvme/target/rdma.c | 4 -- include/rdma/ib_verbs.h | 2 + net/sunrpc/xprtrdma/svc_rdma_transport.c | 1 - 8 files changed, 92 insertions(+), 110 deletions(-)