Skip to content

Commit 9d5f8c2

Browse files
Leon Romanovskyjgunthorpe
authored andcommitted
RDMA/core: Add resource tracking for create and destroy PDs
Track create and destroy operations of PD objects. Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Reviewed-by: Steve Wise <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 08f294a commit 9d5f8c2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
340340
uobj->object = pd;
341341
memset(&resp, 0, sizeof resp);
342342
resp.pd_handle = uobj->id;
343+
pd->res.type = RDMA_RESTRACK_PD;
344+
rdma_restrack_add(&pd->res);
343345

344346
if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp)) {
345347
ret = -EFAULT;

drivers/infiniband/core/verbs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags,
263263
mr_access_flags |= IB_ACCESS_REMOTE_READ | IB_ACCESS_REMOTE_WRITE;
264264
}
265265

266+
pd->res.type = RDMA_RESTRACK_PD;
267+
pd->res.kern_name = caller;
268+
rdma_restrack_add(&pd->res);
269+
266270
if (mr_access_flags) {
267271
struct ib_mr *mr;
268272

@@ -312,6 +316,7 @@ void ib_dealloc_pd(struct ib_pd *pd)
312316
requires the caller to guarantee we can't race here. */
313317
WARN_ON(atomic_read(&pd->usecnt));
314318

319+
rdma_restrack_del(&pd->res);
315320
/* Making delalloc_pd a void return is a WIP, no driver should return
316321
an error here. */
317322
ret = pd->device->dealloc_pd(pd);

0 commit comments

Comments
 (0)