@@ -1933,8 +1933,7 @@ struct page *get_dump_page(unsigned long addr)
1933
1933
* migration failure.
1934
1934
*/
1935
1935
static long check_and_migrate_movable_pages (unsigned long nr_pages ,
1936
- struct page * * pages ,
1937
- unsigned int gup_flags )
1936
+ struct page * * pages )
1938
1937
{
1939
1938
unsigned long i ;
1940
1939
struct folio * prev_folio = NULL ;
@@ -1967,10 +1966,8 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages,
1967
1966
* Migration will fail if the page is pinned, so convert
1968
1967
* the pin on the source page to a normal reference.
1969
1968
*/
1970
- if (gup_flags & FOLL_PIN ) {
1971
- get_page (& folio -> page );
1972
- unpin_user_page (& folio -> page );
1973
- }
1969
+ get_page (& folio -> page );
1970
+ unpin_user_page (& folio -> page );
1974
1971
1975
1972
if (migrate_device_coherent_page (& folio -> page )) {
1976
1973
ret = - EBUSY ;
@@ -2023,10 +2020,7 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages,
2023
2020
if (!pages [i ])
2024
2021
continue ;
2025
2022
2026
- if (gup_flags & FOLL_PIN )
2027
- unpin_user_page (pages [i ]);
2028
- else
2029
- put_page (pages [i ]);
2023
+ unpin_user_page (pages [i ]);
2030
2024
}
2031
2025
2032
2026
if (!list_empty (& movable_page_list )) {
@@ -2049,8 +2043,7 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages,
2049
2043
}
2050
2044
#else
2051
2045
static long check_and_migrate_movable_pages (unsigned long nr_pages ,
2052
- struct page * * pages ,
2053
- unsigned int gup_flags )
2046
+ struct page * * pages )
2054
2047
{
2055
2048
return 0 ;
2056
2049
}
@@ -2073,6 +2066,9 @@ static long __gup_longterm_locked(struct mm_struct *mm,
2073
2066
if (!(gup_flags & FOLL_LONGTERM ))
2074
2067
return __get_user_pages_locked (mm , start , nr_pages , pages , vmas ,
2075
2068
NULL , gup_flags );
2069
+ /* check_and_migrate_movable_pages() assumes pages have been pinned. */
2070
+ if (WARN_ON (!(gup_flags & FOLL_PIN )))
2071
+ return - EINVAL ;
2076
2072
flags = memalloc_pin_save ();
2077
2073
do {
2078
2074
nr_pinned_pages = __get_user_pages_locked (mm , start , nr_pages ,
@@ -2082,8 +2078,7 @@ static long __gup_longterm_locked(struct mm_struct *mm,
2082
2078
rc = nr_pinned_pages ;
2083
2079
break ;
2084
2080
}
2085
- rc = check_and_migrate_movable_pages (nr_pinned_pages , pages ,
2086
- gup_flags );
2081
+ rc = check_and_migrate_movable_pages (nr_pinned_pages , pages );
2087
2082
} while (rc == - EAGAIN );
2088
2083
memalloc_pin_restore (flags );
2089
2084
0 commit comments