]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RDMA/restrack: Reduce scope of synchronization lock while updating DB
authorLeon Romanovsky <leonro@mellanox.com>
Mon, 18 Feb 2019 20:25:46 +0000 (22:25 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 19 Feb 2019 04:04:36 +0000 (21:04 -0700)
XArray uses internal lock for updates to XArray. This means that our
external RW lock is needed to ensure that entry is not deleted while we
are performing iteration over list.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/restrack.c
include/rdma/restrack.h

index ac97167da81c720ed4574c9f3a4c03769db7740b..076ef6475df8a39f69914d2139700145adf1f4e2 100644 (file)
@@ -210,13 +210,11 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res)
        kref_init(&res->kref);
        init_completion(&res->comp);
 
-       down_write(&dev->res.rwsem);
        ret = rt_xa_alloc_cyclic(&dev->res.xa[res->type], &res->id, res,
                                 &dev->res.next_id[res->type]);
 
        if (!ret)
                res->valid = true;
-       up_write(&dev->res.rwsem);
 }
 
 /**
index 44ce32cc0b518943af47451100efab2b253f454a..53e1a7fb735530e387b1c1dfb6470fb62743e942 100644 (file)
@@ -58,7 +58,8 @@ struct rdma_restrack_entry;
  */
 struct rdma_restrack_root {
        /*
-        * @rwsem: Read/write lock to protect lists
+        * @rwsem: Read/write lock to protect erase of entry.
+        * Lists and insertions are protected by XArray internal lock.
         */
        struct rw_semaphore     rwsem;
        /**