*参照元 [#y742ecb8]
#backlinks

*説明 [#xd2bef15]
-パス: 複数あり
--CONFIG_MIGRATION 有効: [[linux-4.4.1/mm/migrate.c]]
--CONFIG_MIGRATION 無効: [[linux-4.4.1/include/linux/migrate.h]]

-FIXME: これは何?
--説明


**引数 [#x5817715]
-struct list_head *from
--
--[[linux-4.4.1/list_head]]
-new_page_t get_new_page
--
--[[linux-4.4.1/new_page_t]]
-free_page_t put_new_page
--
--[[linux-4.4.1/free_page_t]]
-unsigned long private
--
-enum migrate_mode mode
--
--[[linux-4.4.1/migrate_mode]]
-int reason
--


**返り値 [#bf916d09]
-int
--


**参考 [#debe2ccf]


*実装 [#v4efa0c3]

**CONFIG_MIGRATION 有効: linux-4.4.1/mm/migrate.c [#u5d111fb]
 /*
  * migrate_pages - migrate the pages specified in a list, to the free pages
  *                 supplied as the target for the page migration
  *
  * @from:               The list of pages to be migrated.
  * @get_new_page:       The function used to allocate free pages to be used
  *                      as the target of the page migration.
  * @put_new_page:       The function used to free target pages if migration
  *                      fails, or NULL if no special handling is necessary.
  * @private:            Private data to be passed on to get_new_page()
  * @mode:               The migration mode that specifies the constraints for
  *                      page migration, if any.
  * @reason:             The reason for page migration.
  *
  * The function returns after 10 attempts or if no pages are movable any more
  * because the list has become empty or no retryable pages exist any more.
  * The caller should call putback_movable_pages() to return pages to the LRU
  * or free list only if ret != 0.
  *
  * Returns the number of pages that were not migrated, or an error code.
  */
 int migrate_pages(struct list_head *from, new_page_t get_new_page,
                 free_page_t put_new_page, unsigned long private,
                 enum migrate_mode mode, int reason)
 {
         int retry = 1;
         int nr_failed = 0;
         int nr_succeeded = 0;
         int pass = 0;
         struct page *page;
         struct page *page2;
         int swapwrite = current->flags & PF_SWAPWRITE;
         int rc;
 
-
--[[linux-4.4.1/page]]

         if (!swapwrite)
                 current->flags |= PF_SWAPWRITE;
 
         for(pass = 0; pass < 10 && retry; pass++) {
                 retry = 0;
 
                 list_for_each_entry_safe(page, page2, from, lru) {
                         cond_resched();
 
-
--[[linux-4.4.1/list_for_each_entry_safe()]]
--[[linux-4.4.1/cond_resched()]]

                         if (PageHuge(page))
                                 rc = unmap_and_move_huge_page(get_new_page,
                                                 put_new_page, private, page,
                                                 pass > 2, mode);
                         else
                                 rc = unmap_and_move(get_new_page, put_new_page,
                                                 private, page, pass > 2, mode,
                                                 reason);
 
-
--[[linux-4.4.1/PageHuge()]]
--[[linux-4.4.1/unmap_and_move_huge_page()]]
--[[linux-4.4.1/unmap_and_move()]]

                         switch(rc) {
                         case -ENOMEM:
                                 goto out;
                         case -EAGAIN:
                                 retry++;
                                 break;
                         case MIGRATEPAGE_SUCCESS:
                                 nr_succeeded++;
                                 break;
                         default:
                                 /*
                                  * Permanent failure (-EBUSY, -ENOSYS, etc.):
                                  * unlike -EAGAIN case, the failed page is
                                  * removed from migration page list and not
                                  * retried in the next outer loop.
                                  */
                                 nr_failed++;
                                 break;
                         }
                 }
         }
         nr_failed += retry;
         rc = nr_failed;
 out:
         if (nr_succeeded)
                 count_vm_events(PGMIGRATE_SUCCESS, nr_succeeded);
         if (nr_failed)
                 count_vm_events(PGMIGRATE_FAIL, nr_failed);
         trace_mm_migrate_pages(nr_succeeded, nr_failed, mode, reason);
 
-
--[[linux-4.4.1/count_vm_events()]]
--[[linux-4.4.1/trace_mm_migrate_pages()]]

         if (!swapwrite)
                 current->flags &= ~PF_SWAPWRITE;
 
         return rc;
 }


**CONFIG_MIGRATION 無効: linux-4.4.1/include/linux/migrate.h [#b663a253]
 static inline int migrate_pages(struct list_head *l, new_page_t new,
                 free_page_t free, unsigned long private, enum migrate_mode mode,
                 int reason)
         { return -ENOSYS; }


*コメント [#ecd31e00]


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS