From: Haggai Eran <haggaie-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> To: Parav Pandit <pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org, hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org, dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, liranl-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org, sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org Cc: corbet-T1hC0tSOHrs@public.gmane.org, james.l.morris-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org, serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org, ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org, matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org, raindel-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Subject: Re: [PATCHv6 2/3] IB/core: added support to use rdma cgroup controller Date: Wed, 24 Feb 2016 15:43:16 +0200 [thread overview] Message-ID: <56CDB374.602@mellanox.com> (raw) In-Reply-To: <1455966006-13774-3-git-send-email-pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> On 20/02/2016 13:00, Parav Pandit wrote: > +/** > + * ib_device_unregister_rdmacg - unregister with rdma cgroup. > + * @device: device to unregister. > + * > + * Unregister with the rdma cgroup. Should be called after > + * all the resources are deallocated, and after a stage when any > + * other resource allocation of user application cannot be done > + * for this device to avoid any leak in accounting. > + * HCA drivers should clear resource pool ops after ib stack > + * unregisters with rdma cgroup. HCA drivers don't supply their own ops in this version, right? If so, you can update the comment. > + */ > +void ib_device_unregister_rdmacg(struct ib_device *device) > +{ > + rdmacg_unregister_device(&device->cg_device); > +} > diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c > index 179e813..c3bd24c 100644 > --- a/drivers/infiniband/core/device.c > +++ b/drivers/infiniband/core/device.c > @@ -352,10 +352,22 @@ int ib_register_device(struct ib_device *device, > goto out; > } > > +#ifdef CONFIG_CGROUP_RDMA > + ret = ib_device_register_rdmacg(device); > + if (ret) { > + printk(KERN_WARNING "Couldn't set up InfiniBand P_Key/GID cache\n"); You should update the error string, and I think checkpatch recommends using pr_warn(). > + ib_cache_cleanup_one(device); > + goto out; > + } > +#endif > + > ret = ib_device_register_sysfs(device, port_callback); > if (ret) { > printk(KERN_WARNING "Couldn't register device %s with driver model\n", > device->name); > +#ifdef CONFIG_CGROUP_RDMA > + ib_device_unregister_rdmacg(device); > +#endif > ib_cache_cleanup_one(device); > goto out; > } > @@ -405,6 +417,10 @@ void ib_unregister_device(struct ib_device *device) > > mutex_unlock(&device_mutex); > > +#ifdef CONFIG_CGROUP_RDMA > + ib_device_unregister_rdmacg(device); > +#endif > + > ib_device_unregister_sysfs(device); > ib_cache_cleanup_one(device); > > diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c > index 1c02dea..7c51e8a 100644 > --- a/drivers/infiniband/core/uverbs_cmd.c > +++ b/drivers/infiniband/core/uverbs_cmd.c > @@ -1777,6 +1851,12 @@ static int create_qp(struct ib_uverbs_file *file, > &qp_lock_class); > down_write(&obj->uevent.uobject.mutex); > > + pd = idr_read_pd(cmd->pd_handle, file->ucontext); > + if (!pd) { > + ret = -EINVAL; > + goto err_put; > + } > + I'm not sure I understand why you need to keep the PD here. Why don't you use the same ib_device that is used to create the QP? The same applies comment also applies to other uverbs commands. > if (cmd->qp_type == IB_QPT_XRC_TGT) { > xrcd = idr_read_xrcd(cmd->pd_handle, file->ucontext, > &xrcd_uobj); > @@ -1811,8 +1891,7 @@ static int create_qp(struct ib_uverbs_file *file, > > scq = idr_read_cq(cmd->send_cq_handle, file->ucontext, !!rcq); > rcq = rcq ?: scq; > - pd = idr_read_pd(cmd->pd_handle, file->ucontext); > - if (!pd || !scq) { > + if (!scq) { > ret = -EINVAL; > goto err_put; > } > @@ -1858,6 +1937,11 @@ static int create_qp(struct ib_uverbs_file *file, > goto err_put; > } > > + ret = ib_rdmacg_try_charge(&obj->uevent.uobject.cg_obj, pd->device, > + RDMA_VERB_RESOURCE_QP, 1); > + if (ret) > + goto err_put; > + > if (cmd->qp_type == IB_QPT_XRC_TGT) > qp = ib_create_qp(pd, &attr); > else > @@ -1865,7 +1949,7 @@ static int create_qp(struct ib_uverbs_file *file, > > if (IS_ERR(qp)) { > ret = PTR_ERR(qp); > - goto err_put; > + goto err_create; > } > > if (cmd->qp_type != IB_QPT_XRC_TGT) { > @@ -1940,6 +2024,10 @@ err_cb: > err_destroy: > ib_destroy_qp(qp); > > +err_create: > + ib_rdmacg_uncharge(&obj->uevent.uobject.cg_obj, device, > + RDMA_VERB_RESOURCE_QP, 1); > + > err_put: > if (xrcd) > put_xrcd_read(xrcd_uobj); > @@ -3323,6 +3441,11 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file, > obj->uevent.events_reported = 0; > INIT_LIST_HEAD(&obj->uevent.event_list); > > + ret = ib_rdmacg_try_charge(&obj->uevent.uobject.cg_obj, pd->device, > + RDMA_VERB_RESOURCE_SRQ, 1); > + if (ret) > + goto err_put_cq; > + I think you need a new error label to release the PD IDR but not uncharge. > srq = pd->device->create_srq(pd, &attr, udata); > if (IS_ERR(srq)) { > ret = PTR_ERR(srq); > @@ -3387,6 +3510,8 @@ err_destroy: > ib_destroy_srq(srq); > > err_put: > + ib_rdmacg_uncharge(&obj->uevent.uobject.cg_obj, pd->device, > + RDMA_VERB_RESOURCE_SRQ, 1); > put_pd_read(pd); > > err_put_cq: Regards, Haggai
WARNING: multiple messages have this Message-ID (diff)
From: Haggai Eran <haggaie@mellanox.com> To: Parav Pandit <pandit.parav@gmail.com>, <cgroups@vger.kernel.org>, <linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-rdma@vger.kernel.org>, <tj@kernel.org>, <lizefan@huawei.com>, <hannes@cmpxchg.org>, <dledford@redhat.com>, <liranl@mellanox.com>, <sean.hefty@intel.com>, <jgunthorpe@obsidianresearch.com> Cc: <corbet@lwn.net>, <james.l.morris@oracle.com>, <serge@hallyn.com>, <ogerlitz@mellanox.com>, <matanb@mellanox.com>, <raindel@mellanox.com>, <akpm@linux-foundation.org>, <linux-security-module@vger.kernel.org> Subject: Re: [PATCHv6 2/3] IB/core: added support to use rdma cgroup controller Date: Wed, 24 Feb 2016 15:43:16 +0200 [thread overview] Message-ID: <56CDB374.602@mellanox.com> (raw) In-Reply-To: <1455966006-13774-3-git-send-email-pandit.parav@gmail.com> On 20/02/2016 13:00, Parav Pandit wrote: > +/** > + * ib_device_unregister_rdmacg - unregister with rdma cgroup. > + * @device: device to unregister. > + * > + * Unregister with the rdma cgroup. Should be called after > + * all the resources are deallocated, and after a stage when any > + * other resource allocation of user application cannot be done > + * for this device to avoid any leak in accounting. > + * HCA drivers should clear resource pool ops after ib stack > + * unregisters with rdma cgroup. HCA drivers don't supply their own ops in this version, right? If so, you can update the comment. > + */ > +void ib_device_unregister_rdmacg(struct ib_device *device) > +{ > + rdmacg_unregister_device(&device->cg_device); > +} > diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c > index 179e813..c3bd24c 100644 > --- a/drivers/infiniband/core/device.c > +++ b/drivers/infiniband/core/device.c > @@ -352,10 +352,22 @@ int ib_register_device(struct ib_device *device, > goto out; > } > > +#ifdef CONFIG_CGROUP_RDMA > + ret = ib_device_register_rdmacg(device); > + if (ret) { > + printk(KERN_WARNING "Couldn't set up InfiniBand P_Key/GID cache\n"); You should update the error string, and I think checkpatch recommends using pr_warn(). > + ib_cache_cleanup_one(device); > + goto out; > + } > +#endif > + > ret = ib_device_register_sysfs(device, port_callback); > if (ret) { > printk(KERN_WARNING "Couldn't register device %s with driver model\n", > device->name); > +#ifdef CONFIG_CGROUP_RDMA > + ib_device_unregister_rdmacg(device); > +#endif > ib_cache_cleanup_one(device); > goto out; > } > @@ -405,6 +417,10 @@ void ib_unregister_device(struct ib_device *device) > > mutex_unlock(&device_mutex); > > +#ifdef CONFIG_CGROUP_RDMA > + ib_device_unregister_rdmacg(device); > +#endif > + > ib_device_unregister_sysfs(device); > ib_cache_cleanup_one(device); > > diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c > index 1c02dea..7c51e8a 100644 > --- a/drivers/infiniband/core/uverbs_cmd.c > +++ b/drivers/infiniband/core/uverbs_cmd.c > @@ -1777,6 +1851,12 @@ static int create_qp(struct ib_uverbs_file *file, > &qp_lock_class); > down_write(&obj->uevent.uobject.mutex); > > + pd = idr_read_pd(cmd->pd_handle, file->ucontext); > + if (!pd) { > + ret = -EINVAL; > + goto err_put; > + } > + I'm not sure I understand why you need to keep the PD here. Why don't you use the same ib_device that is used to create the QP? The same applies comment also applies to other uverbs commands. > if (cmd->qp_type == IB_QPT_XRC_TGT) { > xrcd = idr_read_xrcd(cmd->pd_handle, file->ucontext, > &xrcd_uobj); > @@ -1811,8 +1891,7 @@ static int create_qp(struct ib_uverbs_file *file, > > scq = idr_read_cq(cmd->send_cq_handle, file->ucontext, !!rcq); > rcq = rcq ?: scq; > - pd = idr_read_pd(cmd->pd_handle, file->ucontext); > - if (!pd || !scq) { > + if (!scq) { > ret = -EINVAL; > goto err_put; > } > @@ -1858,6 +1937,11 @@ static int create_qp(struct ib_uverbs_file *file, > goto err_put; > } > > + ret = ib_rdmacg_try_charge(&obj->uevent.uobject.cg_obj, pd->device, > + RDMA_VERB_RESOURCE_QP, 1); > + if (ret) > + goto err_put; > + > if (cmd->qp_type == IB_QPT_XRC_TGT) > qp = ib_create_qp(pd, &attr); > else > @@ -1865,7 +1949,7 @@ static int create_qp(struct ib_uverbs_file *file, > > if (IS_ERR(qp)) { > ret = PTR_ERR(qp); > - goto err_put; > + goto err_create; > } > > if (cmd->qp_type != IB_QPT_XRC_TGT) { > @@ -1940,6 +2024,10 @@ err_cb: > err_destroy: > ib_destroy_qp(qp); > > +err_create: > + ib_rdmacg_uncharge(&obj->uevent.uobject.cg_obj, device, > + RDMA_VERB_RESOURCE_QP, 1); > + > err_put: > if (xrcd) > put_xrcd_read(xrcd_uobj); > @@ -3323,6 +3441,11 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file, > obj->uevent.events_reported = 0; > INIT_LIST_HEAD(&obj->uevent.event_list); > > + ret = ib_rdmacg_try_charge(&obj->uevent.uobject.cg_obj, pd->device, > + RDMA_VERB_RESOURCE_SRQ, 1); > + if (ret) > + goto err_put_cq; > + I think you need a new error label to release the PD IDR but not uncharge. > srq = pd->device->create_srq(pd, &attr, udata); > if (IS_ERR(srq)) { > ret = PTR_ERR(srq); > @@ -3387,6 +3510,8 @@ err_destroy: > ib_destroy_srq(srq); > > err_put: > + ib_rdmacg_uncharge(&obj->uevent.uobject.cg_obj, pd->device, > + RDMA_VERB_RESOURCE_SRQ, 1); > put_pd_read(pd); > > err_put_cq: Regards, Haggai
next prev parent reply other threads:[~2016-02-24 13:43 UTC|newest] Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-02-20 11:00 [PATCHv6 0/3] rdmacg: IB/core: rdma controller support Parav Pandit 2016-02-20 11:00 ` Parav Pandit 2016-02-20 11:00 ` [PATCHv6 2/3] IB/core: added support to use rdma cgroup controller Parav Pandit [not found] ` <1455966006-13774-3-git-send-email-pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2016-02-24 13:43 ` Haggai Eran [this message] 2016-02-24 13:43 ` Haggai Eran 2016-02-24 16:05 ` Parav Pandit [not found] ` <1455966006-13774-1-git-send-email-pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2016-02-20 11:00 ` [PATCHv6 1/3] rdmacg: Added " Parav Pandit 2016-02-20 11:00 ` Parav Pandit 2016-02-21 7:43 ` Leon Romanovsky 2016-02-21 11:33 ` Parav Pandit [not found] ` <CAG53R5XGJESb+_-FtjLsK+jHoEmbePLd==G2knBMOcrfdPm62Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-02-21 13:45 ` Leon Romanovsky 2016-02-21 13:45 ` Leon Romanovsky [not found] ` <20160221134518.GM30450-2ukJVAZIZ/Y@public.gmane.org> 2016-02-21 14:11 ` Parav Pandit 2016-02-21 14:11 ` Parav Pandit 2016-02-21 15:09 ` Leon Romanovsky 2016-02-21 15:15 ` Parav Pandit 2016-02-24 13:13 ` Haggai Eran 2016-02-24 13:13 ` Haggai Eran [not found] ` <56CDAC7A.6030206-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> 2016-02-24 16:16 ` Parav Pandit 2016-02-24 16:16 ` Parav Pandit [not found] ` <CAG53R5Uof+Ve7CndWy=BrgtxxCisQpzP_Ls0kw=Q270DhoEsZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-02-25 12:03 ` Haggai Eran 2016-02-25 12:03 ` Haggai Eran [not found] ` <56CEED81.7010507-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> 2016-02-25 13:34 ` Parav Pandit 2016-02-25 13:34 ` Parav Pandit 2016-02-25 14:26 ` Parav Pandit [not found] ` <CAG53R5WxXYZof4QzuJndakzvG1+t388pDRXL2O466eEDkYJ+bw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-02-25 14:42 ` Haggai Eran 2016-02-25 14:42 ` Haggai Eran [not found] ` <CAG53R5UZb=9WR7zk2b5C_FuKmt+WdNkbcrVbW+g1-oAj6J=w_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-02-25 14:30 ` Haggai Eran 2016-02-25 14:30 ` Haggai Eran 2016-02-20 11:00 ` [PATCHv6 3/3] rdmacg: Added documentation for rdmacg Parav Pandit 2016-02-20 11:00 ` Parav Pandit 2016-02-20 11:00 ` Parav Pandit [not found] ` <1455966006-13774-4-git-send-email-pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2016-02-24 14:26 ` Haggai Eran 2016-02-24 14:26 ` Haggai Eran 2016-02-24 15:21 ` Parav Pandit 2016-02-28 8:55 ` Haggai Eran 2016-02-28 8:55 ` Haggai Eran 2016-02-28 9:02 ` Parav Pandit 2016-02-22 4:59 ` [PATCHv6 0/3] rdmacg: IB/core: rdma controller support Parav Pandit
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=56CDB374.602@mellanox.com \ --to=haggaie-vpraknaxozvwk0htik3j/w@public.gmane.org \ --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \ --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=corbet-T1hC0tSOHrs@public.gmane.org \ --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \ --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \ --cc=james.l.morris-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \ --cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \ --cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=liranl-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \ --cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \ --cc=matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \ --cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \ --cc=pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \ --cc=raindel-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \ --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \ --cc=serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org \ --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.