]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RDMA/restrack: Track ucontext
authorLeon Romanovsky <leonro@mellanox.com>
Wed, 28 Nov 2018 11:16:43 +0000 (13:16 +0200)
committerDoug Ledford <dledford@redhat.com>
Mon, 3 Dec 2018 19:58:25 +0000 (14:58 -0500)
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>
drivers/infiniband/core/restrack.c
include/rdma/ib_verbs.h
include/rdma/restrack.h

index 06d8657ce5834747d32490e7daa21505bbde53f4..3dd316159f5ff6a58b695eae2b716221a233a139 100644 (file)
@@ -32,6 +32,7 @@ static const char *type2str(enum rdma_restrack_type type)
                [RDMA_RESTRACK_QP] = "QP",
                [RDMA_RESTRACK_CM_ID] = "CM_ID",
                [RDMA_RESTRACK_MR] = "MR",
+               [RDMA_RESTRACK_CTX] = "CTX",
        };
 
        return names[type];
@@ -130,6 +131,8 @@ static struct ib_device *res_to_dev(struct rdma_restrack_entry *res)
                                    res)->id.device;
        case RDMA_RESTRACK_MR:
                return container_of(res, struct ib_mr, res)->device;
+       case RDMA_RESTRACK_CTX:
+               return container_of(res, struct ib_ucontext, res)->device;
        default:
                WARN_ONCE(true, "Wrong resource tracking type %u\n", res->type);
                return NULL;
@@ -149,6 +152,8 @@ static bool res_is_user(struct rdma_restrack_entry *res)
                return !res->kern_name;
        case RDMA_RESTRACK_MR:
                return container_of(res, struct ib_mr, res)->pd->uobject;
+       case RDMA_RESTRACK_CTX:
+               return true;
        default:
                WARN_ONCE(true, "Wrong resource tracking type %u\n", res->type);
                return false;
index 92633c15125b180667538fd32a4c977161e8982b..85021451eee0735f3e395c603400bf9d0f34ec8c 100644 (file)
@@ -1505,6 +1505,10 @@ struct ib_ucontext {
 #endif
 
        struct ib_rdmacg_object cg_obj;
+       /*
+        * Implementation details of the RDMA core, don't use in drivers:
+        */
+       struct rdma_restrack_entry res;
 };
 
 struct ib_uobject {
index 2638fa7cd702178afcd1d8bb7a8cdf464d4f2372..f34aa96e451849a06775762c06b30ccdb6893266 100644 (file)
@@ -38,6 +38,10 @@ enum rdma_restrack_type {
         * @RDMA_RESTRACK_MR: Memory Region (MR)
         */
        RDMA_RESTRACK_MR,
+       /**
+        * @RDMA_RESTRACK_CTX: Verbs contexts (CTX)
+        */
+       RDMA_RESTRACK_CTX,
        /**
         * @RDMA_RESTRACK_MAX: Last entry, used for array dclarations
         */