] RDMA/siw: Fix SQ/RQ drain logic
Subsystems (2)
PATCH v2 1/1 ] RDMA/siw: Fix SQ/RQ drain logic
Storage ULPs (e.g. iSER & NVMeOF) use ib_drain_qp() to drain QP/CQ. Current SIW's own drain routines do not properly wait until all SQ/RQ elements are completed and reaped from the CQ. This may cause touch after free issues. New logic relies on generic __ib_drain_sq()/__ib_drain_rq() posting a final work request, which SIW immediately flushes to CQ.
---
v1 -> v2:
- Accept SQ and RQ work requests, if QP is in ERROR state. In that case, immediately flush WR's to CQ. This already provides needed functionality to support ib_drain_sq()/ib_drain_rq() without extra state checking in the fast path.
drivers/infiniband/sw/siw/siw_main.c | 20 ----- drivers/infiniband/sw/siw/siw_verbs.c | 103 +++++++++++++++++++++----- 2 files changed, 86 insertions(+), 37 deletions(-)
drivers/infiniband/sw/siw/siw_main.c +0 -20
@@ -248,24 +248,6 @@ static struct ib_qp *siw_get_base_qp(struct ib_device *base_dev, int id)return NULL ; } -static void siw_verbs_sq_flush (struct ib_qp *base_qp) -{ -struct siw_qp *qp =to_siw_qp (base_qp); - -down_write (&qp->state_lock); -siw_sq_flush (qp); -up_write (&qp->state_lock); -} - -static void siw_verbs_rq_flush (struct ib_qp *base_qp) -{ -struct siw_qp *qp =to_siw_qp (base_qp); - -down_write (&qp->state_lock); -siw_rq_flush (qp); -up_write (&qp->state_lock); -} -static const struct ib_device_ops siw_device_ops = { .owner =THIS_MODULE , .uverbs_abi_ver =SIW_ABI_VERSION ,
@@ -284,8 +266,6 @@ static const struct ib_device_ops siw_device_ops = { .destroy_cq = siw_destroy_cq, .destroy_qp = siw_destroy_qp, .destroy_srq = siw_destroy_srq, - .drain_rq = siw_verbs_rq_flush, - .drain_sq = siw_verbs_sq_flush, .get_dma_mr = siw_get_dma_mr, .get_port_immutable = siw_get_port_immutable, .iw_accept = siw_accept,
drivers/infiniband/sw/siw/siw_verbs.c +86 -17
136 lines not on this page · raw message
Signature · 1 line
2.17.2
Quoted 114 lines · Bernard Metzler
Storage ULPs (e.g. iSER & NVMeOF) use
ib_drain_qp()to drain QP/CQ. Current SIW's own drain routines do not properly wait until all SQ/RQ elements are completed and reaped from the CQ. This may cause touch after free issues. New logic relies on generic __ib_drain_sq()/__ib_drain_rq() posting a final work request, which SIW immediately flushes to CQ.Fixes 303ae1cdfdf7 ("rdma/siw: application interface")Signed-off-by Krishnamraju Eraparaju <[email protected]>Signed-off-by Bernard Metzler <[email protected]>---
v1 -> v2:
- Accept SQ and RQ work requests, if QP is in ERROR state. In that case, immediately flush WR's to CQ. This already provides needed functionality to support ib_drain_sq()/ib_drain_rq() without extra state checking in the fast path.drivers/infiniband/sw/siw/siw_main.c | 20 ----- drivers/infiniband/sw/siw/siw_verbs.c | 103 +++++++++++++++++++++----- 2 files changed, 86 insertions(+), 37 deletions(-)drivers/infiniband/sw/siw/siw_main.c +0
-20@@ -248,24 +248,6 @@ static struct ib_qp *siw_get_base_qp(struct ib_device *base_dev, int id)return NULL ; } -static void siw_verbs_sq_flush (struct ib_qp *base_qp) -{ -struct siw_qp *qp =to_siw_qp (base_qp); - -down_write (&qp->state_lock); -siw_sq_flush (qp); -up_write (&qp->state_lock); -} - -static void siw_verbs_rq_flush (struct ib_qp *base_qp) -{ -struct siw_qp *qp =to_siw_qp (base_qp); - -down_write (&qp->state_lock); -siw_rq_flush (qp); -up_write (&qp->state_lock); -} -static const struct ib_device_ops siw_device_ops = { .owner =THIS_MODULE , .uverbs_abi_ver =SIW_ABI_VERSION ,@@ -284,8 +266,6 @@ static const struct ib_device_ops siw_device_ops = { .destroy_cq = siw_destroy_cq, .destroy_qp = siw_destroy_qp, .destroy_srq = siw_destroy_srq, - .drain_rq = siw_verbs_rq_flush, - .drain_sq = siw_verbs_sq_flush, .get_dma_mr = siw_get_dma_mr, .get_port_immutable = siw_get_port_immutable, .iw_accept = siw_accept,drivers/infiniband/sw/siw/siw_verbs.c +41
-0@@ -687,6 +687,47 @@ static int siw_copy_inline_sgl(const struct ib_send_wr *core_wr,return bytes; } +/* Complete SQ WR's without processing */ +static int siw_sq_flush_wr (struct siw_qp *qp,const struct ib_send_wr *wr, +const struct ib_send_wr **bad_wr) +{ +struct siw_sqe sqe = {}; +int rv =0 ; + +while (wr) { + sqe.id = wr->wr_id; + sqe.opcode = wr->opcode; + rv =siw_sqe_complete (qp, &sqe,0 ,SIW_WC_WR_FLUSH_ERR ); +if (rv) { +if (bad_wr) + *bad_wr = wr; +break ; + } + wr = wr->next; + } +return rv; +} + +/* Complete RQ WR's without processing */ +static int siw_rq_flush_wr (struct siw_qp *qp,const struct ib_recv_wr *wr, +const struct ib_recv_wr **bad_wr) +{ +struct siw_rqe rqe = {}; +int rv =0 ; + +while (wr) { + rqe.id = wr->wr_id; + rv =siw_rqe_complete (qp, &rqe,0 ,0 ,SIW_WC_WR_FLUSH_ERR ); +if (rv) { +if (bad_wr) + *bad_wr = wr; +break ; + } + wr = wr->next; + } +return rv; +} +/* * siw_post_send() *
drivers/infiniband/sw/siw/siw_verbs.c int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, · line 749
Quoted 4 lines
drivers/infiniband/sw/siw/siw_verbs.c +1
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,unsigned long flags;int rv =0 ; +if (wr && !qp->kernel_verbs) {
It is not related to this specific patch, but all siw "kernel_verbs" should go, we have standard way to distinguish between kernel and user verbs.
Thanks
-----"Leon Romanovsky" <[email protected]> wrote: ----- <...>
Quoted 6 lines
Review int siw_post_send(struct ib_qp *base_qp, const
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp, conststruct
ib_send_wr*wr,Quoted 3 lines
drivers/infiniband/sw/siw/siw_verbs.c +0
-0unsigned long flags;int rv =0 ;
Quoted 9 lines
drivers/infiniband/sw/siw/siw_verbs.c int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, · line 749
Quoted 1 line
drivers/infiniband/sw/siw/siw_verbs.c +1
-0+if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw "
kernel_verbs" should go, we have standard way to distinguish between kernel and user
verbs.Thanks
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that. Let me see if I can compact QP objects to contain the ib_qp. I'd like to avoid following pointers potentially causing cache misses on the fast path. This is why I still have that little boolean within the siw private structure.
Thanks and best regards,
Bernard.
Quoted 15 lines · Bernard Metzler
<...>
Quoted 13 lines
Review int siw_post_send(struct ib_qp *base_qp, const
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp, conststruct
ib_send_wr*wr,drivers/infiniband/sw/siw/siw_verbs.c int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, · line 749
Quoted 4 lines
drivers/infiniband/sw/siw/siw_verbs.c +1
-0unsigned long flags;int rv =0 ; +if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw "
kernel_verbs" should go, we have standard way to distinguish between kernel and user
verbs.
Quoted 6 lines
Quoted 2 lines
Thanks
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that.
No, the uobject pointer is not to be touched by drivers
Jason
-----"Jason Gunthorpe" <[email protected]> wrote: -----
Quoted 27 lines
To: "Bernard Metzler" <[email protected]>
From: "Jason Gunthorpe" <[email protected]>
Date: 10/04/2019 07:48PM
Cc: "Leon Romanovsky" <[email protected]>, [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: [[PATCH v2 for-next]] RDMA/siw: Fix SQ/RQ drain logicQuoted 4 lines · Bernard Metzler
<...>
Quoted 2 lines
Review int siw_post_send(struct ib_qp *base_qp,
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp,const
Quoted 7 lines
Quoted 7 lines
struct
ib_send_wr*wr,drivers/infiniband/sw/siw/siw_verbs.c int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, · line 749
Quoted 4 lines
drivers/infiniband/sw/siw/siw_verbs.c +1
-0unsigned long flags;int rv =0 ; +if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw
"
kernel_verbs"Quoted 4 lines
Quoted 4 lines
should go, we have standard way to distinguish between kernel and user
verbs.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Thanks
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that.
No, the uobject pointer is not to be touched by drivers
Now what would be the appropriate way of remembering/ detecting user level nature of endpoint resources? I see drivers _are_ doing 'if (!ibqp->uobject)' ...
Other drivers keep it with the private state, like iw40, but I learned we shall get rid of it.
We may export an inline query from RDMA core, or simply #define is_usermode(ib_obj *) (ib_obj->uobject != NULL) ?
Thanks and best regards,
Bernard
Quoted 36 lines · Bernard Metzler
-----"Jason Gunthorpe" <[email protected]> wrote: -----
Quoted 34 lines
To: "Bernard Metzler" <[email protected]>
From: "Jason Gunthorpe" <[email protected]>
Date: 10/04/2019 07:48PM
Cc: "Leon Romanovsky" <[email protected]>, [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: [[PATCH v2 for-next]] RDMA/siw: Fix SQ/RQ drain logicQuoted 4 lines · Bernard Metzler
<...>
Quoted 2 lines
Review int siw_post_send(struct ib_qp *base_qp,
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp,const
Quoted 7 lines
Quoted 7 lines
struct
ib_send_wr*wr,drivers/infiniband/sw/siw/siw_verbs.c int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, · line 749
Quoted 4 lines
drivers/infiniband/sw/siw/siw_verbs.c +1
-0unsigned long flags;int rv =0 ; +if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw
"
kernel_verbs"Quoted 10 lines
Quoted 6 lines
should go, we have standard way to distinguish between kernel and user
verbs.Thanks
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that.
Quoted 5 lines
Quoted 2 lines
No, the uobject pointer is not to be touched by drivers
Now what would be the appropriate way of remembering/ detecting user level nature of endpoint resources? I see drivers _are_ doing 'if (!ibqp->uobject)' ...
IMHO, you should rely in "udata" to distinguish user/kernel objects.
Quoted 11 lines
Other drivers keep it with the private state, like iw40, but I learned we shall get rid of it.
We may export an inline query from RDMA core, or simply #define
is_usermode(ib_obj *)(ib_obj->uobject!= NULL) ?Thanks and best regards,
Bernard
-----"Leon Romanovsky" <[email protected]> wrote: -----
Quoted 49 lines
To: "Bernard Metzler" <[email protected]>
From: "Leon Romanovsky" <[email protected]>
Date: 10/27/2019 06:21AM
Cc: "Jason Gunthorpe" <[email protected]>, [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: Re: [[PATCH v2 for-next]] RDMA/siw: Fix SQ/RQ drain logicQuoted 6 lines · Bernard Metzler
-----"Jason Gunthorpe" <[email protected]> wrote: -----
Quoted 4 lines
To: "Bernard Metzler" <[email protected]>
From: "Jason Gunthorpe" <[email protected]>
Date: 10/04/2019 07:48PM
Cc: "Leon Romanovsky" <[email protected]>,Quoted 3 lines
Quoted 3 lines
[email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: [[PATCH v2 for-next]] RDMA/siw: FixSQ/RQ
Quoted 9 lines
Quoted 9 lines
drain logic
Quoted 4 lines · Bernard Metzler
<...>
Quoted 2 lines
Review int siw_post_send(struct ib_qp *base_qp,
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp,const
Quoted 1 line
Quoted 1 line
struct
ib_send_wr*wr,Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
drivers/infiniband/sw/siw/siw_verbs.c int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, · line 749
Quoted 4 lines
drivers/infiniband/sw/siw/siw_verbs.c +1
-0unsigned long flags;int rv =0 ; +if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw
"
kernel_verbs"Quoted 1 line
Quoted 1 line
should go, we have standard way to distinguish between kernel
and
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
user
verbs.Thanks
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
No, the uobject pointer is not to be touched by drivers
Now what would be the appropriate way of remembering/ detecting user level nature of endpoint resources? I see drivers _are_ doing 'if (!ibqp->uobject)' ...
IMHO, you should rely in "udata" to distinguish user/kernel objects.
right, we already do that at resource creation time, when 'udata' is available. But there is no such parameter around during resource access (post_send/post_recv/poll_cq/...), when user land or kernel land application specific code might be required.
That's why siw currently saves that info to a resource (QP/CQ/SRQ) specific parameter 'kernel_verbs'. I agree this parameter is redundant, if the rdma core object provides that information as well. The only way I see it provided is the validity of the uobject pointer of all those resources.
Either (1) we use that uobject pointer as an indication of application location, or (2) we remember it from resource creation time when udata was available, or
(3) we have the rdma core exporting that information explicitly.
siw, and other drivers, are currently implementing (2). Some drivers implement (1). I'd be happy to change siw to implement (1) - to get rid of 'kernel_verbs'.
Thanks and best regards,
Bernard.
Quoted 13 lines
Quoted 11 lines
Other drivers keep it with the private state, like iw40, but I learned we shall get rid of it.
We may export an inline query from RDMA core, or simply #define
is_usermode(ib_obj *)(ib_obj->uobject!= NULL) ?Thanks and best regards,
Bernard
Quoted 6 lines · Bernard Metzler
That's why siw currently saves that info to a resource (QP/CQ/SRQ) specific parameter '
kernel_verbs'. I agree this parameter is redundant, if the rdma core object provides that information as well. The only way I see it provided is the validity of the uobject pointer of all those resources.
The restrack stuff also keeps track of user/kernel on created objects
Jason
Quoted 71 lines · Bernard Metzler
-----"Leon Romanovsky" <[email protected]> wrote: -----
Quoted 49 lines
To: "Bernard Metzler" <[email protected]>
From: "Leon Romanovsky" <[email protected]>
Date: 10/27/2019 06:21AM
Cc: "Jason Gunthorpe" <[email protected]>, [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: Re: [[PATCH v2 for-next]] RDMA/siw: Fix SQ/RQ drain logicQuoted 6 lines · Bernard Metzler
-----"Jason Gunthorpe" <[email protected]> wrote: -----
Quoted 4 lines
To: "Bernard Metzler" <[email protected]>
From: "Jason Gunthorpe" <[email protected]>
Date: 10/04/2019 07:48PM
Cc: "Leon Romanovsky" <[email protected]>,Quoted 3 lines
Quoted 3 lines
[email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: [[PATCH v2 for-next]] RDMA/siw: FixSQ/RQ
Quoted 9 lines
Quoted 9 lines
drain logic
Quoted 4 lines · Bernard Metzler
<...>
Quoted 2 lines
Review int siw_post_send(struct ib_qp *base_qp,
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp,const
Quoted 1 line
Quoted 1 line
struct
ib_send_wr*wr,Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Review int siw_post_send(struct ib_qp *base_qp, · line 749
Quoted 4 lines
(quoted diff) +1
-0unsigned long flags; int rv = 0; + if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw
"
kernel_verbs"Quoted 1 line
Quoted 1 line
should go, we have standard way to distinguish between kernel
and
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
user
verbs.Thanks
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
No, the uobject pointer is not to be touched by drivers
Now what would be the appropriate way of remembering/ detecting user level nature of endpoint resources? I see drivers _are_ doing 'if (!ibqp->uobject)' ...
IMHO, you should rely in "udata" to distinguish user/kernel objects.
right, we already do that at resource creation time, when 'udata' is available. But there is no such parameter around during resource access (post_send/post_recv/poll_cq/...), when user land or kernel land application specific code might be required.
That's why siw currently saves that info to a resource (QP/CQ/SRQ) specific parameter 'kernel_verbs'. I agree this parameter is redundant, if the rdma core object provides that information as well. The only way I see it provided is the validity of the uobject pointer of all those resources.
Quoted 8 lines
Either (1) we use that uobject pointer as an indication of application location, or (2) we remember it from resource creation time when udata was available, or
(3) we have the rdma core exporting that information explicitly.
siw, and other drivers, are currently implementing (2). Some drivers implement (1). I'd be happy to change siw to implement (1) - to get rid of 'kernel_verbs'.
Many if not all "kernel_verbs" variables are copy/paste. The usual way to handle difference in internal flows is to rely on having pointer initialized, e.g.
if (siw_device->some_specific_kernel_pointer)
do_kernelwork(siw_device->some_specific_kernel_pointer->extra)
Thanks
Quoted 21 lines
Thanks and best regards,
Bernard.Quoted 13 lines
Quoted 11 lines
Other drivers keep it with the private state, like iw40, but I learned we shall get rid of it.
We may export an inline query from RDMA core, or simply #define
is_usermode(ib_obj *)(ib_obj->uobject!= NULL) ?Thanks and best regards,
Bernard
-----"Leon Romanovsky" <[email protected]> wrote: -----
Quoted 96 lines
To: "Bernard Metzler" <[email protected]>
From: "Leon Romanovsky" <[email protected]>
Date: 10/29/2019 05:55AM
Cc: "Jason Gunthorpe" <[email protected]>, [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: Re: Re: [[PATCH v2 for-next]] RDMA/siw:
Fix SQ/RQ drain logicQuoted 9 lines · Bernard Metzler
-----"Leon Romanovsky" <[email protected]> wrote: -----
Quoted 7 lines
To: "Bernard Metzler" <[email protected]>
From: "Leon Romanovsky" <[email protected]>
Date: 10/27/2019 06:21AM
Cc: "Jason Gunthorpe" <[email protected]>, [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: Re: [[PATCH v2 for-next]] RDMA/siw:Fix
Quoted 11 lines
Quoted 11 lines
SQ/RQ drain logic
Quoted 6 lines · Bernard Metzler
-----"Jason Gunthorpe" <[email protected]> wrote: -----
Quoted 4 lines
To: "Bernard Metzler" <[email protected]>
From: "Jason Gunthorpe" <[email protected]>
Date: 10/04/2019 07:48PM
Cc: "Leon Romanovsky" <[email protected]>,Quoted 1 line
Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
[email protected]
Subject: [EXTERNAL] Re: Re: [[PATCH v2 for-next]] RDMA/siw: FixSQ/RQ
Quoted 3 lines
Quoted 3 lines
drain logic
On Fri, Oct 04, 2019 at 02:09:57PM +0000, Bernard Metzler
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<...>
Quoted 2 lines
Review int siw_post_send(struct ib_qp
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp
*base_qp,Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
const
Quoted 7 lines
Quoted 7 lines
struct
ib_send_wr*wr,Review int siw_post_send(struct ib_qp · line 749
Quoted 4 lines
(quoted diff) +1
-0unsigned long flags; int rv = 0; + if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw
"
kernel_verbs"Quoted 1 line
Quoted 1 line
should go, we have standard way to distinguish between
kernel
Quoted 11 lines
Quoted 11 lines
and
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
user
verbs.Thanks
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that.
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
No, the uobject pointer is not to be touched by drivers
Now what would be the appropriate way of remembering/ detecting user level nature of endpoint resources? I see drivers _are_ doing 'if (!ibqp->uobject)' ...
IMHO, you should rely in "udata" to distinguish user/kernel
objects.
Quoted 13 lines
Quoted 1 line
right, we already do that at resource creation time, when 'udata' is available. But there is no such parameter around during resource access (post_send/post_recv/poll_cq/...), when user land or kernel land application specific code might be required.
That's why siw currently saves that info to a resource (QP/CQ/SRQ) specific parameter 'kernel_verbs'. I agree this parameter is redundant, if the rdma core object provides that information as well. The only way I see it provided is the validity of the uobject pointer of all those resources.Quoted 8 lines
Either (1) we use that uobject pointer as an indication of application location, or (2) we remember it from resource creation time when udata was available, or
(3) we have the rdma core exporting that information explicitly.
siw, and other drivers, are currently implementing (2). Some drivers implement (1). I'd be happy to change siw to implement (1) - to get rid of 'kernel_verbs'.
Quoted 6 lines
Many if not all "
kernel_verbs" variables are copy/paste. The usual way to handle difference in internal flows is to rely on having pointer initialized, e.g.
if (siw_device->some_specific_kernel_pointer)do_kernelwork(siw_device->some_specific_kernel_pointer->extra)
The conditional code is always rather short:
- a few lines for extra checks during post_sq, post_rq and post_srq to forbid writing queue entries via syscall.
- write the qp kernel pointer to a CQE only if it is a kernel application. Don't expose it to user land.
IMO, these checks do not qualify for a change to a function indirection, which would establish two very similar functions, differing only in very few lines. It would also decrease readability. The function pointer would have to be part of the resource itself (QP/SRQ/CQ), as the flag is now.
Let me limit the usage of this obviously unliked flag to its possible minimum. During resource construction/destruction I do not really need it (except setting it), since 'udata' is there. It would appear only in the fast path for meentioned checks.
I still prefer that siw private flag to avoid to rely on potentially changing semantics of rdma core private structures the driver IMHO better should not interpret. But I am completely open to do it that way, if preferred by the maintainers.
Thanks and best regards,
Bernard.
Quoted 25 lines
Thanks
Quoted 21 lines
Thanks and best regards,
Bernard.Quoted 13 lines
Quoted 11 lines
Other drivers keep it with the private state, like iw40, but I learned we shall get rid of it.
We may export an inline query from RDMA core, or simply #define
is_usermode(ib_obj *)(ib_obj->uobject!= NULL) ?Thanks and best regards,
Bernard
Quoted 18 lines · Bernard Metzler
-----"Leon Romanovsky" <[email protected]> wrote: ----- <...>
Quoted 6 lines
Review int siw_post_send(struct ib_qp *base_qp, const
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp, conststruct
ib_send_wr*wr,Quoted 3 lines
drivers/infiniband/sw/siw/siw_verbs.c +0
-0unsigned long flags;int rv =0 ;Quoted 9 lines
drivers/infiniband/sw/siw/siw_verbs.c int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, · line 749
Quoted 1 line
drivers/infiniband/sw/siw/siw_verbs.c +1
-0+if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw "
kernel_verbs" should go, we have standard way to distinguish between kernel and user
verbs.Thanks
Quoted 10 lines
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that. Let me see if I can compact QP objects to contain the
ib_qp. I'd like to avoid following pointers potentially causing cache misses on the fast path. This is why I still have that little boolean within the siw private structure.
You have this variable in CQ and SRQ too.
I have serious doubts that this value gives any performance advantages. In both flows, you will need to fetch ib_qp pointer, so you don't save here anything by looking on kernel_verbs value.
Thanks
Quoted 4 lines
Thanks and best regards,
Bernard.
-----"Leon Romanovsky" <[email protected]> wrote: -----
Quoted 40 lines
To: "Bernard Metzler" <[email protected]>
From: "Leon Romanovsky" <[email protected]>
Date: 10/05/2019 10:26AM
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: [[PATCH v2 for-next]] RDMA/siw: Fix SQ/RQ drain logicQuoted 5 lines · Bernard Metzler
-----"Leon Romanovsky" <[email protected]> wrote: ----- <...>
Quoted 2 lines
Review int siw_post_send(struct ib_qp *base_qp,
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp,const
Quoted 7 lines
Quoted 7 lines
struct
ib_send_wr*wr,drivers/infiniband/sw/siw/siw_verbs.c int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, · line 749
Quoted 4 lines
drivers/infiniband/sw/siw/siw_verbs.c +1
-0unsigned long flags;int rv =0 ; +if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw
"
kernel_verbs"Quoted 6 lines
Quoted 6 lines
should go, we have standard way to distinguish between kernel and user
verbs.Thanks
Quoted 10 lines
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that. Let me see if I can compact QP objects to contain the
ib_qp. I'd like to avoid following pointers potentially causing cache misses on the fast path. This is why I still have that little boolean within the siw private structure.
Quoted 8 lines
You have this variable in CQ and SRQ too.
I have serious doubts that this value gives any performance advantages.
In both flows, you will need to fetchib_qppointer, so you don't save
here anything by looking onkernel_verbsvalue.
Yes, I see you are right for both CQ and SRQ.
For the CQ, we have a nested structure where siw_cq contains ib_cq. So it is not far away.
For SRQ it is the same.
For QP's we have a split between siw_qp and ib_qp. I will look into how to get that one solved.
I will prepare an extra patch for that whole kernel_verbs thing, but let's not have it gating acceptance of this unrelated patch.
Thanks very much,
Bernard.
Quoted 56 lines · Bernard Metzler
-----"Leon Romanovsky" <[email protected]> wrote: -----
Quoted 40 lines
To: "Bernard Metzler" <[email protected]>
From: "Leon Romanovsky" <[email protected]>
Date: 10/05/2019 10:26AM
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: Re: [[PATCH v2 for-next]] RDMA/siw: Fix SQ/RQ drain logicQuoted 5 lines · Bernard Metzler
-----"Leon Romanovsky" <[email protected]> wrote: ----- <...>
Quoted 2 lines
Review int siw_post_send(struct ib_qp *base_qp,
Quoted 2 lines
*
(quoted diff) +0
-0@@ -705,6 +746,12 @@ int siw_post_send(struct ib_qp *base_qp,const
Quoted 7 lines
Quoted 7 lines
struct
ib_send_wr*wr,drivers/infiniband/sw/siw/siw_verbs.c int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, · line 749
Quoted 4 lines
drivers/infiniband/sw/siw/siw_verbs.c +1
-0unsigned long flags;int rv =0 ; +if (wr && !qp->kernel_verbs) {It is not related to this specific patch, but all siw
"
kernel_verbs"Quoted 6 lines
Quoted 6 lines
should go, we have standard way to distinguish between kernel and user
verbs.Thanks
Quoted 10 lines
Understood. I think we touched on that already. rdma core objects have a uobject pointer which is valid only if it belongs to a user land application. We might better use that. Let me see if I can compact QP objects to contain the
ib_qp. I'd like to avoid following pointers potentially causing cache misses on the fast path. This is why I still have that little boolean within the siw private structure.Quoted 8 lines
You have this variable in CQ and SRQ too.
I have serious doubts that this value gives any performance advantages.
In both flows, you will need to fetchib_qppointer, so you don't save
here anything by looking onkernel_verbsvalue.Yes, I see you are right for both CQ and SRQ.
For the CQ, we have a nested structure where
siw_cqcontainsib_cq. So it is not far away.
Quoted 8 lines
For SRQ it is the same.
For QP's we have a split between
siw_qpandib_qp. I will look into how to get that one solved.I will prepare an extra patch for that whole
kernel_verbsthing, but let's not have it gating acceptance of this unrelated patch.
Sure, it is unrelated.
Quoted 4 lines
Thanks very much,
Bernard.