Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/restrack: Reduce scope of synchronization lock while updating DB

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>

authored by

Leon Romanovsky and committed by
Jason Gunthorpe
48118527 c5dfe0ea

+2 -3
-2
drivers/infiniband/core/restrack.c
··· 210 210 kref_init(&res->kref); 211 211 init_completion(&res->comp); 212 212 213 - down_write(&dev->res.rwsem); 214 213 ret = rt_xa_alloc_cyclic(&dev->res.xa[res->type], &res->id, res, 215 214 &dev->res.next_id[res->type]); 216 215 217 216 if (!ret) 218 217 res->valid = true; 219 - up_write(&dev->res.rwsem); 220 218 } 221 219 222 220 /**
+2 -1
include/rdma/restrack.h
··· 58 58 */ 59 59 struct rdma_restrack_root { 60 60 /* 61 - * @rwsem: Read/write lock to protect lists 61 + * @rwsem: Read/write lock to protect erase of entry. 62 + * Lists and insertions are protected by XArray internal lock. 62 63 */ 63 64 struct rw_semaphore rwsem; 64 65 /**