Skip to content

Commit 203e6e5

Browse files
JoonsooKimtorvalds
authored andcommitted
mm/memory_hotplug: remove a wrapper for alloc_migration_target()
To calculate the correct node to migrate the page for hotplug, we need to check node id of the page. Wrapper for alloc_migration_target() exists for this purpose. However, Vlastimil informs that all migration source pages come from a single node. In this case, we don't need to check the node id for each page and we don't need to re-set the target nodemask for each page by using the wrapper. Set up the migration_target_control once and use it for all pages. Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Roman Gushchin <guro@fb.com> Link: http://lkml.kernel.org/r/1594622517-20681-10-git-send-email-iamjoonsoo.kim@lge.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5460875 commit 203e6e5

1 file changed

Lines changed: 22 additions & 24 deletions

File tree

‎mm/memory_hotplug.c‎

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,27 +1290,6 @@ static int scan_movable_pages(unsigned long start, unsigned long end,
12901290
return 0;
12911291
}
12921292

1293-
static struct page *new_node_page(struct page *page, unsigned long private)
1294-
{
1295-
nodemask_t nmask = node_states[N_MEMORY];
1296-
struct migration_target_control mtc = {
1297-
.nid = page_to_nid(page),
1298-
.nmask = &nmask,
1299-
.gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
1300-
};
1301-
1302-
/*
1303-
* try to allocate from a different node but reuse this node if there
1304-
* are no other online nodes to be used (e.g. we are offlining a part
1305-
* of the only existing node)
1306-
*/
1307-
node_clear(mtc.nid, nmask);
1308-
if (nodes_empty(nmask))
1309-
node_set(mtc.nid, nmask);
1310-
1311-
return alloc_migration_target(page, (unsigned long)&mtc);
1312-
}
1313-
13141293
static int
13151294
do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
13161295
{
@@ -1370,9 +1349,28 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
13701349
put_page(page);
13711350
}
13721351
if (!list_empty(&source)) {
1373-
/* Allocate a new page from the nearest neighbor node */
1374-
ret = migrate_pages(&source, new_node_page, NULL, 0,
1375-
MIGRATE_SYNC, MR_MEMORY_HOTPLUG);
1352+
nodemask_t nmask = node_states[N_MEMORY];
1353+
struct migration_target_control mtc = {
1354+
.nmask = &nmask,
1355+
.gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
1356+
};
1357+
1358+
/*
1359+
* We have checked that migration range is on a single zone so
1360+
* we can use the nid of the first page to all the others.
1361+
*/
1362+
mtc.nid = page_to_nid(list_first_entry(&source, struct page, lru));
1363+
1364+
/*
1365+
* try to allocate from a different node but reuse this node
1366+
* if there are no other online nodes to be used (e.g. we are
1367+
* offlining a part of the only existing node)
1368+
*/
1369+
node_clear(mtc.nid, nmask);
1370+
if (nodes_empty(nmask))
1371+
node_set(mtc.nid, nmask);
1372+
ret = migrate_pages(&source, alloc_migration_target, NULL,
1373+
(unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_HOTPLUG);
13761374
if (ret) {
13771375
list_for_each_entry(page, &source, lru) {
13781376
pr_warn("migrating pfn %lx failed ret:%d ",

0 commit comments

Comments
 (0)