函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\memory.c Create Date:2022-07-27 16:09:11
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Handle the case of a page which we actually need to copy to a new page.* Called with mmap_sem locked and the old page referenced, but* without the ptl held.* High level logic flow:* - Allocate a page, copy the content of the old page to the new one.

函数原型:static vm_fault_t wp_page_copy(struct vm_fault *vmf)

返回类型:vm_fault_t

参数:

类型参数名称
struct vm_fault *vmf
2462  vma等于Target VMA
2463  mm等于The address space we belong to.
2464  old_page等于->fault handlers should return a* page here, unless VM_FAULT_NOPAGE* is set (which is also implied by* VM_FAULT_ERROR).
2465  struct page * new_page = NULL
2467  page_copied等于0
2471  如果此条件成立可能性小(为编译器优化)(anon_vma_prepare(vma))则转到:oom
2474  如果is_zero_pfn(pte_pfn(Value of PTE at the time of fault ))则
2475  new_page等于alloc_zeroed_user_highpage_movable - Allocate a zeroed HIGHMEM page for a VMA that the caller knows can move*@vma: The VMA the page is to be allocated for*@vaddr: The virtual address the page will be inserted into* This function will allocate a page for a
2477  如果非new_page则转到:oom
2479  否则
2480  new_page等于alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, Faulting virtual address )
2482  如果非new_page则转到:oom
2485  如果非cow_user_page(new_page, old_page, vmf)则
2492  put_page(new_page)
2493  如果old_pageput_page(old_page)
2495  返回:0
2499  如果mem_cgroup_try_charge_delay(new_page, mm, GFP_KERNEL, & memcg, false)则转到:oom_free_new
2502  __SetPageUptodate(new_page)
2504  mmu_notifier_range_init( & range, MMU_NOTIFY_CLEAR, 0, vma, mm, Faulting virtual address & PAGE_MASK, (Faulting virtual address & PAGE_MASK) + PAGE_SIZE)
2507  mmu_notifier_invalidate_range_start( & range)
2512  Pointer to pte entry matching* the 'address'. NULL if the page* table hasn't been allocated.等于pte_offset_map_lock(mm, Pointer to pmd entry matching* the 'address' , Faulting virtual address , & Page table lock.* Protects pte page table if 'pte'* is not NULL, otherwise pmd.)
2513  如果此条件成立可能性大(为编译器优化)(pte_same( * Pointer to pte entry matching* the 'address'. NULL if the page* table hasn't been allocated., Value of PTE at the time of fault ))则
2514  如果old_page
2515  如果非PageAnon(old_page)则
2520  否则
2523  flush_cache_page(vma, Faulting virtual address , pte_pfn(Value of PTE at the time of fault ))
2524  entry等于Conversion functions: convert a page and protection to a page entry,* and a page entry and page directory to the page they refer to.* (Currently stuck as a macro because of indirect forward reference* to linux/mm.h:page_to_nid())(new_page, Access permissions of this VMA. )
2525  entry等于Do pte_mkwrite, but only if the vma says VM_WRITE. We do this when* servicing faults for write access. In the normal case, do always want* pte_mkwrite. But get_user_pages can cause write faults for mappings
2532  ptep_clear_flush_notify(vma, Faulting virtual address , Pointer to pte entry matching* the 'address'. NULL if the page* table hasn't been allocated.)
2533  page_add_new_anon_rmap(new_page, vma, Faulting virtual address , false)
2534  mem_cgroup_commit_charge(new_page, memcg, TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., false)
2535  lru_cache_add_active_or_unevictable*@page: the page to be added to LRU*@vma: vma in which page is mapped for determining reclaimability* Place @page on the active or unevictable LRU list, depending on its* evictability
2541  set_pte_at_notify() sets the pte _after_ running the notifier.* This is safe to start by updating the secondary MMUs, because the primary MMU* pte invalidate must have already happened with a ptep_clear_flush() before* set_pte_at_notify() has been invoked(mm, Faulting virtual address , Pointer to pte entry matching* the 'address'. NULL if the page* table hasn't been allocated., entry)
2542  The x86 doesn't have any external MMU info: the kernel page* tables contain all the necessary information.
2543  如果old_page
2566  page_remove_rmap(old_page, false)
2570  new_page等于old_page
2571  page_copied等于1
2572  否则
2573  mem_cgroup_cancel_charge(new_page, memcg, false)
2576  如果new_pageput_page(new_page)
2579  pte_unmap_unlock(Pointer to pte entry matching* the 'address'. NULL if the page* table hasn't been allocated., Page table lock.* Protects pte page table if 'pte'* is not NULL, otherwise pmd.)
2584  mmu_notifier_invalidate_range_only_end( & range)
2585  如果old_page
2590  如果page_copiedFlags, see mm.h. 按位与VM_LOCKED
2596  put_page(old_page)
2598  返回:如果page_copiedVM_FAULT_WRITE否则0
2599  oom_free_new :
2600  put_page(new_page)
2601  oom :
2602  如果old_pageput_page(old_page)
2604  返回:VM_FAULT_OOM
调用者
名称描述
do_wp_pageThis routine handles present pages, when users try to write* to a shared page. It is done by copying the page to a new address* and decrementing the shared-page counter for the old page.* Note that this routine assumes that the protection checks have been