Skip to contentSkip to conversation

TTM evicting same-vm bos

DISCUSSION Hellstrom, Thomas 2 participants 2 messages May 13, 2025 – May 16, 2025

lore
Share & tools
lore
#0 lore raw

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.

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.

Any feedback appreciated.
Thanks,
Thomas

#1 lore raw

Hi Thomas,

sorry for the delayed reply.

Quoted 8 lines · Thomas

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.

Quoted 4 lines

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.

Quoted 7 lines

Any feedback appreciated.
Thanks,
Thomas