Skip to content
Snippets Groups Projects
Forked from drm / msm
Source project has a limited visibility.
  • Alistair Popple's avatar
    e778406b
    mm/migrate_device.c: add migrate_device_range() · e778406b
    Alistair Popple authored
    Device drivers can use the migrate_vma family of functions to migrate
    existing private anonymous mappings to device private pages.  These pages
    are backed by memory on the device with drivers being responsible for
    copying data to and from device memory.
    
    Device private pages are freed via the pgmap->page_free() callback when
    they are unmapped and their refcount drops to zero.  Alternatively they
    may be freed indirectly via migration back to CPU memory in response to a
    pgmap->migrate_to_ram() callback called whenever the CPU accesses an
    address mapped to a device private page.
    
    In other words drivers cannot control the lifetime of data allocated on
    the devices and must wait until these pages are freed from userspace. 
    This causes issues when memory needs to reclaimed on the device, either
    because the device is going away due to a ->release() callback or because
    another user needs to use the memory.
    
    Drivers could use the existing migrate_vma functions to migrate data off
    the device.  However this would require them to track the mappings of each
    page which is both complicated and not always possible.  Instead drivers
    need to be able to migrate device pages directly so they can free up
    device memory.
    
    To allow that this patch introduces the migrate_device family of functions
    which are functionally similar to migrate_vma but which skips the initial
    lookup based on mapping.
    
    Link: https://lkml.kernel.org/r/868116aab70b0c8ee467d62498bb2cf0ef907295.1664366292.git-series.apopple@nvidia.com
    
    
    Signed-off-by: default avatarAlistair Popple <apopple@nvidia.com>
    Cc: "Huang, Ying" <ying.huang@intel.com>
    Cc: Zi Yan <ziy@nvidia.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Yang Shi <shy828301@gmail.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Ralph Campbell <rcampbell@nvidia.com>
    Cc: John Hubbard <jhubbard@nvidia.com>
    Cc: Alex Deucher <alexander.deucher@amd.com>
    Cc: Alex Sierra <alex.sierra@amd.com>
    Cc: Ben Skeggs <bskeggs@redhat.com>
    Cc: Christian König <christian.koenig@amd.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Cc: Felix Kuehling <Felix.Kuehling@amd.com>
    Cc: Jason Gunthorpe <jgg@nvidia.com>
    Cc: Lyude Paul <lyude@redhat.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    e778406b
    History
    mm/migrate_device.c: add migrate_device_range()
    Alistair Popple authored
    Device drivers can use the migrate_vma family of functions to migrate
    existing private anonymous mappings to device private pages.  These pages
    are backed by memory on the device with drivers being responsible for
    copying data to and from device memory.
    
    Device private pages are freed via the pgmap->page_free() callback when
    they are unmapped and their refcount drops to zero.  Alternatively they
    may be freed indirectly via migration back to CPU memory in response to a
    pgmap->migrate_to_ram() callback called whenever the CPU accesses an
    address mapped to a device private page.
    
    In other words drivers cannot control the lifetime of data allocated on
    the devices and must wait until these pages are freed from userspace. 
    This causes issues when memory needs to reclaimed on the device, either
    because the device is going away due to a ->release() callback or because
    another user needs to use the memory.
    
    Drivers could use the existing migrate_vma functions to migrate data off
    the device.  However this would require them to track the mappings of each
    page which is both complicated and not always possible.  Instead drivers
    need to be able to migrate device pages directly so they can free up
    device memory.
    
    To allow that this patch introduces the migrate_device family of functions
    which are functionally similar to migrate_vma but which skips the initial
    lookup based on mapping.
    
    Link: https://lkml.kernel.org/r/868116aab70b0c8ee467d62498bb2cf0ef907295.1664366292.git-series.apopple@nvidia.com
    
    
    Signed-off-by: default avatarAlistair Popple <apopple@nvidia.com>
    Cc: "Huang, Ying" <ying.huang@intel.com>
    Cc: Zi Yan <ziy@nvidia.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Yang Shi <shy828301@gmail.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Ralph Campbell <rcampbell@nvidia.com>
    Cc: John Hubbard <jhubbard@nvidia.com>
    Cc: Alex Deucher <alexander.deucher@amd.com>
    Cc: Alex Sierra <alex.sierra@amd.com>
    Cc: Ben Skeggs <bskeggs@redhat.com>
    Cc: Christian König <christian.koenig@amd.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Cc: Felix Kuehling <Felix.Kuehling@amd.com>
    Cc: Jason Gunthorpe <jgg@nvidia.com>
    Cc: Lyude Paul <lyude@redhat.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>