[PATCH for-mm 2/2] mm/gup: Make migrate_device_page() fails always if !CONFIG_DEVICE_PRIVATE

From: SeongJae Park
Date: Wed Feb 09 2022 - 04:46:03 EST


Commit 7059ac82be44 ("mm/gup.c: migrate device coherent pages when
pinning instead of failing") in -mm tree[1] introduces
'migrate_device_page()', which uses several functions that defined under
CONFIG_DEVICE_RIVATE. As a result, build under 'CONFIG_MIGRATION &&
!CONFIG_DEVICE_PRIVATE' fails as below.

LD .tmp_vmlinux.kallsyms1
mm/gup.o: In function `migrate_device_page':
/linux/mm/gup.c:1856: undefined reference to `migrate_vma_setup'
/linux/mm/gup.c:1876: undefined reference to `migrate_vma_pages'
/linux/mm/gup.c:1879: undefined reference to `migrate_vma_finalize'
/linux/Makefile:1222: recipe for target 'vmlinux' failed
make[1]: *** [vmlinux] Error 1

This commit fixes it by implementing an always-failing version of the
function for !CONFIG_DEVICE_PRIVATE'.

[1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-gupc-migrate-device-coherent-pages-when-pinning-instead-of-failing.patch

Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
mm/gup.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/mm/gup.c b/mm/gup.c
index 1df99a5e90cf..0cf59858114d 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1834,6 +1834,7 @@ struct page *get_dump_page(unsigned long addr)
#endif /* CONFIG_ELF_CORE */

#ifdef CONFIG_MIGRATION
+#ifdef CONFIG_DEVICE_PRIVATE
/*
* Migrates a device coherent page back to normal memory. Caller should have a
* reference on page which will be copied to the new page if migration is
@@ -1887,6 +1888,14 @@ static struct page *migrate_device_page(struct page *page,

return dpage;
}
+#else
+static inline struct page *migrate_device_page(struct page *page,
+ unsigned int gup_flags)
+{
+ return NULL;
+}
+#endif /* CONFIG_DEVICE_PRIVATE */
+

/*
* Check whether all pages are pinnable, if so return number of pages. If some
--
2.17.1