Skip to content

Commit 08f294a

Browse files
Leon Romanovskyjgunthorpe
Leon Romanovsky
authored andcommitted
RDMA/core: Add resource tracking for create and destroy CQs
Track create and destroy operations of CQ objects. Reviewed-by: Mark Bloch <markb@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Reviewed-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 78a0cd6 commit 08f294a

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

drivers/infiniband/core/cq.c

+6
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private,
159159
if (!cq->wc)
160160
goto out_destroy_cq;
161161

162+
cq->res.type = RDMA_RESTRACK_CQ;
163+
cq->res.kern_name = caller;
164+
rdma_restrack_add(&cq->res);
165+
162166
switch (cq->poll_ctx) {
163167
case IB_POLL_DIRECT:
164168
cq->comp_handler = ib_cq_completion_direct;
@@ -183,6 +187,7 @@ struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private,
183187

184188
out_free_wc:
185189
kfree(cq->wc);
190+
rdma_restrack_del(&cq->res);
186191
out_destroy_cq:
187192
cq->device->destroy_cq(cq);
188193
return ERR_PTR(ret);
@@ -214,6 +219,7 @@ void ib_free_cq(struct ib_cq *cq)
214219
}
215220

216221
kfree(cq->wc);
222+
rdma_restrack_del(&cq->res);
217223
ret = cq->device->destroy_cq(cq);
218224
WARN_ON_ONCE(ret);
219225
}

drivers/infiniband/core/uverbs_cmd.c

+2
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,8 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
10331033
goto err_cb;
10341034

10351035
uobj_alloc_commit(&obj->uobject);
1036+
cq->res.type = RDMA_RESTRACK_CQ;
1037+
rdma_restrack_add(&cq->res);
10361038

10371039
return obj;
10381040

drivers/infiniband/core/uverbs_std_types.c

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <rdma/ib_verbs.h>
3636
#include <linux/bug.h>
3737
#include <linux/file.h>
38+
#include <rdma/restrack.h>
3839
#include "rdma_core.h"
3940
#include "uverbs.h"
4041

@@ -319,6 +320,8 @@ static int uverbs_create_cq_handler(struct ib_device *ib_dev,
319320
obj->uobject.object = cq;
320321
obj->uobject.user_handle = user_handle;
321322
atomic_set(&cq->usecnt, 0);
323+
cq->res.type = RDMA_RESTRACK_CQ;
324+
rdma_restrack_add(&cq->res);
322325

323326
ret = uverbs_copy_to(attrs, CREATE_CQ_RESP_CQE, &cq->cqe);
324327
if (ret)

drivers/infiniband/core/verbs.c

+3
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,8 @@ struct ib_cq *ib_create_cq(struct ib_device *device,
15791579
cq->event_handler = event_handler;
15801580
cq->cq_context = cq_context;
15811581
atomic_set(&cq->usecnt, 0);
1582+
cq->res.type = RDMA_RESTRACK_CQ;
1583+
rdma_restrack_add(&cq->res);
15821584
}
15831585

15841586
return cq;
@@ -1597,6 +1599,7 @@ int ib_destroy_cq(struct ib_cq *cq)
15971599
if (atomic_read(&cq->usecnt))
15981600
return -EBUSY;
15991601

1602+
rdma_restrack_del(&cq->res);
16001603
return cq->device->destroy_cq(cq);
16011604
}
16021605
EXPORT_SYMBOL(ib_destroy_cq);

0 commit comments

Comments
 (0)