Current XRC queue
cover Current XRC queue
Hi everyone,
I finally found time to finish going over the base XRC patches. I fixed the "userspace can destroy an XRCD handle while still having QPs/SRQs referring to it" problem with a reference count, rather than the more complicated method used by the original patches.
I think the next step would be for someone (probably not me if we want this to happen soon) to port the rest of the mlx4 XRC patch set on top of this, ideally trying to factor out any reference-counting-ish code away from the device-specific driver and into common code. Then we should finally be able to merge this and move on to the IBoE changes.
Thanks,
Roland
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1264446094-4460-1-git-send-email-rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org
PATCH 1/4 IB/core: XRC base implementation
From: Jack Morgenstein <[email protected]>
Add the core implementation for XRC ("eXtended reliable connected") transport. XRC provides better scalability by allowing senders to specify which shared receive queue (SRQ) should be used to receive a message, which essentially allows one transport context (QP connection) to serve multiple destinations (as long as they shared an adapter, of course).
A few new concepts are introduced to support this:
- A new device capability flag, IB_DEVICE_XRC, which low-level drivers set to indicate that a device supports XRC.
- A new object type: XRC domains (struct ib_xrcd), and new verbs ib_alloc_xrcd()/ib_dealloc_xrcd(). XRCDs are used to limit which XRC SRQs an incoming message can target.
- A new QP type, IB_QPT_XRC, which is used to create QPs that use the XRC transport. Creating XRC QPs requires an XRCD to be specified.
- A new verb, ib_create_xrc_srq(), which is used to create XRC SRQs. XRC SRQs have an associated SRQ number (SRQN), which is included in incoming messages to target the message to a given SRQ.
--- drivers/infiniband/core/verbs.c | 138 +++++++++++++++++++++++++++++++++++++-- include/rdma/ib_verbs.h | 60 ++++++++++++++++- 2 files changed, 190 insertions(+), 8 deletions(-)
drivers/infiniband/core/verbs.c +132 -6
@@ -234,6 +234,8 @@ struct ib_srq *ib_create_srq(struct ib_pd *pd, srq->uobject =NULL ; srq->event_handler = srq_init_attr->event_handler; srq->srq_context = srq_init_attr->srq_context; + srq->xrc_cq =NULL ; + srq->xrcd =NULL ;atomic_inc (&pd->usecnt);atomic_set (&srq->usecnt,0 ); }
@@ -242,6 +244,36 @@ struct ib_srq *ib_create_srq(struct ib_pd *pd, }EXPORT_SYMBOL (ib_create_srq); +struct ib_srq *ib_create_xrc_srq (struct ib_pd *pd, +struct ib_cq *xrc_cq, +struct ib_xrcd *xrcd, +struct ib_srq_init_attr *srq_init_attr) +{ +struct ib_srq *srq; + +if (!pd->device->create_xrc_srq) +return ERR_PTR (-ENOSYS ); + + srq = pd->device->create_xrc_srq (pd, xrc_cq, xrcd, srq_init_attr,NULL ); + +if (!IS_ERR (srq)) { + srq->device = pd->device; + srq->pd = pd; + srq->uobject =NULL ; + srq->event_handler = srq_init_attr->event_handler; + srq->srq_context = srq_init_attr->srq_context; + srq->xrc_cq = xrc_cq; + srq->xrcd = xrcd; +atomic_inc (&pd->usecnt); +atomic_inc (&xrcd->usecnt); +atomic_inc (&xrc_cq->usecnt); +atomic_set (&srq->usecnt,0 ); + } + +return srq; +} +EXPORT_SYMBOL (ib_create_xrc_srq); +int ib_modify_srq (struct ib_srq *srq,struct ib_srq_attr *srq_attr,enum ib_srq_attr_mask srq_attr_mask)
@@ -263,16 +295,25 @@ EXPORT_SYMBOL(ib_query_srq);int ib_destroy_srq (struct ib_srq *srq) {struct ib_pd *pd; +struct ib_cq *xrc_cq; +struct ib_xrcd *xrcd;int ret;if (atomic_read (&srq->usecnt))return -EBUSY ; - pd = srq->pd; + pd = srq->pd; + xrc_cq = srq->xrc_cq; + xrcd = srq->xrcd; ret = srq->device->destroy_srq (srq); -if (!ret) +if (!ret) {atomic_dec (&pd->usecnt); +if (xrc_cq) +atomic_dec (&xrc_cq->usecnt); +if (xrcd) +atomic_dec (&xrcd->usecnt); + }return ret; }
@@ -297,11 +338,17 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd, qp->event_handler = qp_init_attr->event_handler; qp->qp_context = qp_init_attr->qp_context; qp->qp_type = qp_init_attr->qp_type; +if (qp->qp_type ==IB_QPT_XRC ) + qp->xrcd = qp_init_attr->xrcd; +else + qp->xrcd =NULL ;atomic_inc (&pd->usecnt);atomic_inc (&qp_init_attr->send_cq->usecnt);atomic_inc (&qp_init_attr->recv_cq->usecnt);if (qp_init_attr->srq)atomic_inc (&qp_init_attr->srq->usecnt); +if (qp->xrcd) +atomic_inc (&qp->xrcd->usecnt); }return qp;
@@ -327,6 +374,9 @@ static const struct { [IB_QPT_RC] = (IB_QP_PKEY_INDEX |IB_QP_PORT | IB_QP_ACCESS_FLAGS), + [IB_QPT_XRC ] = (IB_QP_PKEY_INDEX | +IB_QP_PORT | + IB_QP_ACCESS_FLAGS), [IB_QPT_SMI ] = (IB_QP_PKEY_INDEX | IB_QP_QKEY), [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
@@ -349,6 +399,9 @@ static const struct { [IB_QPT_RC] = (IB_QP_PKEY_INDEX |IB_QP_PORT | IB_QP_ACCESS_FLAGS), + [IB_QPT_XRC ] = (IB_QP_PKEY_INDEX | +IB_QP_PORT | + IB_QP_ACCESS_FLAGS), [IB_QPT_SMI ] = (IB_QP_PKEY_INDEX | IB_QP_QKEY), [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
@@ -368,6 +421,12 @@ static const struct {IB_QP_RQ_PSN |IB_QP_MAX_DEST_RD_ATOMIC | IB_QP_MIN_RNR_TIMER), + [IB_QPT_XRC ] = (IB_QP_AV | +IB_QP_PATH_MTU | +IB_QP_DEST_QPN | +IB_QP_RQ_PSN | +IB_QP_MAX_DEST_RD_ATOMIC | + IB_QP_MIN_RNR_TIMER), }, .opt_param = { [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
@@ -378,6 +437,9 @@ static const struct { [IB_QPT_RC] = (IB_QP_ALT_PATH |IB_QP_ACCESS_FLAGS | IB_QP_PKEY_INDEX), + [IB_QPT_XRC ] = (IB_QP_ALT_PATH | +IB_QP_ACCESS_FLAGS | + IB_QP_PKEY_INDEX), [IB_QPT_SMI ] = (IB_QP_PKEY_INDEX | IB_QP_QKEY), [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
@@ -398,6 +460,11 @@ static const struct {IB_QP_RNR_RETRY |IB_QP_SQ_PSN | IB_QP_MAX_QP_RD_ATOMIC), + [IB_QPT_XRC ] = (IB_QP_TIMEOUT | +IB_QP_RETRY_CNT | +IB_QP_RNR_RETRY | +IB_QP_SQ_PSN | + IB_QP_MAX_QP_RD_ATOMIC), [IB_QPT_SMI] = IB_QP_SQ_PSN, [IB_QPT_GSI] = IB_QP_SQ_PSN, },
@@ -413,6 +480,11 @@ static const struct {IB_QP_ACCESS_FLAGS |IB_QP_MIN_RNR_TIMER | IB_QP_PATH_MIG_STATE), + [IB_QPT_XRC ] = (IB_QP_CUR_STATE | +IB_QP_ALT_PATH | +IB_QP_ACCESS_FLAGS | +IB_QP_MIN_RNR_TIMER | + IB_QP_PATH_MIG_STATE), [IB_QPT_SMI ] = (IB_QP_CUR_STATE | IB_QP_QKEY), [IB_QPT_GSI] = (IB_QP_CUR_STATE |
@@ -437,6 +509,11 @@ static const struct {IB_QP_ALT_PATH |IB_QP_PATH_MIG_STATE | IB_QP_MIN_RNR_TIMER), + [IB_QPT_XRC ] = (IB_QP_CUR_STATE | +IB_QP_ACCESS_FLAGS | +IB_QP_ALT_PATH | +IB_QP_PATH_MIG_STATE | + IB_QP_MIN_RNR_TIMER), [IB_QPT_SMI ] = (IB_QP_CUR_STATE | IB_QP_QKEY), [IB_QPT_GSI] = (IB_QP_CUR_STATE |
@@ -449,6 +526,7 @@ static const struct { [IB_QPT_UD] = IB_QP_EN_SQD_ASYNC_NOTIFY, [IB_QPT_UC] = IB_QP_EN_SQD_ASYNC_NOTIFY, [IB_QPT_RC] = IB_QP_EN_SQD_ASYNC_NOTIFY, + [IB_QPT_XRC] = IB_QP_EN_SQD_ASYNC_NOTIFY, [IB_QPT_SMI] = IB_QP_EN_SQD_ASYNC_NOTIFY, [IB_QPT_GSI] = IB_QP_EN_SQD_ASYNC_NOTIFY }
@@ -471,6 +549,11 @@ static const struct {IB_QP_ACCESS_FLAGS |IB_QP_MIN_RNR_TIMER | IB_QP_PATH_MIG_STATE), + [IB_QPT_XRC ] = (IB_QP_CUR_STATE | +IB_QP_ALT_PATH | +IB_QP_ACCESS_FLAGS | +IB_QP_MIN_RNR_TIMER | + IB_QP_PATH_MIG_STATE), [IB_QPT_SMI ] = (IB_QP_CUR_STATE | IB_QP_QKEY), [IB_QPT_GSI] = (IB_QP_CUR_STATE |
@@ -499,6 +582,18 @@ static const struct {IB_QP_PKEY_INDEX |IB_QP_MIN_RNR_TIMER | IB_QP_PATH_MIG_STATE), + [IB_QPT_XRC ] = (IB_QP_PORT | +IB_QP_AV | +IB_QP_TIMEOUT | +IB_QP_RETRY_CNT | +IB_QP_RNR_RETRY | +IB_QP_MAX_QP_RD_ATOMIC | +IB_QP_MAX_DEST_RD_ATOMIC | +IB_QP_ALT_PATH | +IB_QP_ACCESS_FLAGS | +IB_QP_PKEY_INDEX | +IB_QP_MIN_RNR_TIMER | + IB_QP_PATH_MIG_STATE), [IB_QPT_SMI ] = (IB_QP_PKEY_INDEX | IB_QP_QKEY), [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
@@ -583,12 +678,14 @@ int ib_destroy_qp(struct ib_qp *qp)struct ib_pd *pd;struct ib_cq *scq, *rcq;struct ib_srq *srq; +struct ib_xrcd *xrcd;int ret; - pd = qp->pd; - scq = qp->send_cq; - rcq = qp->recv_cq; - srq = qp->srq; + pd = qp->pd; + scq = qp->send_cq; + rcq = qp->recv_cq; + srq = qp->srq; + xrcd = qp->xrcd; ret = qp->device->destroy_qp (qp);if (!ret) {
@@ -597,6 +694,8 @@ int ib_destroy_qp(struct ib_qp *qp)atomic_dec (&rcq->usecnt);if (srq)atomic_dec (&srq->usecnt); +if (xrcd) +atomic_dec (&xrcd->usecnt); }return ret;
@@ -904,3 +1003,30 @@ int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)return qp->device->detach_mcast (qp, gid, lid); }EXPORT_SYMBOL (ib_detach_mcast); + +struct ib_xrcd *ib_alloc_xrcd (struct ib_device *device) +{ +struct ib_xrcd *xrcd; + +if (!device->alloc_xrcd) +return ERR_PTR (-ENOSYS ); + + xrcd = device->alloc_xrcd (device,NULL ,NULL ); +if (!IS_ERR (xrcd)) { + xrcd->device = device; + xrcd->uobject =NULL ; +atomic_set (&xrcd->usecnt,0 ); + } + +return xrcd; +} +EXPORT_SYMBOL (ib_alloc_xrcd); + +int ib_dealloc_xrcd (struct ib_xrcd *xrcd) +{ +if (atomic_read (&xrcd->usecnt)) +return -EBUSY ; + +return xrcd->device->dealloc_xrcd (xrcd); +} +EXPORT_SYMBOL (ib_dealloc_xrcd);
include/rdma/ib_verbs.h +58 -2
128 lines not on this page · raw message
Signature · 6 lines
1.6.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/4 IB/uverbs: Support for XRC
In reply to a message not in the archiveFrom: Jack Morgenstein <[email protected]>
Add support for core userspace XRC operations (alloc/dealloc XRC domain, create XRC SRQ), including adding an ABI for marshalling requests and responses.
--- drivers/infiniband/core/uverbs.h | 4 + drivers/infiniband/core/uverbs_cmd.c | 274 ++++++++++++++++++++++++++++++++- drivers/infiniband/core/uverbs_main.c | 35 +++-- include/rdma/ib_user_verbs.h | 35 ++++- 4 files changed, 334 insertions(+), 14 deletions(-)
drivers/infiniband/core/uverbs.h +4 -0
@@ -141,6 +141,7 @@ extern struct idr ib_uverbs_ah_idr;extern struct idr ib_uverbs_cq_idr;extern struct idr ib_uverbs_qp_idr;extern struct idr ib_uverbs_srq_idr; +extern struct idr ib_uverbs_xrcd_idr;void idr_remove_uobj (struct idr *idp,struct ib_uobject *uobj);
@@ -194,5 +195,8 @@ IB_UVERBS_DECLARE_CMD(create_srq);IB_UVERBS_DECLARE_CMD (modify_srq);IB_UVERBS_DECLARE_CMD (query_srq);IB_UVERBS_DECLARE_CMD (destroy_srq); +IB_UVERBS_DECLARE_CMD (create_xrc_srq); +IB_UVERBS_DECLARE_CMD (open_xrcd); +IB_UVERBS_DECLARE_CMD (close_xrcd);#endif /* UVERBS_H */
drivers/infiniband/core/uverbs_cmd.c +272 -2
353 lines not on this page · raw message
drivers/infiniband/core/uverbs_main.c +24 -11
@@ -73,6 +73,7 @@ DEFINE_IDR(ib_uverbs_ah_idr);DEFINE_IDR (ib_uverbs_cq_idr);DEFINE_IDR (ib_uverbs_qp_idr);DEFINE_IDR (ib_uverbs_srq_idr); +DEFINE_IDR (ib_uverbs_xrcd_idr);static DEFINE_SPINLOCK (map_lock);static struct ib_uverbs_device *dev_table[IB_UVERBS_MAX_DEVICES ];
@@ -109,6 +110,9 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file, [IB_USER_VERBS_CMD_MODIFY_SRQ] = ib_uverbs_modify_srq, [IB_USER_VERBS_CMD_QUERY_SRQ] = ib_uverbs_query_srq, [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq, + [IB_USER_VERBS_CMD_CREATE_XRC_SRQ] = ib_uverbs_create_xrc_srq, + [IB_USER_VERBS_CMD_OPEN_XRCD] = ib_uverbs_open_xrcd, + [IB_USER_VERBS_CMD_CLOSE_XRCD] = ib_uverbs_close_xrcd, };static struct vfsmount *uverbs_event_mnt;
@@ -212,17 +216,6 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,kfree (uqp); } -list_for_each_entry_safe (uobj, tmp, &context->cq_list, list) { -struct ib_cq *cq = uobj->object; -struct ib_uverbs_event_file *ev_file = cq->cq_context; -struct ib_ucq_object *ucq = - container_of(uobj, struct ib_ucq_object, uobject); - -idr_remove_uobj (&ib_uverbs_cq_idr, uobj); -ib_destroy_cq (cq); -ib_uverbs_release_ucq (file, ev_file, ucq); -kfree (ucq); - }list_for_each_entry_safe (uobj, tmp, &context->srq_list, list) {struct ib_srq *srq = uobj->object;
@@ -235,6 +228,18 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,kfree (uevent); } +list_for_each_entry_safe (uobj, tmp, &context->cq_list, list) { +struct ib_cq *cq = uobj->object; +struct ib_uverbs_event_file *ev_file = cq->cq_context; +struct ib_ucq_object *ucq = + container_of(uobj, struct ib_ucq_object, uobject); + +idr_remove_uobj (&ib_uverbs_cq_idr, uobj); +ib_destroy_cq (cq); +ib_uverbs_release_ucq (file, ev_file, ucq); +kfree (ucq); + } +/* XXX Free MWs */ list_for_each_entry_safe (uobj, tmp, &context->mr_list, list) {
@@ -245,6 +250,14 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,kfree (uobj); } +list_for_each_entry_safe (uobj, tmp, &context->xrcd_list, list) { +struct ib_xrcd *xrcd = uobj->object; + +idr_remove_uobj (&ib_uverbs_xrcd_idr, uobj); +ib_dealloc_xrcd (xrcd); +kfree (uobj); + } +list_for_each_entry_safe (uobj, tmp, &context->pd_list, list) {struct ib_pd *pd = uobj->object;
include/rdma/ib_user_verbs.h +34 -1
@@ -81,7 +81,10 @@ enum {IB_USER_VERBS_CMD_MODIFY_SRQ ,IB_USER_VERBS_CMD_QUERY_SRQ ,IB_USER_VERBS_CMD_DESTROY_SRQ , - IB_USER_VERBS_CMD_POST_SRQ_RECV +IB_USER_VERBS_CMD_POST_SRQ_RECV , +IB_USER_VERBS_CMD_CREATE_XRC_SRQ , +IB_USER_VERBS_CMD_OPEN_XRCD , + IB_USER_VERBS_CMD_CLOSE_XRCD };/*
@@ -647,6 +650,18 @@ struct ib_uverbs_create_srq {__u64 driver_data[0 ]; }; +struct ib_uverbs_create_xrc_srq { +__u64 response; +__u64 user_handle; +__u32 pd_handle; +__u32 max_wr; +__u32 max_sge; +__u32 srq_limit; +__u32 xrcd_handle; +__u32 xrc_cq; +__u64 driver_data[0 ]; +}; +struct ib_uverbs_create_srq_resp {__u32 srq_handle;__u32 max_wr;
@@ -686,4 +701,22 @@ struct ib_uverbs_destroy_srq_resp { __u32 events_reported; }; +struct ib_uverbs_open_xrcd { +__u64 response; +__s32 fd; +__u32 oflags; +__u64 driver_data[0 ]; +}; + +struct ib_uverbs_open_xrcd_resp { +__u32 xrcd_handle; +}; + +struct ib_uverbs_close_xrcd { +__u64 response; +__u32 xrcd_handle; +__u32 reserved; +__u64 driver_data[0 ]; +}; +#endif /* IB_USER_VERBS_H */
Signature · 6 lines
1.6.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1264446094-4460-3-git-send-email-rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org
Re: [PATCH 2/4] IB/uverbs: Support for XRC
include/rdma/ib_user_verbs.h enum { · line 84
Quoted 9 lines · Roland Dreier
Add support for core userspace XRC operations (alloc/dealloc XRC domain, create XRC SRQ), including adding an ABI for marshalling requests and responses. +++
b/include/rdma/ib_user_verbs.hinclude/rdma/ib_user_verbs.h +4
-1@@ -81,7 +81,10 @@ enum { -IB_USER_VERBS_CMD_POST_SRQ_RECV +IB_USER_VERBS_CMD_POST_SRQ_RECV , +IB_USER_VERBS_CMD_CREATE_XRC_SRQ , +IB_USER_VERBS_CMD_OPEN_XRCD , +IB_USER_VERBS_CMD_CLOSE_XRCD
Jack,Roland I believe that adding entries to this enum means ABI change towards libibverbs or eventually cause ABI change between libibverbs and its consumers, (e.g change in size/content of the verbs context structure, etc), correct?
I'd like to use this ABI change and introduce/expose also the ib_modify_cq verb to user space. Basically, the related patches should be quite simple (uverbs, libibverbs, libmlx4), still, I'll be glad if you tell/coach me against what code base to do that.
One more thing I'd like to add to libibverbs and some device driver libraries is send-with-invalidate, but this is only user space patch set without any kernel/user, lib/app ABI change, correct?
Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 4B5EFEAD.9040702-hKgKHo2Ms0FWk0Htik3J/[email protected]
Re: [PATCH 2/4] IB/uverbs: Support for XRC
Quoted 8 lines
include/rdma/ib_user_verbs.h enum { · line 87
Quoted 6 lines
include/rdma/ib_user_verbs.h +4
-1-IB_USER_VERBS_CMD_POST_SRQ_RECV +IB_USER_VERBS_CMD_POST_SRQ_RECV , +IB_USER_VERBS_CMD_CREATE_XRC_SRQ , +IB_USER_VERBS_CMD_OPEN_XRCD , +IB_USER_VERBS_CMD_CLOSE_XRCD Jack,Roland I believe that adding entries to this enum means ABI change towards libibverbs or eventually cause ABI change between libibverbs and its consumers, (e.g change in size/content of the verbs context structure, etc), correct?
This is a backwards-compatible ABI extension -- we are adding new commands. And I believe OFED has been shipping this ABI for quite a while now (since 1.4?).
Quoted 1 line
I'd like to use this ABI change and introduce/expose also the
ib_modify_cqverb to user space. Basically, the related patches should be quite simple (uverbs, libibverbs, libmlx4), still, I'll be glad if you tell/coach me against what code base to do that.
OK, but we should coordinate this with all the other ABI extensions that OFED has already made.
Quoted 1 line
One more thing I'd like to add to libibverbs and some device driver libraries is send-with-invalidate, but this is only user space patch set without any kernel/user, lib/app ABI change, correct?
It is a library ABI change of course to add the send with invalidate opcode. But that is OK.
- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): aday6jko26n.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org
Re: [PATCH 2/4] IB/uverbs: Support for XRC
Quoted 1 line · Roland Dreier
OK, but we should coordinate this with all the other ABI extensions that OFED has already made
I believe the only thing I need to coordinate with is the XRC patch set.
Jack, can you please direct me to the patch set I should be setting the modify_cq patches against? no problem if this is going to take some time, but I do want to push cq_modify in the same merge window with XRC, I assume we have at least couple of weeks for this to happen.
Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 4B6003B2.4040101-smomgflXvOZWk0Htik3J/[email protected]
Re: [PATCH 2/4] IB/uverbs: Support for XRC
Quoted 10 lines · Or Gerlitz
Quoted 1 line · Roland Dreier
OK, but we should coordinate this with all the other ABI extensions that OFED has already made
I believe the only thing I need to coordinate with is the XRC patch set.
Jack, can you please direct me to the patch set I should be setting the
modify_cqpatches against? no problem if this is going to take some time, but I do want to pushcq_modifyin the same merge window with XRC, I assume we have at least couple of weeks for this to happen.Or.
I'll be getting into XRC tomorrow. Just finishing up some stuff. The patch set will change, pursuant to Roland's changes.
-Jack
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] IB/uverbs: Support for XRC
In reply to a message not in the archiveQuoted 6 lines
Quoted 3 lines
OK, but we should coordinate this with all the other ABI extensions that OFED has already made
I believe the only thing I need to coordinate with is the XRC patch set.
I think the IBoE patches in the OFED branch also extend the ABI. we should try to avoid stepping on that too.
- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): ada8wbjo7v3.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org
Re: [PATCH 2/4] IB/uverbs: Support for XRC
Quoted 3 lines · Roland Dreier
Quoted 1 line
I believe the only thing I need to coordinate with is the XRC patch set.
I think the IBoE patches in the OFED branch also extend the ABI. We should try to avoid stepping on that too.
I think the only (a part from the link type field in the port attr) ABI change introduced by the IBoE branch is the the get_mac verb. As I wrote Eli @ http://marc.info/?l=linux-rdma&m=126380119407472 to my opinion this verb isn't needed at all, so far he didn't reply.
Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/4 IB/uverbs: Add struct ib_usrq_object and ib_uxrcd_object
In reply to a message not in the archiveWhen we add support for sharing XRC domains among multiple processes, we will need to keep track of which XRCD each QP and SRQ is associated with, and keep a per-userspace-context reference count for each XRCD.
Userspace QPs already have a struct ib_uqp_object associated with them, so we can put an XRCD pointer there, but we don't have such an object for SRQs. To handle this, convert userspace SRQs from using struct ib_uevent_object to a new struct ib_usrq_object. To hold the per-context XRCD reference count, we convert userspace XRCDs to use a new struct ib_uxrcd_object.
This patch makes struct ib_usrq_object just contain a struct ib_uevent_object and struct ib_uxrcd_object just contain a struct ib_uobject. The follow-up patch adding support for shared XRCDs will add the extra fields.
--- drivers/infiniband/core/uverbs.h | 8 +++ drivers/infiniband/core/uverbs_cmd.c | 92 ++++++++++++++++---------------- drivers/infiniband/core/uverbs_main.c | 12 +++-- 3 files changed, 61 insertions(+), 51 deletions(-)
drivers/infiniband/core/uverbs.h +8 -0
@@ -119,6 +119,14 @@ struct ib_uevent_object {u32 events_reported; }; +struct ib_uxrcd_object { +struct ib_uobject uobject; +}; + +struct ib_usrq_object { +struct ib_uevent_object uevent; +}; +struct ib_uqp_object {struct ib_uevent_object uevent;struct list_head mcast_list;
drivers/infiniband/core/uverbs_cmd.c +46 -46
263 lines not on this page · raw message
drivers/infiniband/core/uverbs_main.c +7 -5
@@ -219,13 +219,13 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,list_for_each_entry_safe (uobj, tmp, &context->srq_list, list) {struct ib_srq *srq = uobj->object; -struct ib_uevent_object *uevent = - container_of(uobj, struct ib_uevent_object, uobject); +struct ib_usrq_object *usrq = + container_of(uobj, struct ib_usrq_object, uevent.uobject);idr_remove_uobj (&ib_uverbs_srq_idr, uobj);ib_destroy_srq (srq); -ib_uverbs_release_uevent (file, uevent); -kfree (uevent); +ib_uverbs_release_uevent (file, &usrq->uevent); +kfree (usrq); }list_for_each_entry_safe (uobj, tmp, &context->cq_list, list) {
@@ -252,10 +252,12 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,list_for_each_entry_safe (uobj, tmp, &context->xrcd_list, list) {struct ib_xrcd *xrcd = uobj->object; +struct ib_uxrcd_object *uxrcd = + container_of(uobj, struct ib_uxrcd_object, uobject);idr_remove_uobj (&ib_uverbs_xrcd_idr, uobj);ib_dealloc_xrcd (xrcd); -kfree (uobj); +kfree (uxrcd); }list_for_each_entry_safe (uobj, tmp, &context->pd_list, list) {
Signature · 6 lines
1.6.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/4 IB/uverbs: Support for associating XRC domains to inodes
In reply to a message not in the archiveFrom: Jack Morgenstein <[email protected]>
Add support for associating an XRC domain to an inode so that XRC domains can be shared between processes. We keep a per-device RB tree of XRCDs (indexed by inode) in the uverbs module, and use struct ib_xrcd's usecnt member to reference count XRCDs so that an XRCD is not freed until the last process with a reference is done with it.
--- drivers/infiniband/core/uverbs.h | 9 +- drivers/infiniband/core/uverbs_cmd.c | 298 ++++++++++++++++++++++++++++----- drivers/infiniband/core/uverbs_main.c | 6 +- drivers/infiniband/core/verbs.c | 2 +- include/rdma/ib_verbs.h | 2 +- 5 files changed, 272 insertions(+), 45 deletions(-)
drivers/infiniband/core/uverbs.h +8 -1
@@ -70,10 +70,12 @@struct ib_uverbs_device {struct kref ref;struct completion comp; -int devnum;struct cdev *cdev;struct device *dev;struct ib_device *ib_dev; +struct rb_root xrcd_tree; +struct mutex xrcd_tree_mutex; +int devnum;int num_comp_vectors; };
@@ -121,15 +123,18 @@ struct ib_uevent_object {struct ib_uxrcd_object {struct ib_uobject uobject; +atomic_t refcnt; };struct ib_usrq_object {struct ib_uevent_object uevent; +struct ib_uxrcd_object *uxrcd; };struct ib_uqp_object {struct ib_uevent_object uevent;struct list_head mcast_list; +struct ib_uxrcd_object *uxrcd; };struct ib_ucq_object {
@@ -169,6 +174,8 @@ void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr);void ib_uverbs_srq_event_handler (struct ib_event *event,void *context_ptr);void ib_uverbs_event_handler (struct ib_event_handler *handler,struct ib_event *event); +void ib_uverbs_dealloc_xrcd (struct ib_uverbs_device *dev, +struct ib_xrcd *xrcd);#define IB_UVERBS_DECLARE_CMD (name) \ ssize_t ib_uverbs_##name(struct ib_uverbs_file *file, \
drivers/infiniband/core/uverbs_cmd.c +257 -41
473 lines not on this page · raw message
drivers/infiniband/core/uverbs_main.c +5 -1
@@ -250,15 +250,17 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,kfree (uobj); } +mutex_lock (&file->device->xrcd_tree_mutex);list_for_each_entry_safe (uobj, tmp, &context->xrcd_list, list) {struct ib_xrcd *xrcd = uobj->object;struct ib_uxrcd_object *uxrcd = container_of(uobj, struct ib_uxrcd_object, uobject);idr_remove_uobj (&ib_uverbs_xrcd_idr, uobj); -ib_dealloc_xrcd (xrcd); +ib_uverbs_dealloc_xrcd (file->device, xrcd);kfree (uxrcd); } +mutex_unlock (&file->device->xrcd_tree_mutex);list_for_each_entry_safe (uobj, tmp, &context->pd_list, list) {struct ib_pd *pd = uobj->object;
@@ -763,6 +765,8 @@ static void ib_uverbs_add_one(struct ib_device *device)kref_init (&uverbs_dev->ref);init_completion (&uverbs_dev->comp); + uverbs_dev->xrcd_tree =RB_ROOT ; +mutex_init (&uverbs_dev->xrcd_tree_mutex);spin_lock (&map_lock); uverbs_dev->devnum =find_first_zero_bit (dev_map,IB_UVERBS_MAX_DEVICES );
drivers/infiniband/core/verbs.c +1 -1
@@ -1014,7 +1014,7 @@ struct ib_xrcd *ib_alloc_xrcd(struct ib_device *device) xrcd = device->alloc_xrcd (device,NULL ,NULL );if (!IS_ERR (xrcd)) { xrcd->device = device; - xrcd->uobject =NULL ; + xrcd->inode =NULL ;atomic_set (&xrcd->usecnt,0 ); }
include/rdma/ib_verbs.h +1 -1
@@ -848,7 +848,7 @@ struct ib_pd {struct ib_xrcd {struct ib_device *device; -struct ib_uobject *uobject; +struct inode *inode;atomic_t usecnt;/* count all resources */ };
Signature · 6 lines
1.6.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1264446094-4460-5-git-send-email-rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org
Re: [PATCH 4/4] IB/uverbs: Support for associating XRC domains to inodes
Quoted 10 lines · Roland Dreier
From: Jack Morgenstein <[email protected]>
Add support for associating an XRC domain to an inode so that XRC domains can be shared between processes. We keep a per-device RB tree of XRCDs (indexed by inode) in the uverbs module, and use struct ib_xrcd's usecnt member to reference count XRCDs so that an XRCD is not freed until the last process with a reference is done with it.
Signed-off-by Jack Morgenstein <[email protected]>Signed-off-by Roland Dreier <[email protected]>
Feedback on the patch set.
I think I have uncovered a couple of bugs in my review (not surprising, since you most likely could not try out the code).
1. the xrcd refcnt is incremented when creating an xrc qp and xrc srq, but is unconditionally decremented in destroy_qp/destroy_srq whether we have an xrcd or not.
2. In closing/deallocating xrc domains, it is not an error if ib_dealloc_xrcd returns "busy". This simply means that there are other user processes still using that xrc domain. The current process still needs to clean up its uobject. In particular, the usecnt should not be re-incremented on the busy return. (If it gets re-incremented on busy, no one can ever succeed in closing an xrc domain if more that one process is using it).
The following patch fixes the above issues I think. (The patch below assumes that the only error value returned by ib_dealloc_xrcd is "-EBUSY" -- as is the case with pd's. The mlx4 driver always returns 0 for the deallocate functions).
Please review this and send me your feedback.
Thanks!
-Jack
=========================================================================================
drivers/infiniband/core/uverbs_cmd.c +13 -15
@@ -1382,6 +1382,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,struct ib_uobject *uobj;struct ib_qp *qp;struct ib_uqp_object *obj; +struct ib_xrcd *xrcd;int ret = -EINVAL ;if (copy_from_user (&cmd, buf,sizeof cmd))
@@ -1400,6 +1401,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,return -EBUSY ; } + xrcd = qp->xrcd; ret =ib_destroy_qp (qp);if (!ret) uobj->live =0 ;
@@ -1409,7 +1411,8 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,if (ret)return ret; -atomic_dec (&obj->uxrcd->refcnt); +if (xrcd) +atomic_dec (&obj->uxrcd->refcnt);idr_remove_uobj (&ib_uverbs_qp_idr, uobj);
@@ -2294,6 +2297,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,struct ib_uobject *uobj;struct ib_srq *srq;struct ib_usrq_object *obj; +struct ib_xrcd *xrcd;int ret = -EINVAL ;if (copy_from_user (&cmd, buf,sizeof cmd))
@@ -2305,6 +2309,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, srq = uobj->object; obj = container_of(uobj, struct ib_usrq_object, uevent.uobject); + xrcd = srq->xrcd; ret =ib_destroy_srq (srq);if (!ret) uobj->live =0 ;
@@ -2314,7 +2319,8 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,if (ret)return ret; -atomic_dec (&obj->uxrcd->refcnt); +if (xrcd) +atomic_dec (&obj->uxrcd->refcnt);idr_remove_uobj (&ib_uverbs_srq_idr, uobj);
@@ -2604,12 +2610,9 @@ ssize_t ib_uverbs_close_xrcd(struct ib_uverbs_file *file, live = uobj->live; -if (inode && ret) -atomic_inc (&xrcd->usecnt); -put_uobj_write (uobj); -if (ret) +if (ret && !inode) goto out;if (inode && !live)
@@ -2637,15 +2640,10 @@ void ib_uverbs_dealloc_xrcd(struct ib_uverbs_device *dev,int ret =0 ; inode = xrcd->inode; -if (inode && !atomic_dec_and_test (&xrcd->usecnt)) -return ; +if (inode) +atomic_dec (&xrcd->usecnt); ret =ib_dealloc_xrcd (xrcd); - -if (inode) { -if (!ret) -xrcd_table_delete (dev, inode); -else -atomic_inc (&xrcd->usecnt); - } +if (!ret && inode) +xrcd_table_delete (dev, inode); }
=======================================================================
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 201002011552.24904.jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
Re: [PATCH 4/4] IB/uverbs: Support for associating XRC domains to inodes
Quoted 2 lines
I think I have uncovered a couple of bugs in my review (not surprising, since you most likely could not try out the code).
Thanks. Yes, this was all compile-tested only.
Quoted 2 lines
1. the xrcd refcnt is incremented when creating an xrc qp and xrc srq, but is unconditionally decremented in destroy_qp/destroy_srq whether we have an xrcd or not.
This was all messed up... the error path of create_qp was bogus too. I think the updated patch below is good though.
Quoted 5 lines
2. In closing/deallocating xrc domains, it is not an error if
ib_dealloc_xrcdreturns "busy". This simply means that there are other user processes still using that xrc domain. The current process still needs to clean up its uobject. In particular, the usecnt should not be re-incremented on the busy return. (If it gets re-incremented on busy, no one can ever succeed in closing an xrc domain if more that one process is using it).
I do agree we shouldn't reincrement the use count if the dealloc fails -- in ib_uverbs_dealloc_xrcd we're in the path of closing a context and so there's no real way to recover if the ib_dealloc_xrcd fails. But I don't think the busy case is an issue -- we should return without trying to dealloc if the xrcd is held by another process, since the atomic_dec_and_test will return a non-zero value in that case I think. So the simplification in the patch below should be OK, right?
--- drivers/infiniband/core/uverbs.h | 9 +- drivers/infiniband/core/uverbs_cmd.c | 294 ++++++++++++++++++++++++++++----- drivers/infiniband/core/uverbs_main.c | 6 +- drivers/infiniband/core/verbs.c | 2 +- include/rdma/ib_verbs.h | 2 +- 5 files changed, 268 insertions(+), 45 deletions(-)
drivers/infiniband/core/uverbs.h +8 -1
@@ -70,10 +70,12 @@struct ib_uverbs_device {struct kref ref;struct completion comp; -int devnum;struct cdev *cdev;struct device *dev;struct ib_device *ib_dev; +struct rb_root xrcd_tree; +struct mutex xrcd_tree_mutex; +int devnum;int num_comp_vectors; };
@@ -121,15 +123,18 @@ struct ib_uevent_object {struct ib_uxrcd_object {struct ib_uobject uobject; +atomic_t refcnt; };struct ib_usrq_object {struct ib_uevent_object uevent; +struct ib_uxrcd_object *uxrcd; };struct ib_uqp_object {struct ib_uevent_object uevent;struct list_head mcast_list; +struct ib_uxrcd_object *uxrcd; };struct ib_ucq_object {
@@ -169,6 +174,8 @@ void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr);void ib_uverbs_srq_event_handler (struct ib_event *event,void *context_ptr);void ib_uverbs_event_handler (struct ib_event_handler *handler,struct ib_event *event); +void ib_uverbs_dealloc_xrcd (struct ib_uverbs_device *dev, +struct ib_xrcd *xrcd);#define IB_UVERBS_DECLARE_CMD (name) \ ssize_t ib_uverbs_##name(struct ib_uverbs_file *file, \
drivers/infiniband/core/uverbs_cmd.c +253 -41
456 lines not on this page · raw message
drivers/infiniband/core/uverbs_main.c +5 -1
@@ -250,15 +250,17 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,kfree (uobj); } +mutex_lock (&file->device->xrcd_tree_mutex);list_for_each_entry_safe (uobj, tmp, &context->xrcd_list, list) {struct ib_xrcd *xrcd = uobj->object;struct ib_uxrcd_object *uxrcd = container_of(uobj, struct ib_uxrcd_object, uobject);idr_remove_uobj (&ib_uverbs_xrcd_idr, uobj); -ib_dealloc_xrcd (xrcd); +ib_uverbs_dealloc_xrcd (file->device, xrcd);kfree (uxrcd); } +mutex_unlock (&file->device->xrcd_tree_mutex);list_for_each_entry_safe (uobj, tmp, &context->pd_list, list) {struct ib_pd *pd = uobj->object;
@@ -763,6 +765,8 @@ static void ib_uverbs_add_one(struct ib_device *device)kref_init (&uverbs_dev->ref);init_completion (&uverbs_dev->comp); + uverbs_dev->xrcd_tree =RB_ROOT ; +mutex_init (&uverbs_dev->xrcd_tree_mutex);spin_lock (&map_lock); uverbs_dev->devnum =find_first_zero_bit (dev_map,IB_UVERBS_MAX_DEVICES );
drivers/infiniband/core/verbs.c +1 -1
@@ -1014,7 +1014,7 @@ struct ib_xrcd *ib_alloc_xrcd(struct ib_device *device) xrcd = device->alloc_xrcd (device,NULL ,NULL );if (!IS_ERR (xrcd)) { xrcd->device = device; - xrcd->uobject =NULL ; + xrcd->inode =NULL ;atomic_set (&xrcd->usecnt,0 ); }
include/rdma/ib_verbs.h +1 -1
@@ -848,7 +848,7 @@ struct ib_pd {struct ib_xrcd {struct ib_device *device; -struct ib_uobject *uobject; +struct inode *inode;atomic_t usecnt;/* count all resources */ };
Signature · 6 lines
1.6.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): adaeil2gfy9.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org
Re: [PATCH 4/4] IB/uverbs: Support for associating XRC domains to inodes
Quoted 10 lines · Roland Dreier
> 2. In closing/deallocating xrc domains, it is not an error if
ib_dealloc_xrcdreturns "busy". > This simply means that there are other user processes still using that xrc domain. > The current process still needs to clean up its uobject. In particular, the usecnt should > not be re-incremented on the busy return. (If it gets re-incremented on busy, no one can ever > succeed in closing an xrc domain if more that one process is using it).I do agree we shouldn't reincrement the use count if the dealloc fails -- in
ib_uverbs_dealloc_xrcdwe're in the path of closing a context and so there's no real way to recover if theib_dealloc_xrcdfails.
Agreed. If we return an error when there is no i-node, then we should also return an error when an i-node exists (and restore the status-quo-ante by reincrementing the refcnt in this case). Although, this will leave things in a weird state (with an xrcd which cannot get deallocated). Like you, I don't really see other options here.
Quoted 4 lines
But I don't think the busy case is an issue -- we should return without trying to dealloc if the xrcd is held by another process, since the
atomic_dec_and_testwill return a non-zero value in that case I think.
You are correct -- I missed that in my review.
Quoted 1 line
So the simplification in the patch below should be OK, right?
Looks good!
-Jack
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line
I finally found time to finish going over the base XRC patches. I
fixed
Quoted 9 lines
the "userspace can destroy an XRCD handle while still having QPs/SRQs referring to it" problem with a reference count, rather than the more complicated method used by the original patches.
I think the next step would be for someone (probably not me if we want this to happen soon) to port the rest of the mlx4 XRC patch set on top of this, ideally trying to factor out any reference-counting-ish code away from the device-specific driver and into common code. Then we should finally be able to merge this and move on to the IBoE changes.
Thanks Roland
Jack from Mellanox will take it from here
Tziporet
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html