@@ -1997,32 +1997,20 @@ static struct page *alloc_misplaced_dst_page(struct page *page,
19971997 unsigned long data )
19981998{
19991999 int nid = (int ) data ;
2000- struct page * newpage ;
2001-
2002- newpage = __alloc_pages_node (nid ,
2003- (GFP_HIGHUSER_MOVABLE |
2004- __GFP_THISNODE | __GFP_NOMEMALLOC |
2005- __GFP_NORETRY | __GFP_NOWARN ) &
2006- ~__GFP_RECLAIM , 0 );
2007-
2008- return newpage ;
2009- }
2010-
2011- static struct page * alloc_misplaced_dst_page_thp (struct page * page ,
2012- unsigned long data )
2013- {
2014- int nid = (int ) data ;
2015- struct page * newpage ;
2016-
2017- newpage = alloc_pages_node (nid , (GFP_TRANSHUGE_LIGHT | __GFP_THISNODE ),
2018- HPAGE_PMD_ORDER );
2019- if (!newpage )
2020- goto out ;
2021-
2022- prep_transhuge_page (newpage );
2000+ int order = compound_order (page );
2001+ gfp_t gfp = __GFP_THISNODE ;
2002+ struct folio * new ;
2003+
2004+ if (order > 0 )
2005+ gfp |= GFP_TRANSHUGE_LIGHT ;
2006+ else {
2007+ gfp |= GFP_HIGHUSER_MOVABLE | __GFP_NOMEMALLOC | __GFP_NORETRY |
2008+ __GFP_NOWARN ;
2009+ gfp &= ~__GFP_RECLAIM ;
2010+ }
2011+ new = __folio_alloc_node (gfp , order , nid );
20232012
2024- out :
2025- return newpage ;
2013+ return & new -> page ;
20262014}
20272015
20282016static int numamigrate_isolate_page (pg_data_t * pgdat , struct page * page )
@@ -2080,22 +2068,8 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma,
20802068 int nr_remaining ;
20812069 unsigned int nr_succeeded ;
20822070 LIST_HEAD (migratepages );
2083- new_page_t * new ;
2084- bool compound ;
20852071 int nr_pages = thp_nr_pages (page );
20862072
2087- /*
2088- * PTE mapped THP or HugeTLB page can't reach here so the page could
2089- * be either base page or THP. And it must be head page if it is
2090- * THP.
2091- */
2092- compound = PageTransHuge (page );
2093-
2094- if (compound )
2095- new = alloc_misplaced_dst_page_thp ;
2096- else
2097- new = alloc_misplaced_dst_page ;
2098-
20992073 /*
21002074 * Don't migrate file pages that are mapped in multiple processes
21012075 * with execute permissions as they are probably shared libraries.
@@ -2116,9 +2090,9 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma,
21162090 goto out ;
21172091
21182092 list_add (& page -> lru , & migratepages );
2119- nr_remaining = migrate_pages (& migratepages , * new , NULL , node ,
2120- MIGRATE_ASYNC , MR_NUMA_MISPLACED ,
2121- & nr_succeeded );
2093+ nr_remaining = migrate_pages (& migratepages , alloc_misplaced_dst_page ,
2094+ NULL , node , MIGRATE_ASYNC ,
2095+ MR_NUMA_MISPLACED , & nr_succeeded );
21222096 if (nr_remaining ) {
21232097 if (!list_empty (& migratepages )) {
21242098 list_del (& page -> lru );
0 commit comments