On Wed, Aug 16, 2023 at 11:49:32PM -0700, Vivek Kasireddy wrote: > For drivers that would like to migrate pages out of the movable > zone (or CMA) in order to pin them (longterm) for DMA, using > check_and_migrate_movable_pages() directly provides a convenient > option instead of duplicating similar checks (e.g, checking > the folios for zone, hugetlb, etc) and calling migrate_pages() > directly. > > Ideally, a driver is expected to call pin_user_pages(FOLL_LONGTERM) > to migrate and pin the pages for longterm DMA but there are > situations where the GUP APIs cannot be used directly for > various reasons (e.g, when the VMA or start addr cannot be > easily determined but the relevant pages are available). No way this should be an exposed API. Please add an API that does the migration and pinning in one useful helper, including one to undo the pin. Then properly document it, and ensure it is a _GPL export.