Skip to content

Commit 6061521

Browse files
Leon Romanovskydledford
authored andcommitted
RDMA/restrack: Track ucontext
Add ability to track allocated ib_ucontext, which are limited resource and worth to be visible by users. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 61d6952 commit 6061521

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

drivers/infiniband/core/restrack.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static const char *type2str(enum rdma_restrack_type type)
3232
[RDMA_RESTRACK_QP] = "QP",
3333
[RDMA_RESTRACK_CM_ID] = "CM_ID",
3434
[RDMA_RESTRACK_MR] = "MR",
35+
[RDMA_RESTRACK_CTX] = "CTX",
3536
};
3637

3738
return names[type];
@@ -130,6 +131,8 @@ static struct ib_device *res_to_dev(struct rdma_restrack_entry *res)
130131
res)->id.device;
131132
case RDMA_RESTRACK_MR:
132133
return container_of(res, struct ib_mr, res)->device;
134+
case RDMA_RESTRACK_CTX:
135+
return container_of(res, struct ib_ucontext, res)->device;
133136
default:
134137
WARN_ONCE(true, "Wrong resource tracking type %u\n", res->type);
135138
return NULL;
@@ -149,6 +152,8 @@ static bool res_is_user(struct rdma_restrack_entry *res)
149152
return !res->kern_name;
150153
case RDMA_RESTRACK_MR:
151154
return container_of(res, struct ib_mr, res)->pd->uobject;
155+
case RDMA_RESTRACK_CTX:
156+
return true;
152157
default:
153158
WARN_ONCE(true, "Wrong resource tracking type %u\n", res->type);
154159
return false;

include/rdma/ib_verbs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,10 @@ struct ib_ucontext {
15051505
#endif
15061506

15071507
struct ib_rdmacg_object cg_obj;
1508+
/*
1509+
* Implementation details of the RDMA core, don't use in drivers:
1510+
*/
1511+
struct rdma_restrack_entry res;
15081512
};
15091513

15101514
struct ib_uobject {

include/rdma/restrack.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ enum rdma_restrack_type {
3838
* @RDMA_RESTRACK_MR: Memory Region (MR)
3939
*/
4040
RDMA_RESTRACK_MR,
41+
/**
42+
* @RDMA_RESTRACK_CTX: Verbs contexts (CTX)
43+
*/
44+
RDMA_RESTRACK_CTX,
4145
/**
4246
* @RDMA_RESTRACK_MAX: Last entry, used for array dclarations
4347
*/

0 commit comments

Comments
 (0)