Skip to content

Commit

Permalink
RDMA/restrack: Reduce scope of synchronization lock while updating DB
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Leon Romanovsky authored and Jason Gunthorpe committed Feb 19, 2019
1 parent c5dfe0e commit 4811852
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions drivers/infiniband/core/restrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion include/rdma/restrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down

0 comments on commit 4811852

Please sign in to comment.