All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix do_move_pages_to_node() error handling
@ 2018-11-14  0:40 p.jaroszynski
  2018-11-14  7:34 ` Michal Hocko
  0 siblings, 1 reply; 9+ messages in thread
From: p.jaroszynski @ 2018-11-14  0:40 UTC (permalink / raw)
  To: Michal Hocko; +Cc: linux-mm, Piotr Jaroszynski

From: Piotr Jaroszynski <pjaroszynski@nvidia.com>

migrate_pages() can return the number of pages that failed to migrate
instead of 0 or an error code. If that happens, the positive return is
treated as an error all the way up through the stack leading to the
move_pages() syscall returning a positive number. I believe this
regressed with commit a49bd4d71637 ("mm, numa: rework do_pages_move")
that refactored a lot of this code.

Fix this by treating positive returns as success in
do_move_pages_to_node() as that seems to most closely follow the
previous code. This still leaves the question whether silently
considering this case a success is the right thing to do as even the
status of the pages will be set as if they were successfully migrated,
but that seems to have been the case before as well.

Fixes: a49bd4d71637 ("mm, numa: rework do_pages_move")
Signed-off-by: Piotr Jaroszynski <pjaroszynski@nvidia.com>
---
 mm/migrate.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/mm/migrate.c b/mm/migrate.c
index 8baeb7ff2f6d..b42efef780d6 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1461,6 +1461,7 @@ static int store_status(int __user *status, int start, int value, int nr)
 	return 0;
 }
 
+/* Returns 0 or an error code. */
 static int do_move_pages_to_node(struct mm_struct *mm,
 		struct list_head *pagelist, int node)
 {
@@ -1473,6 +1474,15 @@ static int do_move_pages_to_node(struct mm_struct *mm,
 			MIGRATE_SYNC, MR_SYSCALL);
 	if (err)
 		putback_movable_pages(pagelist);
+
+	/*
+	 * migrate_pages() can return the number of not migrated pages, but the
+	 * callers of do_move_pages_to_node() only care about and handle hard
+	 * failures.
+	 */
+	if (err > 0)
+		err = 0;
+
 	return err;
 }
 
-- 
2.11.0.262.g4b0a5b2.dirty

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-11-16 11:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-14  0:40 [PATCH] Fix do_move_pages_to_node() error handling p.jaroszynski
2018-11-14  7:34 ` Michal Hocko
2018-11-14 11:29   ` Michal Hocko
2018-11-14 18:04     ` Piotr Jaroszynski
2018-11-14 21:22       ` Michal Hocko
2018-11-15  1:04         ` Piotr Jaroszynski
2018-11-15  8:47           ` Michal Hocko
2018-11-15 18:58             ` Piotr Jaroszynski
2018-11-16 11:49               ` Michal Hocko

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.