Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\migrate.c Create Date:2022-07-28 15:59:03
Last Modify:2022-05-20 09:53:13 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:__unmap_and_move

Proto:static int __unmap_and_move(struct page *page, struct page *newpage, int force, enum migrate_mode mode)

Type:int

Parameter:

TypeParameterName
struct page *page
struct page *newpage
intforce
enum migrate_modemode
1007  rc = -EAGAIN
1008  page_was_mapped = 0
1009  struct anon_vma * anon_vma = NULL
1010  is_lru = Not __PageMovable(page)
1012  If Not Return true if the page was successfully locked Then
1013  If Not force || mode == MIGRATE_ASYNC Then Go to out
1029  If flags & Allocating memory Then Go to out
1032  lock_page may only be called if we have the page's inode pinned.
1035  If Only test-and-set exist for PG_writeback. The unconditional operators are* risky: they bypass page accounting. Then
1043  Case mode == MIGRATE_SYNC
1044  Case mode == MIGRATE_SYNC_NO_COPY
1045  Break
1046  Default
1047  rc = -EBUSY
1048  Go to out_unlock
1050  If Not force Then Go to out_unlock
1052  Wait for a page to complete writeback
1069  If PageAnon(page) && Not A KSM page is one of those write-protected "shared pages" or "merged pages"* which KSM maps into multiple mms, wherever identical anonymous page content* is found in VM_MERGEABLE vmas. It's a PageAnon page, pointing not to any Then anon_vma = Getting a lock on a stable anon_vma from a page off the LRU is tricky!* Since there is no serialization what so ever against page_remove_rmap()* the best this function can do is return a locked anon_vma that might* have been relevant to this page
1080  If Value for the false possibility is greater at compile time(!Return true if the page was successfully locked) Then Go to out_unlock
1083  If Value for the false possibility is greater at compile time(!is_lru) Then
1084  rc = Move a page to a newly allocated page* The page is locked and all ptes have been successfully removed.* The new page will have replaced the old page if this function* is successful.* Return value:* < 0 - error code* MIGRATEPAGE_SUCCESS - success
1085  Go to out_unlock_both
1100  If Not See page-flags.h for PAGE_MAPPING_FLAGS Then
1101  VM_BUG_ON_PAGE(PageAnon(page), page)
1104  Go to out_unlock_both
1106  Else if Return true if this page is mapped into pagetables.* For compound page it returns true if any subpage of compound page is mapped. Then
1108  VM_BUG_ON_PAGE(PageAnon(page) && !A KSM page is one of those write-protected "shared pages" or "merged pages"* which KSM maps into multiple mms, wherever identical anonymous page content* is found in VM_MERGEABLE vmas. It's a PageAnon page, pointing not to any && !anon_vma, page)
1110  ry_to_unmap - try to remove all page table mappings to a page*@page: the page to get unmapped*@flags: action and flags* Tries to remove all the page table entries which are mapping this* page, used in the pageout path. Caller must hold the page lock.
1112  page_was_mapped = 1
1115  If Not Return true if this page is mapped into pagetables.* For compound page it returns true if any subpage of compound page is mapped. Then rc = Move a page to a newly allocated page* The page is locked and all ptes have been successfully removed.* The new page will have replaced the old page if this function* is successful.* Return value:* < 0 - error code* MIGRATEPAGE_SUCCESS - success
1118  If page_was_mapped Then Get rid of all migration entries and replace them by* references to the indicated page.
1122  out_unlock_both :
1123  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
1124  out_unlock :
1126  If anon_vma Then put_anon_vma(anon_vma)
1128  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
1129  out :
1139  If rc == Return values from addresss_space_operations.migratepage():* - negative errno on page migration failure;* - zero on page migration success; Then
1140  If Value for the false possibility is greater at compile time(!is_lru) Then Perform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
1142  Else putback_lru_page - put previously isolated page onto appropriate LRU list*@page: page to be put back to appropriate lru list* Add previously isolated @page to appropriate LRU list.* Page may still be unevictable for other reasons.
1146  Return rc
Caller
NameDescribe
unmap_and_moveObtain the lock on page, remove all ptes and migrate the page* to the newly allocated page in newpage.