Hi Thomas, sorry for the delayed reply.
On 5/13/25 11:14, Hellstrom, Thomas wrote: > Hi, Christian > > During eviction we want to be able to evict bos that share the VM's > reservation object but that are currently not bound to the VM since > they are not part of the current working set. > > TTM can't handle this situation since it's not aware of whether a bo is > bound to a VM or not. That's not 100% true. We already have support for something similar for the KFD as well, see function amdgpu_ttm_bo_eviction_valuable(): /* If bo is a KFD BO, check if the bo belongs to the current process. * If true, then return false as any KFD process needs all its BOs to * be resident to run successfully */ dma_resv_for_each_fence(&resv_cursor, bo->base.resv, DMA_RESV_USAGE_BOOKKEEP, f) { if (amdkfd_fence_check_mm(f, current->mm) && !(place->flags & TTM_PL_FLAG_CONTIGUOUS)) return false; } But to be honest I never really liked that approach because it abuses the fact that KFD fences are bound to the struct mm. Additional to that we have a few flags in the context object which allows to evict BOs with the same resv object during object creation. > Do you have a preference of how to address this? One idea would be to > forward the operation ctx to the eviction_valuable callback. Another to > add an "unbound" flag to the bo and an "unbound_only" flag to the > operation ctx. Adding the ctx to the eviction valuable callback sounds like a good approach to me. Regards, Christian. > > Any feedback appreciated. > Thanks, > Thomas > > >