diff mbox series

[rdma-next,v1,09/16] RDMA/restrack: Reduce scope of synchronization lock while updating DB

Message ID 20190116115918.4125-10-leon@kernel.org (mailing list archive)
State Superseded
Headers show
Series Provide per-ID access to restrack objects | expand

Commit Message

Leon Romanovsky Jan. 16, 2019, 11:59 a.m. UTC
From: Leon Romanovsky <leonro@mellanox.com>

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 iteration over list.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/core/restrack.c | 2 --
 include/rdma/restrack.h            | 3 ++-
 2 files changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c
index 7515425fc0fd..3176a95662b9 100644
--- a/drivers/infiniband/core/restrack.c
+++ b/drivers/infiniband/core/restrack.c
@@ -224,14 +224,12 @@  static void rdma_restrack_add(struct rdma_restrack_entry *res)
 	init_completion(&res->comp);
 	res->valid = true;
 
-	down_write(&dev->res.rwsem);
 	id = res_to_id(res);
 	ret = xa_insert(&dev->res.xa[res->type], id, res, GFP_KERNEL);
 	WARN_ONCE(ret == -EEXIST, "Tried to add non-unique type %d entry\n",
 		  res->type);
 	if (ret)
 		res->valid = false;
-	up_write(&dev->res.rwsem);
 }
 
 /**
diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h
index 375ff8fb65e7..ed00b660b041 100644
--- a/include/rdma/restrack.h
+++ b/include/rdma/restrack.h
@@ -58,7 +58,8 @@  struct rdma_restrack_entry;
  */
 struct rdma_restrack_root {
 	/*
-	 * @rwsem: Read/write lock to protect lists and IDR
+	 * @rwsem: Read/write lock to protect erase of entry.
+	 * Lists and insertions are protected by XArray internal lock.
 	 */
 	struct rw_semaphore	rwsem;
 	/**