> From: linux-rdma-owner@xxxxxxxxxxxxxxx <linux-rdma- > owner@xxxxxxxxxxxxxxx> On Behalf Of Michal Kalderon > > > From: Gal Pressman <galpress@xxxxxxxxxx> > > Sent: Thursday, August 22, 2019 11:35 AM > > > > On 20/08/2019 15:18, Michal Kalderon wrote: > > > > > > > +void rdma_user_mmap_entry_free(struct kref *kref) { > > > + struct rdma_user_mmap_entry *entry = > > > + container_of(kref, struct rdma_user_mmap_entry, ref); > > > + unsigned long i, npages = (u32)DIV_ROUND_UP(entry->length, > > PAGE_SIZE); > > > + struct ib_ucontext *ucontext = entry->ucontext; > > > + > > > + /* need to erase all entries occupied... */ > > > + for (i = 0; i < npages; i++) { > > > + xa_erase(&ucontext->mmap_xa, entry->mmap_page + i); > > > + > > > + ibdev_dbg(ucontext->device, > > > + "mmap: obj[0x%p] key[%#llx] addr[%#llx] len[%#llx] > > npages[%#lx] removed\n", > > > + entry->obj, rdma_user_mmap_get_key(entry), > > > + entry->address, entry->length, npages); > > > + > > > + if (ucontext->device->ops.mmap_free) > > > + ucontext->device->ops.mmap_free(entry); > > > + } > > > > Should this loop be surrounded with a lock? What happens with > > concurrent insertions? > This is a good point, thanks for catching it. Gal, after revisiting this, I think there is no need for a lock, the xa_erase is safe When run concurrently with the insertions under xa_lock, and if an entry is erased During the insert there is no harm. Thanks, Michal > > >