On 09-Jan-19 02:05, Jason Gunthorpe wrote: > >> This can be solved by freeing the PDs on dealloc_ucontext time which >> will guarantee that no other process will get the same BAR pages. > > Depends on the implementation. > > What is coming next is 'shared pd' which will allow the PD HW object > to be pointed at by multiple different ucontext's. (this is another > reason why you can't really remove the mmap cookie on first use, as to > make a correct driver for shared-PD the sharing flow will have to > re-mmap the BAR pages, presumably.) > > The implementation of deferred destroy would need to very carefully > handle this. In case of a shared PD, are the different ucontexts expected to share the same BAR pages? Sounds like a PD reference count will be needed in order to free it on last using ucontext dealloc. We can also just fail mmaps for pages that are still used by a different ucontext instead of deferring the PD deallocation. Is there a way to notify the driver of munmaps? instead of waiting for dealloc_ucontext?