2 * Memory Migration functionality - linux/mm/migration.c
4 * Copyright (C) 2006 Silicon Graphics, Inc., Christoph Lameter
6 * Page migration was first developed in the context of the memory hotplug
7 * project. The main authors of the migration code are:
9 * IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
10 * Hirokazu Takahashi <taka@valinux.co.jp>
11 * Dave Hansen <haveblue@us.ibm.com>
15 #include <linux/migrate.h>
16 #include <linux/module.h>
17 #include <linux/swap.h>
18 #include <linux/swapops.h>
19 #include <linux/pagemap.h>
20 #include <linux/buffer_head.h>
21 #include <linux/mm_inline.h>
22 #include <linux/nsproxy.h>
23 #include <linux/pagevec.h>
24 #include <linux/ksm.h>
25 #include <linux/rmap.h>
26 #include <linux/topology.h>
27 #include <linux/cpu.h>
28 #include <linux/cpuset.h>
29 #include <linux/writeback.h>
30 #include <linux/mempolicy.h>
31 #include <linux/vmalloc.h>
32 #include <linux/security.h>
33 #include <linux/memcontrol.h>
34 #include <linux/syscalls.h>
35 #include <linux/gfp.h>
39 #define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
42 * migrate_prep() needs to be called before we start compiling a list of pages
43 * to be migrated using isolate_lru_page(). If scheduling work on other CPUs is
44 * undesirable, use migrate_prep_local()
46 int migrate_prep(void)
49 * Clear the LRU lists so pages can be isolated.
50 * Note that pages may be moved off the LRU after we have
51 * drained them. Those pages will fail to migrate like other
52 * pages that may be busy.
59 /* Do the necessary work of migrate_prep but not if it involves other CPUs */
60 int migrate_prep_local(void)
68 * Add isolated pages on the list back to the LRU under page lock
69 * to avoid leaking evictable pages back onto unevictable list.
71 void putback_lru_pages(struct list_head *l)
76 list_for_each_entry_safe(page, page2, l, lru) {
78 dec_zone_page_state(page, NR_ISOLATED_ANON +
79 page_is_file_cache(page));
80 putback_lru_page(page);
85 * Restore a potential migration pte to a working pte entry
87 static int remove_migration_pte(struct page *new, struct vm_area_struct *vma,
88 unsigned long addr, void *old)
90 struct mm_struct *mm = vma->vm_mm;
98 pgd = pgd_offset(mm, addr);
99 if (!pgd_present(*pgd))
102 pud = pud_offset(pgd, addr);
103 if (!pud_present(*pud))
106 pmd = pmd_offset(pud, addr);
107 if (!pmd_present(*pmd))
110 ptep = pte_offset_map(pmd, addr);
112 if (!is_swap_pte(*ptep)) {
117 ptl = pte_lockptr(mm, pmd);
120 if (!is_swap_pte(pte))
123 entry = pte_to_swp_entry(pte);
125 if (!is_migration_entry(entry) ||
126 migration_entry_to_page(entry) != old)
130 pte = pte_mkold(mk_pte(new, vma->vm_page_prot));
131 if (is_write_migration_entry(entry))
132 pte = pte_mkwrite(pte);
133 flush_cache_page(vma, addr, pte_pfn(pte));
134 set_pte_at(mm, addr, ptep, pte);
137 page_add_anon_rmap(new, vma, addr);
139 page_add_file_rmap(new);
141 /* No need to invalidate - it was non-present before */
142 update_mmu_cache(vma, addr, ptep);
144 pte_unmap_unlock(ptep, ptl);
150 * Get rid of all migration entries and replace them by
151 * references to the indicated page.
153 static void remove_migration_ptes(struct page *old, struct page *new)
155 rmap_walk(new, remove_migration_pte, old);
159 * Something used the pte of a page under migration. We need to
160 * get to the page and wait until migration is finished.
161 * When we return from this function the fault will be retried.
163 * This function is called from do_swap_page().
165 void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
166 unsigned long address)
173 ptep = pte_offset_map_lock(mm, pmd, address, &ptl);
175 if (!is_swap_pte(pte))
178 entry = pte_to_swp_entry(pte);
179 if (!is_migration_entry(entry))
182 page = migration_entry_to_page(entry);
185 * Once radix-tree replacement of page migration started, page_count
186 * *must* be zero. And, we don't want to call wait_on_page_locked()
187 * against a page without get_page().
188 * So, we use get_page_unless_zero(), here. Even failed, page fault
191 if (!get_page_unless_zero(page))
193 pte_unmap_unlock(ptep, ptl);
194 wait_on_page_locked(page);
198 pte_unmap_unlock(ptep, ptl);
202 * Replace the page in the mapping.
204 * The number of remaining references must be:
205 * 1 for anonymous pages without a mapping
206 * 2 for pages with a mapping
207 * 3 for pages with a mapping and PagePrivate/PagePrivate2 set.
209 static int migrate_page_move_mapping(struct address_space *mapping,
210 struct page *newpage, struct page *page)
216 /* Anonymous page without mapping */
217 if (page_count(page) != 1)
222 spin_lock_irq(&mapping->tree_lock);
224 pslot = radix_tree_lookup_slot(&mapping->page_tree,
227 expected_count = 2 + page_has_private(page);
228 if (page_count(page) != expected_count ||
229 (struct page *)radix_tree_deref_slot(pslot) != page) {
230 spin_unlock_irq(&mapping->tree_lock);
234 if (!page_freeze_refs(page, expected_count)) {
235 spin_unlock_irq(&mapping->tree_lock);
240 * Now we know that no one else is looking at the page.
242 get_page(newpage); /* add cache reference */
243 if (PageSwapCache(page)) {
244 SetPageSwapCache(newpage);
245 set_page_private(newpage, page_private(page));
248 radix_tree_replace_slot(pslot, newpage);
250 page_unfreeze_refs(page, expected_count);
252 * Drop cache reference from old page.
253 * We know this isn't the last reference.
258 * If moved to a different zone then also account
259 * the page for that zone. Other VM counters will be
260 * taken care of when we establish references to the
261 * new page and drop references to the old page.
263 * Note that anonymous pages are accounted for
264 * via NR_FILE_PAGES and NR_ANON_PAGES if they
265 * are mapped to swap space.
267 __dec_zone_page_state(page, NR_FILE_PAGES);
268 __inc_zone_page_state(newpage, NR_FILE_PAGES);
269 if (PageSwapBacked(page)) {
270 __dec_zone_page_state(page, NR_SHMEM);
271 __inc_zone_page_state(newpage, NR_SHMEM);
273 spin_unlock_irq(&mapping->tree_lock);
279 * Copy the page to its new location
281 static void migrate_page_copy(struct page *newpage, struct page *page)
283 copy_highpage(newpage, page);
286 SetPageError(newpage);
287 if (PageReferenced(page))
288 SetPageReferenced(newpage);
289 if (PageUptodate(page))
290 SetPageUptodate(newpage);
291 if (TestClearPageActive(page)) {
292 VM_BUG_ON(PageUnevictable(page));
293 SetPageActive(newpage);
294 } else if (TestClearPageUnevictable(page))
295 SetPageUnevictable(newpage);
296 if (PageChecked(page))
297 SetPageChecked(newpage);
298 if (PageMappedToDisk(page))
299 SetPageMappedToDisk(newpage);
301 if (PageDirty(page)) {
302 clear_page_dirty_for_io(page);
304 * Want to mark the page and the radix tree as dirty, and
305 * redo the accounting that clear_page_dirty_for_io undid,
306 * but we can't use set_page_dirty because that function
307 * is actually a signal that all of the page has become dirty.
308 * Wheras only part of our page may be dirty.
310 __set_page_dirty_nobuffers(newpage);
313 mlock_migrate_page(newpage, page);
314 ksm_migrate_page(newpage, page);
316 ClearPageSwapCache(page);
317 ClearPagePrivate(page);
318 set_page_private(page, 0);
319 page->mapping = NULL;
322 * If any waiters have accumulated on the new page then
325 if (PageWriteback(newpage))
326 end_page_writeback(newpage);
329 /************************************************************
330 * Migration functions
331 ***********************************************************/
333 /* Always fail migration. Used for mappings that are not movable */
334 int fail_migrate_page(struct address_space *mapping,
335 struct page *newpage, struct page *page)
339 EXPORT_SYMBOL(fail_migrate_page);
342 * Common logic to directly migrate a single page suitable for
343 * pages that do not use PagePrivate/PagePrivate2.
345 * Pages are locked upon entry and exit.
347 int migrate_page(struct address_space *mapping,
348 struct page *newpage, struct page *page)
352 BUG_ON(PageWriteback(page)); /* Writeback must be complete */
354 rc = migrate_page_move_mapping(mapping, newpage, page);
359 migrate_page_copy(newpage, page);
362 EXPORT_SYMBOL(migrate_page);
366 * Migration function for pages with buffers. This function can only be used
367 * if the underlying filesystem guarantees that no other references to "page"
370 int buffer_migrate_page(struct address_space *mapping,
371 struct page *newpage, struct page *page)
373 struct buffer_head *bh, *head;
376 if (!page_has_buffers(page))
377 return migrate_page(mapping, newpage, page);
379 head = page_buffers(page);
381 rc = migrate_page_move_mapping(mapping, newpage, page);
390 bh = bh->b_this_page;
392 } while (bh != head);
394 ClearPagePrivate(page);
395 set_page_private(newpage, page_private(page));
396 set_page_private(page, 0);
402 set_bh_page(bh, newpage, bh_offset(bh));
403 bh = bh->b_this_page;
405 } while (bh != head);
407 SetPagePrivate(newpage);
409 migrate_page_copy(newpage, page);
415 bh = bh->b_this_page;
417 } while (bh != head);
421 EXPORT_SYMBOL(buffer_migrate_page);
425 * Writeback a page to clean the dirty state
427 static int writeout(struct address_space *mapping, struct page *page)
429 struct writeback_control wbc = {
430 .sync_mode = WB_SYNC_NONE,
433 .range_end = LLONG_MAX,
439 if (!mapping->a_ops->writepage)
440 /* No write method for the address space */
443 if (!clear_page_dirty_for_io(page))
444 /* Someone else already triggered a write */
448 * A dirty page may imply that the underlying filesystem has
449 * the page on some queue. So the page must be clean for
450 * migration. Writeout may mean we loose the lock and the
451 * page state is no longer what we checked for earlier.
452 * At this point we know that the migration attempt cannot
455 remove_migration_ptes(page, page);
457 rc = mapping->a_ops->writepage(page, &wbc);
459 if (rc != AOP_WRITEPAGE_ACTIVATE)
460 /* unlocked. Relock */
463 return (rc < 0) ? -EIO : -EAGAIN;
467 * Default handling if a filesystem does not provide a migration function.
469 static int fallback_migrate_page(struct address_space *mapping,
470 struct page *newpage, struct page *page)
473 return writeout(mapping, page);
476 * Buffers may be managed in a filesystem specific way.
477 * We must have no buffers or drop them.
479 if (page_has_private(page) &&
480 !try_to_release_page(page, GFP_KERNEL))
483 return migrate_page(mapping, newpage, page);
487 * Move a page to a newly allocated page
488 * The page is locked and all ptes have been successfully removed.
490 * The new page will have replaced the old page if this function
497 static int move_to_new_page(struct page *newpage, struct page *page,
500 struct address_space *mapping;
504 * Block others from accessing the page when we get around to
505 * establishing additional references. We are the only one
506 * holding a reference to the new page at this point.
508 if (!trylock_page(newpage))
511 /* Prepare mapping for the new page.*/
512 newpage->index = page->index;
513 newpage->mapping = page->mapping;
514 if (PageSwapBacked(page))
515 SetPageSwapBacked(newpage);
517 mapping = page_mapping(page);
519 rc = migrate_page(mapping, newpage, page);
520 else if (mapping->a_ops->migratepage)
522 * Most pages have a mapping and most filesystems
523 * should provide a migration function. Anonymous
524 * pages are part of swap space which also has its
525 * own migration function. This is the most common
526 * path for page migration.
528 rc = mapping->a_ops->migratepage(mapping,
531 rc = fallback_migrate_page(mapping, newpage, page);
534 newpage->mapping = NULL;
537 remove_migration_ptes(page, newpage);
540 unlock_page(newpage);
546 * Obtain the lock on page, remove all ptes and migrate the page
547 * to the newly allocated page in newpage.
549 static int unmap_and_move(new_page_t get_new_page, unsigned long private,
550 struct page *page, int force, int offlining)
554 struct page *newpage = get_new_page(page, private, &result);
555 int remap_swapcache = 1;
558 struct mem_cgroup *mem = NULL;
559 struct anon_vma *anon_vma = NULL;
564 if (page_count(page) == 1) {
565 /* page was freed from under us. So we are done. */
569 /* prepare cgroup just returns 0 or -ENOMEM */
572 if (!trylock_page(page)) {
579 * Only memory hotplug's offline_pages() caller has locked out KSM,
580 * and can safely migrate a KSM page. The other cases have skipped
581 * PageKsm along with PageReserved - but it is only now when we have
582 * the page lock that we can be certain it will not go KSM beneath us
583 * (KSM will not upgrade a page from PageAnon to PageKsm when it sees
584 * its pagecount raised, but only here do we take the page lock which
587 if (PageKsm(page) && !offlining) {
592 /* charge against new page */
593 charge = mem_cgroup_prepare_migration(page, newpage, &mem);
594 if (charge == -ENOMEM) {
600 if (PageWriteback(page)) {
603 wait_on_page_writeback(page);
606 * By try_to_unmap(), page->mapcount goes down to 0 here. In this case,
607 * we cannot notice that anon_vma is freed while we migrates a page.
608 * This rcu_read_lock() delays freeing anon_vma pointer until the end
609 * of migration. File cache pages are no problem because of page_lock()
610 * File Caches may use write_page() or lock_page() in migration, then,
611 * just care Anon page here.
613 if (PageAnon(page)) {
617 /* Determine how to safely use anon_vma */
618 if (!page_mapped(page)) {
619 if (!PageSwapCache(page))
623 * We cannot be sure that the anon_vma of an unmapped
624 * swapcache page is safe to use because we don't
625 * know in advance if the VMA that this page belonged
626 * to still exists. If the VMA and others sharing the
627 * data have been freed, then the anon_vma could
628 * already be invalid.
630 * To avoid this possibility, swapcache pages get
631 * migrated but are not remapped when migration
637 * Take a reference count on the anon_vma if the
638 * page is mapped so that it is guaranteed to
639 * exist when the page is remapped later
641 anon_vma = page_anon_vma(page);
642 atomic_inc(&anon_vma->external_refcount);
647 * Corner case handling:
648 * 1. When a new swap-cache page is read into, it is added to the LRU
649 * and treated as swapcache but it has no rmap yet.
650 * Calling try_to_unmap() against a page->mapping==NULL page will
651 * trigger a BUG. So handle it here.
652 * 2. An orphaned page (see truncate_complete_page) might have
653 * fs-private metadata. The page can be picked up due to memory
654 * offlining. Everywhere else except page reclaim, the page is
655 * invisible to the vm, so the page can not be migrated. So try to
656 * free the metadata, so the page can be freed.
658 if (!page->mapping) {
659 if (!PageAnon(page) && page_has_private(page)) {
661 * Go direct to try_to_free_buffers() here because
662 * a) that's what try_to_release_page() would do anyway
663 * b) we may be under rcu_read_lock() here, so we can't
664 * use GFP_KERNEL which is what try_to_release_page()
665 * needs to be effective.
667 try_to_free_buffers(page);
673 /* Establish migration ptes or remove ptes */
674 try_to_unmap(page, TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS);
677 if (!page_mapped(page))
678 rc = move_to_new_page(newpage, page, remap_swapcache);
680 if (rc && remap_swapcache)
681 remove_migration_ptes(page, page);
684 /* Drop an anon_vma reference if we took one */
685 if (anon_vma && atomic_dec_and_lock(&anon_vma->external_refcount, &anon_vma->lock)) {
686 int empty = list_empty(&anon_vma->head);
687 spin_unlock(&anon_vma->lock);
689 anon_vma_free(anon_vma);
696 mem_cgroup_end_migration(mem, page, newpage);
702 * A page that has been migrated has all references
703 * removed and will be freed. A page that has not been
704 * migrated will have kepts its references and be
707 list_del(&page->lru);
708 dec_zone_page_state(page, NR_ISOLATED_ANON +
709 page_is_file_cache(page));
710 putback_lru_page(page);
716 * Move the new page to the LRU. If migration was not successful
717 * then this will free the page.
719 putback_lru_page(newpage);
725 *result = page_to_nid(newpage);
733 * The function takes one list of pages to migrate and a function
734 * that determines from the page to be migrated and the private data
735 * the target of the move and allocates the page.
737 * The function returns after 10 attempts or if no pages
738 * are movable anymore because to has become empty
739 * or no retryable pages exist anymore. All pages will be
740 * returned to the LRU or freed.
742 * Return: Number of pages not migrated or error code.
744 int migrate_pages(struct list_head *from,
745 new_page_t get_new_page, unsigned long private, int offlining)
752 int swapwrite = current->flags & PF_SWAPWRITE;
756 current->flags |= PF_SWAPWRITE;
758 for(pass = 0; pass < 10 && retry; pass++) {
761 list_for_each_entry_safe(page, page2, from, lru) {
764 rc = unmap_and_move(get_new_page, private,
765 page, pass > 2, offlining);
776 /* Permanent failure */
785 current->flags &= ~PF_SWAPWRITE;
787 putback_lru_pages(from);
792 return nr_failed + retry;
797 * Move a list of individual pages
799 struct page_to_node {
806 static struct page *new_page_node(struct page *p, unsigned long private,
809 struct page_to_node *pm = (struct page_to_node *)private;
811 while (pm->node != MAX_NUMNODES && pm->page != p)
814 if (pm->node == MAX_NUMNODES)
817 *result = &pm->status;
819 return alloc_pages_exact_node(pm->node,
820 GFP_HIGHUSER_MOVABLE | GFP_THISNODE, 0);
824 * Move a set of pages as indicated in the pm array. The addr
825 * field must be set to the virtual address of the page to be moved
826 * and the node number must contain a valid target node.
827 * The pm array ends with node = MAX_NUMNODES.
829 static int do_move_page_to_node_array(struct mm_struct *mm,
830 struct page_to_node *pm,
834 struct page_to_node *pp;
837 down_read(&mm->mmap_sem);
840 * Build a list of pages to migrate
842 for (pp = pm; pp->node != MAX_NUMNODES; pp++) {
843 struct vm_area_struct *vma;
847 vma = find_vma(mm, pp->addr);
848 if (!vma || !vma_migratable(vma))
851 page = follow_page(vma, pp->addr, FOLL_GET);
861 /* Use PageReserved to check for zero page */
862 if (PageReserved(page) || PageKsm(page))
866 err = page_to_nid(page);
870 * Node already in the right place
875 if (page_mapcount(page) > 1 &&
879 err = isolate_lru_page(page);
881 list_add_tail(&page->lru, &pagelist);
882 inc_zone_page_state(page, NR_ISOLATED_ANON +
883 page_is_file_cache(page));
887 * Either remove the duplicate refcount from
888 * isolate_lru_page() or drop the page ref if it was
897 if (!list_empty(&pagelist))
898 err = migrate_pages(&pagelist, new_page_node,
899 (unsigned long)pm, 0);
901 up_read(&mm->mmap_sem);
906 * Migrate an array of page address onto an array of nodes and fill
907 * the corresponding array of status.
909 static int do_pages_move(struct mm_struct *mm, struct task_struct *task,
910 unsigned long nr_pages,
911 const void __user * __user *pages,
912 const int __user *nodes,
913 int __user *status, int flags)
915 struct page_to_node *pm;
916 nodemask_t task_nodes;
917 unsigned long chunk_nr_pages;
918 unsigned long chunk_start;
921 task_nodes = cpuset_mems_allowed(task);
924 pm = (struct page_to_node *)__get_free_page(GFP_KERNEL);
931 * Store a chunk of page_to_node array in a page,
932 * but keep the last one as a marker
934 chunk_nr_pages = (PAGE_SIZE / sizeof(struct page_to_node)) - 1;
936 for (chunk_start = 0;
937 chunk_start < nr_pages;
938 chunk_start += chunk_nr_pages) {
941 if (chunk_start + chunk_nr_pages > nr_pages)
942 chunk_nr_pages = nr_pages - chunk_start;
944 /* fill the chunk pm with addrs and nodes from user-space */
945 for (j = 0; j < chunk_nr_pages; j++) {
946 const void __user *p;
950 if (get_user(p, pages + j + chunk_start))
952 pm[j].addr = (unsigned long) p;
954 if (get_user(node, nodes + j + chunk_start))
958 if (node < 0 || node >= MAX_NUMNODES)
961 if (!node_state(node, N_HIGH_MEMORY))
965 if (!node_isset(node, task_nodes))
971 /* End marker for this chunk */
972 pm[chunk_nr_pages].node = MAX_NUMNODES;
974 /* Migrate this chunk */
975 err = do_move_page_to_node_array(mm, pm,
976 flags & MPOL_MF_MOVE_ALL);
980 /* Return status information */
981 for (j = 0; j < chunk_nr_pages; j++)
982 if (put_user(pm[j].status, status + j + chunk_start)) {
990 free_page((unsigned long)pm);
996 * Determine the nodes of an array of pages and store it in an array of status.
998 static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,
999 const void __user **pages, int *status)
1003 down_read(&mm->mmap_sem);
1005 for (i = 0; i < nr_pages; i++) {
1006 unsigned long addr = (unsigned long)(*pages);
1007 struct vm_area_struct *vma;
1011 vma = find_vma(mm, addr);
1015 page = follow_page(vma, addr, 0);
1017 err = PTR_ERR(page);
1022 /* Use PageReserved to check for zero page */
1023 if (!page || PageReserved(page) || PageKsm(page))
1026 err = page_to_nid(page);
1034 up_read(&mm->mmap_sem);
1038 * Determine the nodes of a user array of pages and store it in
1039 * a user array of status.
1041 static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,
1042 const void __user * __user *pages,
1045 #define DO_PAGES_STAT_CHUNK_NR 16
1046 const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR];
1047 int chunk_status[DO_PAGES_STAT_CHUNK_NR];
1050 unsigned long chunk_nr;
1052 chunk_nr = nr_pages;
1053 if (chunk_nr > DO_PAGES_STAT_CHUNK_NR)
1054 chunk_nr = DO_PAGES_STAT_CHUNK_NR;
1056 if (copy_from_user(chunk_pages, pages, chunk_nr * sizeof(*chunk_pages)))
1059 do_pages_stat_array(mm, chunk_nr, chunk_pages, chunk_status);
1061 if (copy_to_user(status, chunk_status, chunk_nr * sizeof(*status)))
1066 nr_pages -= chunk_nr;
1068 return nr_pages ? -EFAULT : 0;
1072 * Move a list of pages in the address space of the currently executing
1075 SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
1076 const void __user * __user *, pages,
1077 const int __user *, nodes,
1078 int __user *, status, int, flags)
1080 const struct cred *cred = current_cred(), *tcred;
1081 struct task_struct *task;
1082 struct mm_struct *mm;
1086 if (flags & ~(MPOL_MF_MOVE|MPOL_MF_MOVE_ALL))
1089 if ((flags & MPOL_MF_MOVE_ALL) && !capable(CAP_SYS_NICE))
1092 /* Find the mm_struct */
1093 read_lock(&tasklist_lock);
1094 task = pid ? find_task_by_vpid(pid) : current;
1096 read_unlock(&tasklist_lock);
1099 mm = get_task_mm(task);
1100 read_unlock(&tasklist_lock);
1106 * Check if this process has the right to modify the specified
1107 * process. The right exists if the process has administrative
1108 * capabilities, superuser privileges or the same
1109 * userid as the target process.
1112 tcred = __task_cred(task);
1113 if (cred->euid != tcred->suid && cred->euid != tcred->uid &&
1114 cred->uid != tcred->suid && cred->uid != tcred->uid &&
1115 !capable(CAP_SYS_NICE)) {
1122 err = security_task_movememory(task);
1127 err = do_pages_move(mm, task, nr_pages, pages, nodes, status,
1130 err = do_pages_stat(mm, nr_pages, pages, status);
1139 * Call migration functions in the vma_ops that may prepare
1140 * memory in a vm for migration. migration functions may perform
1141 * the migration for vmas that do not have an underlying page struct.
1143 int migrate_vmas(struct mm_struct *mm, const nodemask_t *to,
1144 const nodemask_t *from, unsigned long flags)
1146 struct vm_area_struct *vma;
1149 for (vma = mm->mmap; vma && !err; vma = vma->vm_next) {
1150 if (vma->vm_ops && vma->vm_ops->migrate) {
1151 err = vma->vm_ops->migrate(vma, to, from, flags);