Re: page migration: Fail with error if swap not setup

Christoph Lameter
2006-03-15T03:53:22Z

On Tue, 14 Mar 2006, Andrew Morton wrote:

> > lru_add_drain_all();
> > + }
> >
>
> Whereas this appears to be racy...

Migration just makes the best effort. Page that are moved off the LRU
after the draining end up on the failed migration list and will not be
migrated.

Sorry about the blank. New patch with more explanations?

page migration: Fail with error if swap not setup

Currently the migration of anonymous pages will silently fail if no
swap is setup. This patch makes page migration functions to check
for available swap and fail with -ENODEV if no swap space is available.

Signed-off-by: Christoph Lameter <clameter@sgi.com>

Index: linux-2.6.16-rc6/mm/mempolicy.c
===================================================================
--- linux-2.6.16-rc6.orig/mm/mempolicy.c 2006-03-14 16:31:15.000000000 -0800
+++ linux-2.6.16-rc6/mm/mempolicy.c 2006-03-14 19:52:25.000000000 -0800
@@ -330,9 +330,19 @@ check_range(struct mm_struct *mm, unsign
int err;
struct vm_area_struct *first, *vma, *prev;

- /* Clear the LRU lists so pages can be isolated */
- if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))
+ if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) {
+ /* Must have swap device for migration */
+ if (nr_swap_pages <= 0)
+ return ERR_PTR(-ENODEV);
+
+ /*
+ * Clear the LRU lists so pages can be isolated.
+ * Note that pages may be moved off the LRU after we have
+ * drained them. Those pages will fail to migrate like other
+ * pages that may be busy.
+ */
lru_add_drain_all();
+ }

first = find_vma(mm, start);
if (!first)