The patch titled mm: make do_move_pages() complexity linear has been added to the -mm tree. Its filename is mm-make-do_move_pages-complexity-linear.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: mm: make do_move_pages() complexity linear From: Brice Goglin <Brice.Goglin@xxxxxxxx> Page migration is currently very slow because its overhead is quadratic with the number of pages. This is caused by each single page migration doing a linear lookup in the page array in new_page_node(). Since pages are stored in the array order in the pagelist and do_move_pages process this list in order, new_page_node() can increase the "pm" pointer to the page array so that the next iteration will find the next page in 0 or few lookup steps. Signed-off-by: Brice Goglin <Brice.Goglin@xxxxxxxx> Signed-off-by: Nathalie Furmento <Nathalie.Furmento@xxxxxxxx> Acked-by: Christoph Lameter <cl@xxxxxxxxxxxxxxxxxxxx> Cc: Mel Gorman <mel@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/migrate.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff -puN mm/migrate.c~mm-make-do_move_pages-complexity-linear mm/migrate.c --- a/mm/migrate.c~mm-make-do_move_pages-complexity-linear +++ a/mm/migrate.c @@ -837,14 +837,23 @@ struct page_to_node { int status; }; +/* + * Allocate a page on the node given as a page_to_node in private. + * Increase private to point to the next page_to_node so that the + * next iteration does not have to traverse the whole pm array. + */ static struct page *new_page_node(struct page *p, unsigned long private, int **result) { - struct page_to_node *pm = (struct page_to_node *)private; + struct page_to_node **pmptr = (struct page_to_node **)private; + struct page_to_node *pm = *pmptr; while (pm->node != MAX_NUMNODES && pm->page != p) pm++; + /* prepare for the next iteration */ + *pmptr = pm + 1; + if (pm->node == MAX_NUMNODES) return NULL; @@ -926,10 +935,12 @@ set_status: pp->status = err; } - if (!list_empty(&pagelist)) + if (!list_empty(&pagelist)) { + /* new_page_node() will modify tmp */ + struct page_to_node *tmp = pm; err = migrate_pages(&pagelist, new_page_node, - (unsigned long)pm); - else + (unsigned long)&tmp); + } else err = -ENOENT; up_read(&mm->mmap_sem); _ Patches currently in -mm which might be from Brice.Goglin@xxxxxxxx are mm-make-do_move_pages-complexity-linear.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html