* + mm-make-do_move_pages-complexity-linear-fix.patch added to -mm tree
@ 2008-10-03 0:23 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2008-10-03 0:23 UTC (permalink / raw)
To: mm-commits; +Cc: Brice.Goglin, Nathalie.Furmento, cl, mel
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-fix.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@inria.fr>
> +/*
> + * 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;
> +
>
Actually, this "pm+1" breaks the case where migrate_pages() calls
unmap_and_move() multiple times on the same page. In this case, we need
the while loop to look at pm instead of pm+1 first. So we can't cache
pm+1 in private, but caching pm is ok. There will be 1 while loop
instead of 0 in the regular case. Updated patch (with more comments)
coming soon.
Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
Signed-off-by: Nathalie Furmento <Nathalie.Furmento@labri.fr>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/migrate.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff -puN mm/migrate.c~mm-make-do_move_pages-complexity-linear-fix mm/migrate.c
--- a/mm/migrate.c~mm-make-do_move_pages-complexity-linear-fix
+++ a/mm/migrate.c
@@ -839,8 +839,14 @@ struct page_to_node {
/*
* 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.
+ *
+ * Cache the _last used_ pm in private so that the next call may find the
+ * target pm in very few while loops (usually 1) instead of scanning the
+ * whole pm array.
+ * We cannot cache the _next_ pm in private (to get 0 while loop in the
+ * regular case) because it would break the case where new_page_node()
+ * is called multiple times on the same page (when migrate_pages() tries
+ * unmap_and_move() multiple times).
*/
static struct page *new_page_node(struct page *p, unsigned long private,
int **result)
@@ -851,8 +857,8 @@ static struct page *new_page_node(struct
while (pm->node != MAX_NUMNODES && pm->page != p)
pm++;
- /* prepare for the next iteration */
- *pmptr = pm + 1;
+ /* save the current pm to reduce the while loop in the next call */
+ *pmptr = pm;
if (pm->node == MAX_NUMNODES)
return NULL;
_
Patches currently in -mm which might be from Brice.Goglin@inria.fr are
mm-make-do_move_pages-complexity-linear.patch
mm-make-do_move_pages-complexity-linear-fix.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-10-03 0:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-03 0:23 + mm-make-do_move_pages-complexity-linear-fix.patch added to -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.