aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMinchan Kim <minchan.kim@gmail.com>2010-10-26 17:21:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 19:52:06 -0400
commitcf608ac19c95804dc2df43b1f4f9e068aa9034ab (patch)
treea84d37df2b0bb57bd9a4b0b466726f5343fa5448
parente4455abb50a19562dbfdc51a8424fda9b588bd6d (diff)
mm: compaction: fix COMPACTPAGEFAILED counting
Presently update_nr_listpages() doesn't have a role. That's because lists passed is always empty just after calling migrate_pages. The migrate_pages cleans up page list which have failed to migrate before returning by aaa994b3. [PATCH] page migration: handle freeing of pages in migrate_pages() Do not leave pages on the lists passed to migrate_pages(). Seems that we will not need any postprocessing of pages. This will simplify the handling of pages by the callers of migrate_pages(). At that time, we thought we don't need any postprocessing of pages. But the situation is changed. The compaction need to know the number of failed to migrate for COMPACTPAGEFAILED stat This patch makes new rule for caller of migrate_pages to call putback_lru_pages. So caller need to clean up the lists so it has a chance to postprocess the pages. [suggested by Christoph Lameter] Signed-off-by: Minchan Kim <minchan.kim@gmail.com> Cc: Hugh Dickins <hughd@google.com> Cc: Andi Kleen <andi@firstfloor.org> Reviewed-by: Mel Gorman <mel@csn.ul.ie> Reviewed-by: Wu Fengguang <fengguang.wu@intel.com> Acked-by: Christoph Lameter <cl@linux.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/memory-failure.c1
-rw-r--r--mm/memory_hotplug.c2
-rw-r--r--mm/mempolicy.c10
-rw-r--r--mm/migrate.c12
4 files changed, 18 insertions, 7 deletions
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 44a8cefeae6e..124324134ff6 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1292,6 +1292,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
1292 list_add(&hpage->lru, &pagelist); 1292 list_add(&hpage->lru, &pagelist);
1293 ret = migrate_huge_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, 0); 1293 ret = migrate_huge_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, 0);
1294 if (ret) { 1294 if (ret) {
1295 putback_lru_pages(&pagelist);
1295 pr_debug("soft offline: %#lx: migration failed %d, type %lx\n", 1296 pr_debug("soft offline: %#lx: migration failed %d, type %lx\n",
1296 pfn, ret, page->flags); 1297 pfn, ret, page->flags);
1297 if (ret > 0) 1298 if (ret > 0)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 06662c5a3e86..4821338b4e4b 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -731,6 +731,8 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
731 goto out; 731 goto out;
732 /* this function returns # of failed pages */ 732 /* this function returns # of failed pages */
733 ret = migrate_pages(&source, hotremove_migrate_alloc, 0, 1); 733 ret = migrate_pages(&source, hotremove_migrate_alloc, 0, 1);
734 if (ret)
735 putback_lru_pages(&source);
734 736
735out: 737out:
736 return ret; 738 return ret;
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index f969da5dd8a2..21243b2b7b07 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -931,8 +931,11 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest,
931 check_range(mm, mm->mmap->vm_start, mm->task_size, &nmask, 931 check_range(mm, mm->mmap->vm_start, mm->task_size, &nmask,
932 flags | MPOL_MF_DISCONTIG_OK, &pagelist); 932 flags | MPOL_MF_DISCONTIG_OK, &pagelist);
933 933
934 if (!list_empty(&pagelist)) 934 if (!list_empty(&pagelist)) {
935 err = migrate_pages(&pagelist, new_node_page, dest, 0); 935 err = migrate_pages(&pagelist, new_node_page, dest, 0);
936 if (err)
937 putback_lru_pages(&pagelist);
938 }
936 939
937 return err; 940 return err;
938} 941}
@@ -1147,9 +1150,12 @@ static long do_mbind(unsigned long start, unsigned long len,
1147 1150
1148 err = mbind_range(mm, start, end, new); 1151 err = mbind_range(mm, start, end, new);
1149 1152
1150 if (!list_empty(&pagelist)) 1153 if (!list_empty(&pagelist)) {
1151 nr_failed = migrate_pages(&pagelist, new_vma_page, 1154 nr_failed = migrate_pages(&pagelist, new_vma_page,
1152 (unsigned long)vma, 0); 1155 (unsigned long)vma, 0);
1156 if (nr_failed)
1157 putback_lru_pages(&pagelist);
1158 }
1153 1159
1154 if (!err && nr_failed && (flags & MPOL_MF_STRICT)) 1160 if (!err && nr_failed && (flags & MPOL_MF_STRICT))
1155 err = -EIO; 1161 err = -EIO;
diff --git a/mm/migrate.c b/mm/migrate.c
index d917ac3207f5..35e454189966 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -883,8 +883,9 @@ out:
883 * 883 *
884 * The function returns after 10 attempts or if no pages 884 * The function returns after 10 attempts or if no pages
885 * are movable anymore because to has become empty 885 * are movable anymore because to has become empty
886 * or no retryable pages exist anymore. All pages will be 886 * or no retryable pages exist anymore.
887 * returned to the LRU or freed. 887 * Caller should call putback_lru_pages to return pages to the LRU
888 * or free list.
888 * 889 *
889 * Return: Number of pages not migrated or error code. 890 * Return: Number of pages not migrated or error code.
890 */ 891 */
@@ -931,8 +932,6 @@ out:
931 if (!swapwrite) 932 if (!swapwrite)
932 current->flags &= ~PF_SWAPWRITE; 933 current->flags &= ~PF_SWAPWRITE;
933 934
934 putback_lru_pages(from);
935
936 if (rc) 935 if (rc)
937 return rc; 936 return rc;
938 937
@@ -1087,9 +1086,12 @@ set_status:
1087 } 1086 }
1088 1087
1089 err = 0; 1088 err = 0;
1090 if (!list_empty(&pagelist)) 1089 if (!list_empty(&pagelist)) {
1091 err = migrate_pages(&pagelist, new_page_node, 1090 err = migrate_pages(&pagelist, new_page_node,
1092 (unsigned long)pm, 0); 1091 (unsigned long)pm, 0);
1092 if (err)
1093 putback_lru_pages(&pagelist);
1094 }
1093 1095
1094 up_read(&mm->mmap_sem); 1096 up_read(&mm->mmap_sem);
1095 return err; 1097 return err;