• Matthew Auld's avatar
    drm/i915/ttm: add tt shmem backend · 7ae03459
    Matthew Auld authored
    For cached objects we can allocate our pages directly in shmem. This
    should make it possible(in a later patch) to utilise the existing
    i915-gem shrinker code for such objects. For now this is still disabled.
    
    v2(Thomas):
      - Add optional try_to_writeback hook for objects. Importantly we need
        to check if the object is even still shrinkable; in between us
        dropping the shrinker LRU lock and acquiring the object lock it could for
        example have been moved. Also we need to differentiate between
        "lazy" shrinking and the immediate writeback mode. Also later we need to
        handle objects which don't even have mm.pages, so bundling this into
        put_pages() would require somehow handling that edge case, hence
        just letting the ttm backend handle everything in try_to_writeback
        doesn't seem too bad.
    v3(Thomas):
      - Likely a bad idea to touch the object from the unpopulate hook,
        since it's not possible to hold a reference, without also creating
        circular dependency, so likely this is too fragile. For now just
        ensure we at least mark the pages as dirty/accessed when called from the
        shrinker on WILLNEED objects.
      - s/try_to_writeback/shrinker_release_pages, since this can do more
        than just writeback.
      - Get rid of do_backup boolean and just set the SWAPPED flag prior to
        calling unpopulate.
      - Keep shmem_tt as lowest priority for the TTM LRU bo_swapout walk, since
        these just get skipped anyway. We can try to come up with something
        better later.
    v4(Thomas):
      - s/PCI_DMA/DMA/. Also drop NO_KERNEL_MAPPING and NO_WARN, which
        apparently doesn't do anything with streaming mappings.
      - Just pass along the error for ->truncate, and assume nothing.
    Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
    Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Cc: Christian König <christian.koenig@amd.com>
    Cc: Oak Zeng <oak.zeng@intel.com>
    Reviewed-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
    Acked-by: default avatarOak Zeng <oak.zeng@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211018091055.1998191-2-matthew.auld@intel.com
    7ae03459
i915_gem_shmem.c 17.2 KB