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: 24+ 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 ` [PATCHv6 1/3] rdmacg: Added rdma cgroup controller Parav Pandit
2016-02-21 7:43 ` Leon Romanovsky
2016-02-21 11:33 ` Parav Pandit
2016-02-21 13:45 ` Leon Romanovsky
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 16:16 ` Parav Pandit
2016-02-25 12:03 ` Haggai Eran
2016-02-25 13:34 ` Parav Pandit
2016-02-25 14:26 ` Parav Pandit
2016-02-25 14:42 ` Haggai Eran
2016-02-25 14:30 ` Haggai Eran
2016-02-20 11:00 ` [PATCHv6 2/3] IB/core: added support to use " Parav Pandit
2016-02-24 13:43 ` Haggai Eran [this message]
2016-02-24 16:05 ` Parav Pandit
2016-02-20 11:00 ` [PATCHv6 3/3] rdmacg: Added documentation for rdmacg Parav Pandit
2016-02-24 14:26 ` Haggai Eran
2016-02-24 15:21 ` Parav Pandit
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@mellanox.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=dledford@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=james.l.morris@oracle.com \
--cc=jgunthorpe@obsidianresearch.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=liranl@mellanox.com \
--cc=lizefan@huawei.com \
--cc=matanb@mellanox.com \
--cc=ogerlitz@mellanox.com \
--cc=pandit.parav@gmail.com \
--cc=raindel@mellanox.com \
--cc=sean.hefty@intel.com \
--cc=serge@hallyn.com \
--cc=tj@kernel.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox