On 26/07/2019 16:23, Jason Gunthorpe wrote: > On Fri, Jul 26, 2019 at 08:42:07AM +0000, Michal Kalderon wrote: > >>>> But we don't free entires from the xa_array ( only when ucontext is >>>> destroyed) so how will There be an empty element after we wrap ? >>> >>> Oh! >>> >>> That should be fixed up too, in the general case if a user is >>> creating/destroying driver objects in loop we don't want memory usage to >>> be unbounded. >>> >>> The rdma_user_mmap stuff has VMA ops that can refcount the xa entry and >>> now that this is core code it is easy enough to harmonize the two things and >>> track the xa side from the struct rdma_umap_priv >>> >>> The question is, does EFA or qedr have a use model for this that allows a >>> userspace verb to create/destroy in a loop? ie do we need to fix this right >>> now? > >> The mapping occurs for every qp and cq creation. So yes. >> >> So do you mean add a ref-cnt to the xarray entry and from umap >> decrease the refcnt and free? > > Yes, free the entry (release the HW resource) and release the xa_array > ID. This is a bit tricky for EFA. The UAR BAR resources (LLQ for example) aren't cleaned up until the UAR is deallocated, so many of the entries won't really be freed when the refcount reaches zero (i.e the HW considers these entries as refcounted as long as the UAR exists). The best we can do is free the DMA buffers for appropriate entries.