Browse Source

[PATCH] 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 check for available swap
and fail with -ENODEV if no swap space is available.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Christoph Lameter 19 năm trước cách đây
mục cha
commit
90036ee593
1 tập tin đã thay đổi với 12 bổ sung2 xóa
  1. 12 2
      mm/mempolicy.c

+ 12 - 2
mm/mempolicy.c

@@ -330,9 +330,19 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
 	int err;
 	int err;
 	struct vm_area_struct *first, *vma, *prev;
 	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();
 		lru_add_drain_all();
+	}
 
 
 	first = find_vma(mm, start);
 	first = find_vma(mm, start);
 	if (!first)
 	if (!first)